TESTER

line

line(x1, y1, x2, y2, [stroke], [weight])

Draw a line

Syntaxe

line(x1=10, y1=10, x2=5, y2=5, stroke="#000000",weight=4)

Arguments

NameRequiredDefaultDescription
x1yes-x-coordinate of the first point
y1yes-y-coordinate of the first point
x2yes-x-coordinate of the second point
y2yes-y-coordinate of the second point
stroke--Stroke color
weight--Stroke weight (thickness)

Full example

var settings = {
    speed: 0.001,
    color: "#f2eb8a",
    alpha: "11",
    nFrames: 8000
};

noise(alpha=2.0, beta=2.0, octaves=3, seed=TAU);

canvas(800, 600, "#000");

var sc = 1.75;
coord_scale(sc);
coord_translate(-width()*(1-1/sc)/2, -height()*(1-1/sc)/2);

weight(1);
for (var i = 0; i < settings.nFrames; i++) {
    var t = i * settings.speed;
    var x1 = noise1d(t) * width();
    var y1 = noise1d(100 + t) * height();
    var x2 = noise1d(200 + t) * width();
    var y2 = noise1d(300 + t) * height();

    stroke(settings.color+settings.alpha); 
    line(x1, y1, x2, y2);
}

save("line.png");