UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

19 lines (14 loc) 469 B
import { assert } from "../../../core/assert.js"; /** * * @param {Sampler2D} target * @param {CanvasRenderingContext2D} ctx */ export function canvasDataToSampler(target, ctx) { const width = target.width; const height = target.height; const imageData = ctx.getImageData(0, 0, width, height); const data = imageData.data; assert.equal(data.length, target.height * target.width * target.itemSize); target.data = data; }