Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: DOMMatrix object to skia Transform convert #633

Merged
merged 1 commit into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions __test__/draw.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,18 @@ test('setTransform', async (t) => {
await snapshotImage(t)
})

test('setTransform matrix', async (t) => {
const { ctx } = t.context
const mat = new DOMMatrix()
.rotate(30)
.skewX(30)
.scale(1, Math.sqrt(3) / 2)
ctx.setTransform(mat)
ctx.fillStyle = 'red'
ctx.fillRect(100, 100, 100, 100)
await snapshotImage(t)
})

test('stroke', async (t) => {
const { ctx } = t.context
// First sub-path
Expand Down
Binary file added __test__/snapshots/setTransform matrix.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1919,10 +1919,10 @@ impl From<TransformObject> for Transform {
fn from(value: TransformObject) -> Self {
Self::new(
value.a as f32,
value.b as f32,
value.c as f32,
value.d as f32,
value.e as f32,
value.b as f32,
value.d as f32,
value.f as f32,
)
}
Expand Down