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;
}