Published
Edited
Nov 6, 2020
Fork of Circle Wave
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mutable atcp = [];
Insert cell
canvas = {
const context = DOM.context2d(width, height);
const line = d3.lineRadial()
.context(context)
.curve(d3.curveLinearClosed)
.angle((r, i) => i * 2 * Math.PI / n)
.radius(r => r);
let prevTime = performance.now();
while (true) {
context.clearRect(0, 0, width, height);
context.save();
context.translate(width / 2, height / 2);
context.lineWidth = lineWidth;
context.lineJoin = "round";
context.globalCompositeOperation = glCompOp;
colors.forEach((color, j) => {
context.beginPath();
line(Float64Array.from({length: n}, (_, i) => {
const a = i * 2 * Math.PI / n;
const t = (paused ? prevTime : performance.now()) * speed;
const c = Math.cos(a * frequency - j * shift + t);
const p = Math.pow((1 + Math.cos(a - t)) / 2, 3);
return radius + amplitude * c * p;
}));
context.strokeStyle = color;
context.stroke();
});
context.restore();
yield context.canvas;
}
}
Insert cell
colors = ["cyan", "magenta", "yellow"]
// colors = ['#ff4242', '#1841fe', '#74E9AE']

Insert cell
shift = 2 * Math.PI / shiftAmt
Insert cell
speed = speedAmt //1 / 1000
Insert cell
frequency = freqAmt
Insert cell
amplitude = amplitudeAmt
Insert cell
width = widthAmt
Insert cell
radius = radiusAmt //Math.min(width, height) / 2 - amplitude * 2
Insert cell
height = 640
Insert cell
mutable n = nAmt //360
Insert cell
import {slider, select, color} from "@jashkenas/inputs"
Insert cell
d3 = require("d3-shape@1")
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