INNER CODE UNIT · TypeScript
ensureContexts
silvia-odwyer/photon · webpack_demo/src/index.ts:129
const ensureContexts = (): boolean => {
if (!canvas || !ctx || !newimg) {
console.warn("Photon demo is still initialising.");
return false;
}
return true;
};
const ensureBlendCanvasSize = () => {
if (!canvas2 || !ctx2 || !newimg || !img2) {
return;
}
const targetWidth = newimg.width >= img2.width ? newimg.width + 1 : img2.width;
const targetHeight =
newimg.height >= img2.height ? newimg.height + 1 : img2.height;
if (canvas2.width !== targetWidth || canvas2.height !== targetHeight) {
canvas2.width = targetWidth;
canvas2.height = targetHeight;