Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
drcmda committed Jun 13, 2023
2 parents bdfca6e + a7fc9ce commit 6517cac
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions packages/test-renderer/src/createTestCanvas.ts
Expand Up @@ -2,16 +2,19 @@ import { WebGL2RenderingContext } from './WebGL2RenderingContext'
import type { CreateCanvasParameters } from './types/internal'

export const createCanvas = ({ beforeReturn, width = 1280, height = 800 }: CreateCanvasParameters = {}) => {
const canvas = {
width,
height,
style: {},
addEventListener: (() => {}) as any,
removeEventListener: (() => {}) as any,
clientWidth: width,
clientHeight: height,
getContext: (() => new WebGL2RenderingContext(canvas)) as any,
} as HTMLCanvasElement
const canvas =
typeof document !== 'undefined' && typeof document.createElement === 'function'
? document.createElement('canvas')
: ({
style: {},
addEventListener: (() => {}) as any,
removeEventListener: (() => {}) as any,
clientWidth: width,
clientHeight: height,
getContext: (() => new WebGL2RenderingContext(canvas)) as any,
} as HTMLCanvasElement)
canvas.width = width
canvas.height = height

beforeReturn?.(canvas)

Expand Down

0 comments on commit 6517cac

Please sign in to comment.