Метод clip
Удаляется все что находится вне указанной фигуры. На рисунке будет удалено все, что вне звезды:

Синтаксис
clip()
Пример
var canvas = document.getElementById("picture");
var ctx = canvas.getContext("2d");
ctx.arc(200, 200, 100, 0, 2 * Math.PI, false);
ctx.stroke();
ctx.clip();
ctx.beginPath();
ctx.arc(100, 100, 150, 0, 2 * Math.PI, false);
ctx.fillStyle = "red";
ctx.fill();
ctx.beginPath();
ctx.arc(300, 400, 250, 0, 2 * Math.PI, false);
ctx.fillStyle = "green";
ctx.fill();
Материалы
Показать комментарии
