Skip to content

Commit

Permalink
fix: DOMMatrix object to skia Transform convert (#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Feb 11, 2023
1 parent b4c161e commit c82d41d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions __test__/draw.spec.ts
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
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
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

0 comments on commit c82d41d

Please sign in to comment.