3 function TemplateCanvasObject(stage)
5 // For the canvas stage, most likely you will need to create your
6 // animated object since it's only draw time thing.
8 // Fill in your object data.
11 TemplateCanvasObject.prototype = {
17 animate: function(timeDelta)
19 // Redraw the animated object. The last time this animated
20 // item was drawn before 'timeDelta'.
24 // Redraw your object.
29 TemplateCanvasStage = Utilities.createSubclass(Stage,
35 initialize: function(benchmark, options)
37 Stage.prototype.initialize.call(this, benchmark, options);
38 this.context = this.element.getContext("2d");
40 // Define a collection for your objects.
45 // If count is -ve, -count elements need to be removed form the
46 // stage. If count is +ve, +count elements need to be added to
49 // Change objects in the stage.
52 animate: function(timeDelta)
54 // Animate the elements such that all of them are redrawn. Most
55 // likely you will need to call TemplateCanvasObject.animate()
56 // for all your animated objects here.
58 // Most likely you will need to clear the canvas with every redraw.
59 this.context.clearRect(0, 0, this.size.x, this.size.y);
61 // Loop through all your objects and ask them to animate.
65 TemplateCanvasBenchmark = Utilities.createSubclass(Benchmark,
68 Benchmark.call(this, new TemplateCanvasStage(), options);
71 // Override this function if the benchmark needs to wait for resources to be
74 // Default implementation returns a resolved promise, so that the benchmark
75 // benchmark starts right away. Here's an example where we're waiting 5
76 // seconds before starting the benchmark.
77 waitUntilReady: function()
79 var promise = new SimplePromise;
80 window.setTimeout(function() {
87 window.benchmarkClass = TemplateCanvasBenchmark;