| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // This code in inspired by the canvas arcs test on the animometer | 4 // This code in inspired by the canvas arcs test on the animometer |
| 5 // benchmark (https://pr.gg/animometer/developer.html). | 5 // benchmark (https://pr.gg/animometer/developer.html). |
| 6 // Javascript code: https://pr.gg/animometer/tests/master/resources/canvas-tests
.js | 6 // Javascript code: https://pr.gg/animometer/tests/master/resources/canvas-tests
.js |
| 7 | 7 |
| 8 function CanvasArc() { | 8 function CanvasArc() { |
| 9 var x; | 9 var x; |
| 10 var y; | 10 var y; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 var colors = ["#101010", "#808080", "#c0c0c0", | 38 var colors = ["#101010", "#808080", "#c0c0c0", |
| 39 "#e01040", "#10c030", "#e05010"]; | 39 "#e01040", "#10c030", "#e05010"]; |
| 40 this.color = colors[Math.floor(Math.random() * colors.length)]; | 40 this.color = colors[Math.floor(Math.random() * colors.length)]; |
| 41 | 41 |
| 42 this.is_stroke = (Math.floor(Math.random() * 3) == 0); | 42 this.is_stroke = (Math.floor(Math.random() * 3) == 0); |
| 43 | 43 |
| 44 this.counterclockwise = (Math.floor(Math.random() * 2) == 0); | 44 this.counterclockwise = (Math.floor(Math.random() * 2) == 0); |
| 45 | 45 |
| 46 this.arc_speed = (Math.random() - 0.5) * Math.PI / 10; | 46 this.arc_speed = (Math.random() - 0.5) * Math.PI / 10; |
| 47 |
| 47 this.start_angle = Math.random() * 2 * Math.PI; | 48 this.start_angle = Math.random() * 2 * Math.PI; |
| 48 this.end_angle = Math.random() * 2 * Math.PI; | 49 this.end_angle = Math.random() * 2 * Math.PI; |
| 49 } | 50 } |
| 50 | 51 |
| 51 this.draw = function(context) { | 52 this.draw = function(context) { |
| 52 this.start_angle += this.arc_speed; | 53 this.start_angle += this.arc_speed; |
| 53 this.end_angle += this.arc_speed / 2; | 54 this.end_angle += this.arc_speed / 2; |
| 54 | 55 |
| 55 // draw the canvas arc on the given context | 56 // draw the canvas arc on the given context |
| 56 if (this.is_stroke) { | 57 if (this.is_stroke) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // draw all initialized_arcs on the context | 97 // draw all initialized_arcs on the context |
| 97 for(var i = 0; i < initialized_arcs.length; i++) { | 98 for(var i = 0; i < initialized_arcs.length; i++) { |
| 98 initialized_arcs[i].draw(context); | 99 initialized_arcs[i].draw(context); |
| 99 } | 100 } |
| 100 }; | 101 }; |
| 101 | 102 |
| 102 return arcs; | 103 return arcs; |
| 103 })(); | 104 })(); |
| 104 | 105 |
| 105 | 106 |
| OLD | NEW |