Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/inline_editor/BezierUI.js

Issue 2623743002: DevTools: extract modules (non-extensions) (Closed)
Patch Set: rebaseline Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 /** 4 /**
5 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 UI.BezierUI = class { 7 InlineEditor.BezierUI = class {
8 /** 8 /**
9 * @param {number} width 9 * @param {number} width
10 * @param {number} height 10 * @param {number} height
11 * @param {number} marginTop 11 * @param {number} marginTop
12 * @param {number} controlPointRadius 12 * @param {number} controlPointRadius
13 * @param {boolean} linearLine 13 * @param {boolean} linearLine
14 */ 14 */
15 constructor(width, height, marginTop, controlPointRadius, linearLine) { 15 constructor(width, height, marginTop, controlPointRadius, linearLine) {
16 this.width = width; 16 this.width = width;
17 this.height = height; 17 this.height = height;
18 this.marginTop = marginTop; 18 this.marginTop = marginTop;
19 this.radius = controlPointRadius; 19 this.radius = controlPointRadius;
20 this.linearLine = linearLine; 20 this.linearLine = linearLine;
21 } 21 }
22 22
23 /** 23 /**
24 * @param {!Common.Geometry.CubicBezier} bezier 24 * @param {!Common.Geometry.CubicBezier} bezier
25 * @param {!Element} path 25 * @param {!Element} path
26 * @param {number} width 26 * @param {number} width
27 */ 27 */
28 static drawVelocityChart(bezier, path, width) { 28 static drawVelocityChart(bezier, path, width) {
29 var height = UI.BezierUI.Height; 29 var height = InlineEditor.BezierUI.Height;
30 var pathBuilder = ['M', 0, height]; 30 var pathBuilder = ['M', 0, height];
31 /** @const */ var sampleSize = 1 / 40; 31 /** @const */ var sampleSize = 1 / 40;
32 32
33 var prev = bezier.evaluateAt(0); 33 var prev = bezier.evaluateAt(0);
34 for (var t = sampleSize; t < 1 + sampleSize; t += sampleSize) { 34 for (var t = sampleSize; t < 1 + sampleSize; t += sampleSize) {
35 var current = bezier.evaluateAt(t); 35 var current = bezier.evaluateAt(t);
36 var slope = (current.y - prev.y) / (current.x - prev.x); 36 var slope = (current.y - prev.y) / (current.x - prev.x);
37 var weightedX = prev.x * (1 - t) + current.x * t; 37 var weightedX = prev.x * (1 - t) + current.x * t;
38 slope = Math.tanh(slope / 1.5); // Normalise slope 38 slope = Math.tanh(slope / 1.5); // Normalise slope
39 pathBuilder = pathBuilder.concat(['L', (weightedX * width).toFixed(2), (he ight - slope * height).toFixed(2)]); 39 pathBuilder = pathBuilder.concat(['L', (weightedX * width).toFixed(2), (he ight - slope * height).toFixed(2)]);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 curve.setAttribute( 118 curve.setAttribute(
119 'd', 'M' + this.radius + ',' + (height + this.radius + this.marginTop) + ' C' + curvePoints.join(' ')); 119 'd', 'M' + this.radius + ',' + (height + this.radius + this.marginTop) + ' C' + curvePoints.join(' '));
120 120
121 this._drawControlPoints( 121 this._drawControlPoints(
122 group, 0, height, bezier.controlPoints[0].x * width, (1 - bezier.control Points[0].y) * height); 122 group, 0, height, bezier.controlPoints[0].x * width, (1 - bezier.control Points[0].y) * height);
123 this._drawControlPoints( 123 this._drawControlPoints(
124 group, width, 0, bezier.controlPoints[1].x * width, (1 - bezier.controlP oints[1].y) * height); 124 group, width, 0, bezier.controlPoints[1].x * width, (1 - bezier.controlP oints[1].y) * height);
125 } 125 }
126 }; 126 };
127 127
128 UI.BezierUI.Height = 26; 128 InlineEditor.BezierUI.Height = 26;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698