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.
Merge pull request #343 from Brooooooklyn/fabric
Fabric.js compatible
- Loading branch information
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.