canvasの既存コンテクスト内容を型抜き

by ethertank

JavaScript

var c = document.createElement("canvas"),
    ctx = c.getContext("2d");
c.width = 50;
c.height = 50;

document.body.appendChild(c);

ctx.fillRect(0, 0, 50, 50); //black rectangle
ctx.globalCompositeOperation = "destination-atop"; //型抜き
ctx.beginPath();
ctx.arc(25, 25, 25, 0, 2 * Math.PI, true);
ctx.fill();