2011-12-20 7 views

답변

2

사각형에는 기본 제공 기능이 없습니다. 그러나이 (demo)처럼 arcTo로 직접 그릴 수 있습니다 :

function drawRoundButton(ctx, x, y, width, height, arcsize) { 
    ctx.beginPath(); 
    ctx.moveTo(x+arcsize, y); 
    ctx.lineTo(x+width-arcsize, y); 
    ctx.arcTo(x+width, y, x+width, y+arcsize, arcsize); 
    ctx.lineTo(x+width,y+height-arcsize); 
    ctx.arcTo(x+width, y+height, x+width-arcsize, y+height, arcsize); 
    ctx.lineTo(x+arcsize, y+height); 
    ctx.arcTo(x, y+height, x, y-arcsize, arcsize); 
    ctx.lineTo(x, y+arcsize); 
    ctx.arcTo(x, y, x+arcsize, y, arcsize); 
    ctx.lineTo(x+arcsize, y); 
    ctx.stroke(); 
    ctx.fill(); 
} 
+0

user1020026 @ 죄송합니다, 이해가 안 돼요. 당신의 문제는 정확히 무엇입니까? 지금까지 가지고있는 것에 대한 링크를 게시 할 수 있습니까? – phihag

관련 문제