1 describe('PathKit\'s Effects', function() {
3 // see https://fiddle.skia.org/c/@discrete_path
4 function drawStar(X=128, Y=128, R=116) {
5 let p = PathKit.NewPath();
7 for (let i = 1; i < 8; i++) {
9 p.lineTo(X + R * Math.cos(a), Y + R * Math.sin(a));
15 it('effects_dash', function(done) {
17 ctx.path = drawStar();
21 let path = ctx.path.copy().dash(10, 3, 1);
25 function teardown(ctx) {
29 LoadPathKit.then(() => {
30 benchmarkAndReport('effects_dash', setup, test, teardown).then(() => {
32 }).catch(reportError(done));
36 it('effects_trim', function(done) {
38 ctx.path = drawStar();
42 let path = ctx.path.copy().trim(0.25, .8);
46 function teardown(ctx) {
50 LoadPathKit.then(() => {
51 benchmarkAndReport('effects_trim', setup, test, teardown).then(() => {
53 }).catch(reportError(done));
57 it('effects_trim_complement', function(done) {
59 ctx.path = drawStar();
63 let path = ctx.path.copy().trim(0.25, .8, true);
67 function teardown(ctx) {
71 LoadPathKit.then(() => {
72 benchmarkAndReport('effects_trim_complement', setup, test, teardown).then(() => {
74 }).catch(reportError(done));
78 it('effects_transform', function(done) {
80 ctx.path = drawStar();
84 let path = ctx.path.copy().transform(3, 0, 0,
90 function teardown(ctx) {
94 LoadPathKit.then(() => {
95 benchmarkAndReport('effects_transform', setup, test, teardown).then(() => {
97 }).catch(reportError(done));
101 it('effects_stroke', function(done) {
102 function setup(ctx) {
103 ctx.path = drawStar();
107 let path = ctx.path.copy().stroke({
109 join: PathKit.StrokeJoin.BEVEL,
110 cap: PathKit.StrokeCap.BUTT,
116 function teardown(ctx) {
120 LoadPathKit.then(() => {
121 benchmarkAndReport('effects_stroke', setup, test, teardown).then(() => {
123 }).catch(reportError(done));