@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
25 lines (16 loc) • 636 B
JavaScript
import { html_canvas_to_rendering_context2d_cached } from "./html_canvas_to_rendering_context2d_cached.js";
import { Sampler2D } from './sampler/Sampler2D.js';
/**
*
* @param {HTMLCanvasElement} canvas
* @returns {Sampler2D}
*/
function html_canvas_to_sampler2d(canvas) {
const width = canvas.width;
const height = canvas.height;
const context = html_canvas_to_rendering_context2d_cached(canvas);
const imageData = context.getImageData(0, 0, width, height);
const data = imageData.data;
return new Sampler2D(data, 4, width, height);
}
export default html_canvas_to_sampler2d;