Util for rounded rectangle in turtletoy
Log in to post a comment.
const width = 150; // min=20, max=200, step=5 const height = 75; // min=20, max=200, step=5 const borderRadius = 10; // min=0, max=50, step=1 const turtle = new Turtle(); drawRoundedRect(-width/2, -height/2, width, height, borderRadius); function drawRoundedRect(x, y, w, h, tl, tr=tl, br=tl, bl=tr) { turtle.radians(); tl = Math.min(tl, w/2, h/2); tr = Math.min(tr, w/2, h/2); br = Math.min(br, w/2, h/2); bl = Math.min(bl, w/2, h/2); turtle.jump(x+tl, y); turtle.forward(w-tr-tl); turtle.circle(tr, Math.PI/2); turtle.forward(h-br-tr); turtle.circle(br, Math.PI/2); turtle.forward(w-bl-br); turtle.circle(bl, Math.PI/2); turtle.forward(h-tl-bl); turtle.circle(tl, Math.PI/2); }