OLD | NEW |
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 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @param {number} width | 7 * @param {number} width |
8 * @param {number} height | 8 * @param {number} height |
9 * @param {number} marginTop | 9 * @param {number} marginTop |
10 * @param {number} controlPointRadius | 10 * @param {number} controlPointRadius |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 var height = WebInspector.AnimationUI.Options.AnimationHeight; | 110 var height = WebInspector.AnimationUI.Options.AnimationHeight; |
111 var pathBuilder = ["M", 0, height]; | 111 var pathBuilder = ["M", 0, height]; |
112 const sampleSize = 1 / 40; | 112 const sampleSize = 1 / 40; |
113 | 113 |
114 var prev = bezier.evaluateAt(0); | 114 var prev = bezier.evaluateAt(0); |
115 for (var t = sampleSize; t < 1 + sampleSize; t += sampleSize) { | 115 for (var t = sampleSize; t < 1 + sampleSize; t += sampleSize) { |
116 var current = bezier.evaluateAt(t); | 116 var current = bezier.evaluateAt(t); |
117 var slope = (current.y - prev.y) / (current.x - prev.x); | 117 var slope = (current.y - prev.y) / (current.x - prev.x); |
118 var weightedX = prev.x * (1 - t) + current.x * t; | 118 var weightedX = prev.x * (1 - t) + current.x * t; |
119 slope = Math.tanh(slope / 1.5); // Normalise slope | 119 slope = Math.tanh(slope / 1.5); // Normalise slope |
120 pathBuilder = pathBuilder.concat(["L", weightedX * width, height - slope
* height ]); | 120 pathBuilder = pathBuilder.concat(["L", (weightedX * width).toFixed(2), (
height - slope * height).toFixed(2) ]); |
121 prev = current; | 121 prev = current; |
122 } | 122 } |
123 pathBuilder = pathBuilder.concat(["L", width, height, "Z"]); | 123 pathBuilder = pathBuilder.concat(["L", width.toFixed(2), height, "Z"]); |
124 path.setAttribute("d", pathBuilder.join(" ")); | 124 path.setAttribute("d", pathBuilder.join(" ")); |
125 } | 125 } |
OLD | NEW |