Skip to content

Commit

Permalink
chore: tolerate max error in rough test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoiver committed Jan 26, 2025
1 parent d59011a commit 3bcc5cd
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 0 deletions.
15 changes: 15 additions & 0 deletions __tests__/ssr/rough-circle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ describe('RoughCircle', () => {
expect($canvas.getContext('webgl1')).toMatchWebGLSnapshot(
dir,
'rough-circle',
{
maxError: 1000,
},
);
expect(exporter.toSVG({ grid: true })).toMatchSVGSnapshot(
dir,
Expand All @@ -66,6 +69,9 @@ describe('RoughCircle', () => {
expect($canvas.getContext('webgl1')).toMatchWebGLSnapshot(
dir,
'rough-circle-zigzag',
{
maxError: 1000,
},
);
expect(exporter.toSVG({ grid: true })).toMatchSVGSnapshot(
dir,
Expand All @@ -90,6 +96,9 @@ describe('RoughCircle', () => {
expect($canvas.getContext('webgl1')).toMatchWebGLSnapshot(
dir,
'rough-circle-cross-hatch',
{
maxError: 1000,
},
);
expect(exporter.toSVG({ grid: true })).toMatchSVGSnapshot(
dir,
Expand All @@ -111,6 +120,9 @@ describe('RoughCircle', () => {
expect($canvas.getContext('webgl1')).toMatchWebGLSnapshot(
dir,
'rough-circle-solid',
{
maxError: 1000,
},
);
expect(exporter.toSVG({ grid: true })).toMatchSVGSnapshot(
dir,
Expand All @@ -132,6 +144,9 @@ describe('RoughCircle', () => {
expect($canvas.getContext('webgl1')).toMatchWebGLSnapshot(
dir,
'rough-circle-dashed',
{
maxError: 1000,
},
);
expect(exporter.toSVG({ grid: true })).toMatchSVGSnapshot(
dir,
Expand Down
3 changes: 3 additions & 0 deletions __tests__/ssr/rough-ellipse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ describe('RoughEllipse', () => {
expect($canvas.getContext('webgl1')).toMatchWebGLSnapshot(
dir,
'rough-ellipse',
{
maxError: 1000,
},
);
expect(exporter.toSVG({ grid: true })).toMatchSVGSnapshot(
dir,
Expand Down
6 changes: 6 additions & 0 deletions __tests__/ssr/rough-path.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ describe('RoughPath', () => {
expect($canvas.getContext('webgl1')).toMatchWebGLSnapshot(
dir,
'rough-path',
{
maxError: 1000,
},
);
expect(exporter.toSVG({ grid: true })).toMatchSVGSnapshot(
dir,
Expand All @@ -62,6 +65,9 @@ describe('RoughPath', () => {
expect($canvas.getContext('webgl1')).toMatchWebGLSnapshot(
dir,
'rough-path-transform',
{
maxError: 1000,
},
);
expect(exporter.toSVG({ grid: true })).toMatchSVGSnapshot(
dir,
Expand Down
3 changes: 3 additions & 0 deletions __tests__/ssr/rough-polyline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ describe('RoughPolyline', () => {
expect($canvas.getContext('webgl1')).toMatchWebGLSnapshot(
dir,
'rough-polyline',
{
maxError: 1000,
},
);
expect(exporter.toSVG({ grid: true })).toMatchSVGSnapshot(
dir,
Expand Down
12 changes: 12 additions & 0 deletions __tests__/ssr/rough-rect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ describe('RoughRect', () => {
expect($canvas.getContext('webgl1')).toMatchWebGLSnapshot(
dir,
'rough-rect',
{
maxError: 1000,
},
);
expect(exporter.toSVG({ grid: true })).toMatchSVGSnapshot(
dir,
Expand All @@ -67,6 +70,9 @@ describe('RoughRect', () => {
expect($canvas.getContext('webgl1')).toMatchWebGLSnapshot(
dir,
'rough-rect-stroke',
{
maxError: 1000,
},
);
expect(exporter.toSVG({ grid: true })).toMatchSVGSnapshot(
dir,
Expand Down Expand Up @@ -94,6 +100,9 @@ describe('RoughRect', () => {
expect($canvas.getContext('webgl1')).toMatchWebGLSnapshot(
dir,
'rough-rect-dropshadow',
{
maxError: 1000,
},
);
expect(exporter.toSVG({ grid: true })).toMatchSVGSnapshot(
dir,
Expand All @@ -120,6 +129,9 @@ describe('RoughRect', () => {
expect($canvas.getContext('webgl1')).toMatchWebGLSnapshot(
dir,
'rough-rect-rerender',
{
maxError: 1000,
},
);
expect(exporter.toSVG({ grid: true })).toMatchSVGSnapshot(
dir,
Expand Down
16 changes: 16 additions & 0 deletions packages/site/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,22 @@ call(() => {
}
});

// evenodd fill rule
const star = new Path({
d: 'M150 0 L121 90 L198 35 L102 35 L179 90 Z',
fill: '#F67676',
fillRule: 'evenodd',
tessellationMethod: TesselationMethod.LIBTESS, // instead of earcut
});
canvas.appendChild(star);

// holes
const ring = new Path({
d: 'M 50 10 A 40 40 0 1 0 50 90 A 40 40 0 1 0 50 10 Z M 50 30 A 20 20 0 1 1 50 70 A 20 20 0 1 1 50 30 Z',
fill: '#F67676',
});
canvas.appendChild(ring);

// SDF
const text = new Text({
x: 300,
Expand Down
16 changes: 16 additions & 0 deletions packages/site/docs/zh/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,22 @@ call(() => {
}
});

// evenodd fill rule
const star = new Path({
d: 'M150 0 L121 90 L198 35 L102 35 L179 90 Z',
fill: '#F67676',
fillRule: 'evenodd',
tessellationMethod: TesselationMethod.LIBTESS, // instead of earcut
});
canvas.appendChild(star);

// holes
const ring = new Path({
d: 'M 50 10 A 40 40 0 1 0 50 90 A 40 40 0 1 0 50 10 Z M 50 30 A 20 20 0 1 1 50 70 A 20 20 0 1 1 50 30 Z',
fill: '#F67676',
});
canvas.appendChild(ring);

// SDF
const text = new Text({
x: 300,
Expand Down

0 comments on commit 3bcc5cd

Please sign in to comment.