3
나는 똑같이 다섯 부분으로 나누어지는 반지를 만들려고합니다. JS/JQuery를 처음 접했을 때 내 방식이 정통 적이 될 수 있습니다. 아래는 내가 가지고있는 코드 :캔버스 내에서 반지를 어떻게 자르 죠?
var c=document.getElementById("c");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.arc(430,430,300,0,2*Math.PI,true);//x-y-r-angle-PI-rotation(clockwise vs anti//
ctx.closePath();
ctx.strokeStyle="#000";
ctx.stroke();
ctx.save();
ctx.beginPath();
ctx.arc(430,430,200,0,2*Math.PI);
ctx.closePath();
ctx.strokeStyle="#000";
ctx.stroke();
ctx.clip();
var drawAngledLine = function(x, y, length, angle) {
var radians = angle/180 * Math.PI;
var endX = x + length * Math.cos(radians);
var endY = y - length * Math.sin(radians);
ctx.beginPath();
ctx.moveTo(x, y)
ctx.lineTo(endX, endY);
ctx.closePath();
ctx.stroke();
}
ctx.strokeStyle = "#000";
ctx.lineWidth = "1";
drawAngledLine(430, 430, 300, -90);
drawAngledLine(430, 430, 300, -162);
drawAngledLine(430, 430, 300, -234);
drawAngledLine(430, 430, 300, -306);
drawAngledLine(430, 430, 300, -18);
ctx.restore();
ctx.beginPath();
ctx.arc(430,430,200,0,2*Math.PI,true);
ctx.strokeStyle="#000";
ctx.stroke();
내가 ctx.clip를 사용하려고했습니다(); 하지만 줄의 내부를 잘라내어 내부를 가리고 원 안쪽과 바깥 쪽 원 사이를 연결하는 선만 표시하고 싶습니다. 이미지가 없으면 설명하기가 어렵습니다 ...
누군가의 도움을주십시오. 미리 환호하십시오.
Loktar 이즈 그쪽으로 bezt –