Public
Edited
Feb 2, 2023
Insert cell
Insert cell
viewof form = Inputs.form({
width: Inputs.range([0, 1000], { label: "Width", step: 1, value: 1000 }),
height: Inputs.range([4, 1000], { label: "Height", step: 1, value: 1000 }),

})
Insert cell
Insert cell
shad = (n) => {
let arr = [];
let y1, y2, r, jump, y_diff;

r = 100 + Math.random() * 100;
for (let i = 0; i < n; i++) {
y1 = H * 0.2 + H * Math.random() * 0.3;
y2 = H * 0.5 + H * Math.random() * 0.4;
y_diff = y2 - y1;
jump = 1 + Math.random() * 10;
arr[i] = {
x: W * 0.2 + Math.random() * W * 0.6,
y1: y1,
y2: y2,
y_diff: y2 - y1,
jump: jump,
rrate: r / (y_diff / jump),
r: r,
j: 0,
n: 1 + Math.floor(Math.random() * 10),
clr: getColor(),
c1: getColor(),
c2: getColor()
};
}
return arr;
}
Insert cell
Insert cell
W = form.width
Insert cell
H = form.height
Insert cell
Insert cell
Insert cell
import { p5 } from "@tmcw/p5"
Insert cell
import { try_it } from "@observablehq/notes"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more