url: "simple/simple-canvas-paths.html?pathType=linePath&lineJoin=miter",
name: "Canvas line path, miter join"
},
+ {
+ url: "simple/simple-canvas-paths.html?pathType=linePath&lineDash=1",
+ name: "Canvas line path with dash pattern"
+ },
{
url: "simple/simple-canvas-paths.html?pathType=quadratic",
name: "Canvas quadratic segments"
CanvasLinePathStage.prototype = Object.create(SimpleCanvasPathStrokeStage.prototype);
CanvasLinePathStage.prototype.constructor = CanvasLinePathStage;
+function CanvasLineDashStage(element, options)
+{
+ SimpleCanvasStage.call(this, element, options, CanvasLinePoint);
+ this.context.setLineDash([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
+ this.context.lineWidth = 1;
+ this.context.strokeStyle = "#000";
+ this._step = 0;
+}
+CanvasLineDashStage.prototype = Object.create(SimpleCanvasStage.prototype);
+CanvasLineDashStage.prototype.constructor = CanvasLineDashStage;
+CanvasLineDashStage.prototype.animate = function() {
+ var context = this.context;
+ context.lineDashOffset = this._step++;
+ context.beginPath();
+ context.moveTo(0,0);
+ this._objects.forEach(function(object) {
+ object.draw(context);
+ });
+ context.stroke();
+};
+
// === BENCHMARK ===
function CanvasPathBenchmark(suite, test, options, recordTable, progressBar) {
case "linePath": {
if ("lineJoin" in this._options)
return new CanvasLinePathStage(element, this._options);
+ if ("lineDash" in this._options)
+ return new CanvasLineDashStage(element, this._options);
break;
}
case "quadratic":
+2015-10-12 Jon Lee <jonlee@apple.com>
+
+ Add canvas line dash test
+ https://bugs.webkit.org/show_bug.cgi?id=150078
+ <rdar://problem/23082347>
+
+ Reviewed by Dean Jackson.
+
+ * Animometer/runner/resources/tests.js: Add line dash test.
+ * Animometer/tests/simple/resources/simple-canvas-paths.js:
+ (CanvasLineDashStage): Create a new stage with a default dash pattern and stroke style.
+ Maintain a step which will animate the dash.
+ (CanvasLineDashStage.prototype.animate): Render the line path with the dash. Increment
+ the dash offset to animate.
+ (CanvasPathBenchmark.prototype.createStage): Add the test.
+
2015-10-12 Jon Lee <jonlee@apple.com>
Add canvas line path tests