Skip to content

Commit

Permalink
fix: skia async prop deprecated in future release
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeve-Stobs committed Jun 25, 2022
1 parent 462fce5 commit 088e628
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 7 additions & 4 deletions benchmark/gradient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ function drawGradient(factory: (width: number, height: number) => Canvas) {

const ctx = canvas.getContext('2d')!

// @ts-expect-error
canvas.async = false

const gradient = ctx.createLinearGradient(20, 0, 220, 0)

// Add three color stops
Expand All @@ -25,7 +22,13 @@ function drawGradient(factory: (width: number, height: number) => Canvas) {
ctx.fillStyle = gradient
ctx.fillRect(20, 20, 200, 100)

canvas.toBuffer('image/png')
if (canvas instanceof SkiaCanvas) {
canvas.toBufferSync('image/png')
} else {
// @ts-expect-error
canvas.async = false
canvas.toBuffer('image/png')
}
}

export function gradient() {
Expand Down
11 changes: 7 additions & 4 deletions benchmark/house.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import { createCanvas as skiaCreateCanvas } from '../index'
function drawHouse(factory: (width: number, height: number) => Canvas) {
const canvas = factory(1024, 768)

// @ts-expect-error
canvas.async = false

const ctx = canvas.getContext('2d')!

ctx.lineWidth = 10
Expand All @@ -32,7 +29,13 @@ function drawHouse(factory: (width: number, height: number) => Canvas) {
ctx.closePath()
ctx.stroke()

canvas.toBuffer('image/png')
if (canvas instanceof SkiaCanvas) {
canvas.toBufferSync('image/png')
} else {
// @ts-expect-error
canvas.async = false
canvas.toBuffer('image/png')
}
}

export function house() {
Expand Down

0 comments on commit 088e628

Please sign in to comment.