generated from napi-rs/package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: pass the fabric.js visual tests
- Fix addColorStop sort issue in CanvasGradient - Fix Transform::inverse method - No need map_points in CanvasGradient::get_shader - CSS Color now allowed to be empty string - Allow createPattern from another Canvas - toDataURL should be STANDARD base64 - swap Path in beginPath for better performance
- Loading branch information
1 parent
a2bd455
commit ec55b3a
Showing
35 changed files
with
2,392 additions
and
1,470 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import test from 'ava' | ||
|
||
import { createCanvas, Canvas } from '../index' | ||
|
||
test('Canvas constructor should be equal to createCanvas', (t) => { | ||
t.deepEqual(createCanvas(200, 100), new Canvas(200, 100)) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import ava, { TestInterface } from 'ava' | ||
|
||
import { createCanvas, Canvas, SKRSContext2D } from '../index' | ||
import { snapshotImage } from './image-snapshot' | ||
|
||
const test = ava as TestInterface<{ | ||
canvas: Canvas | ||
ctx: SKRSContext2D | ||
}> | ||
|
||
test.beforeEach((t) => { | ||
const canvas = createCanvas(512, 512) | ||
t.context.canvas = canvas | ||
t.context.ctx = canvas.getContext('2d')! | ||
}) | ||
|
||
test('transform-with-state', async (t) => { | ||
const canvas = createCanvas(256, 256) | ||
const ctx = canvas.getContext('2d') | ||
ctx.translate(128.5, 128.5) | ||
ctx.scale(1, 1) | ||
ctx.clearRect(-128, -128, 256, 256) | ||
ctx.beginPath() | ||
ctx.moveTo(-52.5, -38.5) | ||
ctx.lineTo(52.5, -38.5) | ||
ctx.lineTo(52.5, 38.5) | ||
ctx.lineTo(-52.5, 38.5) | ||
ctx.lineTo(-52.5, -38.5) | ||
ctx.closePath() | ||
ctx.save() | ||
const p = ctx.createLinearGradient(0, 0, 0, 77) | ||
p.addColorStop(1, 'rgba(0, 128, 128, 1)') | ||
p.addColorStop(0.6, 'rgba(0, 255, 255, 1)') | ||
p.addColorStop(0.3, 'rgba(176, 199, 45, 1)') | ||
p.addColorStop(0.0, 'rgba(204, 82, 51, 1)') | ||
ctx.fillStyle = p | ||
ctx.transform(1, 0, 0, 1, -52.5, -38.5) | ||
ctx.transform(1, 0, 0, 1, 0, 0) | ||
ctx.fill() | ||
ctx.restore() | ||
await snapshotImage(t, { canvas, ctx }) | ||
}) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
ec55b3a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
Draw house#skia-canvas
26
ops/sec (±0.38%
)19.5
ops/sec (±0.79%
)0.75
Draw house#node-canvas
23
ops/sec (±0.3%
)19.1
ops/sec (±1.36%
)0.83
Draw house#@napi-rs/skia
25
ops/sec (±0.12%
)20.3
ops/sec (±1.1%
)0.81
Draw gradient#skia-canvas
26
ops/sec (±0.73%
)19
ops/sec (±1.26%
)0.73
Draw gradient#node-canvas
22
ops/sec (±0.24%
)18
ops/sec (±1.68%
)0.82
Draw gradient#@napi-rs/skia
25
ops/sec (±0.1%
)20
ops/sec (±1.38%
)0.80
This comment was automatically generated by workflow using github-action-benchmark.