💾drawOnCanvas2D()

browsercanvas ⟩ drawOnCanvas2D()

💾 replit: square & circle

// ⭐ draw on <canvas> 2D context
function drawOnCanvas2D(selector, draw) {
    let canvas = document.querySelector(selector);
    if (!canvas) { console.log(`⛔ no such element: "${selector}"`); return; }
    let context = canvas.getContext("2d");
    if (draw) draw(context);
}

Last updated