Skip to content

Commit 8e245c5

Browse files
author
saŭlo
committed
canvas test
1 parent 5254e3d commit 8e245c5

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

lib/js/tests/Webapi/Canvas/Webapi__Canvas__Canvas2d__test.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,19 @@ ctx.strokeRect(1, 0, 10, 10);
158158

159159
ctx.clearRect(1, 0, 10, 10);
160160

161-
var path = new Path2D("M24.85,10.126c2.018-4.783,6.628-8.125,11.99-8.125c7.223,0,12.425,6.179,13.079,13.543 c0,0,0.353,1.828-0.424,5.119c-1.058,4.482-3.545,8.464-6.898,11.503L24.85,48L7.402,32.165c-3.353-3.038-5.84-7.021-6.898-11.503 c-0.777-3.291-0.424-5.119-0.424-5.119C0.734,8.179,5.936,2,13.159,2C18.522,2,22.832,5.343,24.85,10.126z");
161+
var path1 = new Path2D(undefined);
162+
163+
var path2 = new Path2D("M24.85,10.126c2.018-4.783,6.628-8.125,11.99-8.125c7.223,0,12.425,6.179,13.079,13.543 c0,0,0.353,1.828-0.424,5.119c-1.058,4.482-3.545,8.464-6.898,11.503L24.85,48L7.402,32.165c-3.353-3.038-5.84-7.021-6.898-11.503 c-0.777-3.291-0.424-5.119-0.424-5.119C0.734,8.179,5.936,2,13.159,2C18.522,2,22.832,5.343,24.85,10.126z");
164+
165+
path1.rect(1, 2, 10, 10);
166+
167+
path2.bezierCurveTo(1, 2, 2, 2, 4, 4);
162168

163169
ctx.beginPath();
164170

165-
ctx.stroke(path);
171+
ctx.stroke(path1);
166172

167-
ctx.fill(path);
173+
ctx.fill(path2);
168174

169175
exports.canvasEl = canvasEl;
170176
exports.ctx = ctx;
@@ -183,5 +189,6 @@ exports.imageFromData = imageFromData;
183189
exports.w = w;
184190
exports.h = h;
185191
exports.frameFromImage = frameFromImage;
186-
exports.path = path;
192+
exports.path1 = path1;
193+
exports.path2 = path2;
187194
/* canvasEl Not a pure module */

tests/Webapi/Canvas/Webapi__Canvas__Canvas2d__test.res

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,17 @@ ctx->fillRect(~x=1., ~y=0., ~w=10., ~h=10.)
112112
ctx->strokeRect(~x=1., ~y=0., ~w=10., ~h=10.)
113113
ctx->clearRect(~x=1., ~y=0., ~w=10., ~h=10.)
114114

115-
let path: path2d = newPath2D("M24.85,10.126c2.018-4.783,6.628-8.125,11.99-8.125c7.223"
115+
116+
let path1 = Path2d.make()
117+
let path2 = Path2d.make(~d="M24.85,10.126c2.018-4.783,6.628-8.125,11.99-8.125c7.223"
116118
++ ",0,12.425,6.179,13.079,13.543 c0,0,0.353,1.828-0.424,5.119c-1.058,4.482"
117119
++ "-3.545,8.464-6.898,11.503L24.85,48L7.402,32.165c-3.353-3.038-5.84-7.021"
118120
++ "-6.898-11.503 c-0.777-3.291-0.424-5.119-0.424-5.119C0.734,8.179,5.936,2"
119-
++ ",13.159,2C18.522,2,22.832,5.343,24.85,10.126z")
121+
++ ",13.159,2C18.522,2,22.832,5.343,24.85,10.126z",())
122+
123+
path1->Path2d.rect(~x=1., ~y=2., ~w=10., ~h=10.)
124+
path2->Path2d.bezierCurveTo(~cp1x=1., ~cp1y=2., ~cp2x=2., ~cp2y=2., ~x=4., ~y=4.)
125+
120126
ctx->beginPath
121-
ctx->strokePath2D(path)
122-
ctx->fillPath2D(path)
127+
ctx->strokePath2d(path1)
128+
ctx->fillPath2d(path2)

0 commit comments

Comments
 (0)