line
Draw a line
line(
x1,
y1,
x2,
y2,
[stroke=#000000],
[weight=1.00]
)
Draw a line
Syntaxe
line(x1=10, y1=10, x2=5, y2=5, stroke="#000000",weight=4)
Arguments
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
x1 | yes | - | x-coordinate of the first point | |
y1 | yes | - | y-coordinate of the first point | |
x2 | yes | - | x-coordinate of the second point | |
y2 | yes | - | y-coordinate of the second point | |
stroke | - | #000000 | Stroke color | |
weight | - | 1.00 | Stroke weight (thickness) |
Full example
var params = {
speed: 0.001,
color: "#f2eb8a",
alpha: "11",
nFrames: 8000
};
noise(alpha=2.0, beta=2.0, octaves=3, seed=TAU);
canvas(800, 600, "#000000");
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 < params.nFrames; i++) {
var t = i * params.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(params.color+params.alpha);
line(x1, y1, x2, y2);
}
save(whoami() + ".png");
