MCPcopy
hub / github.com/nodeca/pica / createCanvas

Method createCanvas

src/pica_main.ts:170–187  ·  view source on GitHub ↗
(width: number, height: number, preferOffscreen?: CreateCanvasPreference)

Source from the content-addressed store, hash-verified

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) {

Callers 6

__extractTileDataMethod · 0.95
__planStagesAndResizeMethod · 0.95
resizeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected