TESTER

arc

arc(x, y, radius, start, stop, [close], [pie], [stroke], [fill], [weight])

Draw an arc

Syntaxe

arc(x=10, y=10, radius=100, start=0, stop=HALF_PI, stroke="#000000", fill="#FFA000", weight=4)

Arguments

NameRequiredDefaultDescription
xyes-x-coordinate of the center
yyes-y-coordinate of the center
radiusyes-Radius of the arc
startyes-angle to start the arc, specified in radians
stopyes-angle to stop the arc, specified in radians
close--close the arc (useless if pie is used)
pie--close the arc to the center (overrides close)
stroke--Stroke color
fill--Fill color
weight--Stroke weight (thickness)

Full example

var margin = 10;
var radius = 50;

var x = radius + margin;
var y = radius + margin;

var gap = 10 ;

var startStart = 0;
var stopStart = PI / 4;
var stopEnd = TWO_PI - PI / 4;
var count = 10;
var stepX = radius*2 + gap;
var rowGap = radius * 2 + gap;

var canvasWidth = margin * 2 + radius * 2 + (count - 1) * stepX;
var canvasHeight = margin * 2 + radius * 2;
canvas(canvasWidth, canvasHeight * 4);


stroke("#0D150A");
weight(3);

for (var i = 0; i < count; i++) {
    var t = i / (count - 1);
    var stop = stopStart + t * (stopEnd - stopStart);

    arc(x + i * stepX, y, radius, startStart, stop, fill="transparent");
    circle(x + i * stepX, y, 3, fill="#889092", stroke="transparent");
    
    fill("#E0E3C6");
    arc(x + i * stepX, y + rowGap, radius, startStart, stop);
    circle(x + i * stepX, y + rowGap, 3, fill="#889092", stroke="transparent");
    
    fill("#F3B61F");
    arc(x + i * stepX, y + rowGap * 2, radius, startStart, stop, close=true);
    circle(x + i * stepX, y + rowGap * 2, 3, fill="#889092", stroke="transparent");
    
    fill("#E86219");
    arc(x + i * stepX, y + rowGap * 3, radius, startStart, stop, pie=true);
    circle(x + i * stepX, y + rowGap * 3, 3, fill="#889092", stroke="transparent");

}

save("arc.png");