(width: number, height: number, preferOffscreen?: CreateCanvasPreference)
| 168 | } |
| 169 | |
| 170 | createCanvas (width: number, height: number, preferOffscreen?: CreateCanvasPreference): PicaCanvas { |
| 171 | if (preferOffscreen && this.capabilities.offscreen_canvas) { |
| 172 | return new OffscreenCanvas(width, height) |
| 173 | } |
| 174 | |
| 175 | if (this.capabilities.canvas) { |
| 176 | const canvas = document.createElement('canvas') |
| 177 | canvas.width = width |
| 178 | canvas.height = height |
| 179 | return canvas |
| 180 | } |
| 181 | |
| 182 | if (this.capabilities.ww_offscreen_canvas) { |
| 183 | return new OffscreenCanvas(width, height) |
| 184 | } |
| 185 | |
| 186 | throw new Error('Pica: cannot create canvas') |
| 187 | } |
| 188 | |
| 189 | private __createWorkerSlot (): { value: Worker, destroy: () => void } { |
| 190 | if (this.options.workerURL) { |
no outgoing calls
no test coverage detected