Published
Edited
Mar 17, 2021
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
w = params.w || 540
Insert cell
h = params.h || w
Insert cell
prngSeed = params.prngSeed || Date.now()
Insert cell
simplexSeed = params.simplexSeed || Date.now()
Insert cell
stepY = params.stepY || 20
Insert cell
p = params.p || getRandomPalette()
Insert cell
palette = params.palette || shuffle(p)
Insert cell
Insert cell
Insert cell
render = bnb({
w, h,
numFrames: 120,
fps: 20,
record: true,
video: 'mp4',
// shutterAngle: 0.5,
// samplesPerFrame: 4,
preload: (s, g) => {
g.pg = s.createGraphics(w, h)
},

draw: (s, t, g) => {
const cosT = s.cos(t * s.TAU) * s.sin(t * s.TAU) * .3
const sinT = s.sin(t * s.TAU) * .6

s.background(palette[0])
s.strokeCap(s.SQUARE)

s.drawingContext.shadowBlur = 5
s.drawingContext.shadowColor = 'rgba(22, 22, 22, .5)'
s.drawingContext.shadowOffsetX = -3
s.drawingContext.shadowOffSetY = 3
s.push()
// s.stroke(0, 0)
// s.fill(0, 0) //for transparent clipping
// s.circle(w/2, h/2, w - 40)
// s.drawingContext.clip()
// s.fill(palette[0])
// s.circle(w/2, h/2, w)
const sw = 1
s.strokeWeight(sw)
const prng = new PRNG(prngSeed)
for(let y = 0; y < h; y += stepY) {
g.pg.clear()
g.pg.stroke(palette[prng.rand(1, palette.length-1)])
//const step = prng.rand(sw * 1.5, 8)
const step = .5
for(let x = 0; x < w; x += step) {
const u = PVector(x, y)
u.addY(simplex.noise4D(u.x / 200, u.y, cosT, sinT) * 150)
const v = PVector(x, y + stepY - 1)
v.addY(simplex.noise4D(v.x / 200, v.y, cosT, sinT) * 150)
if(u.y < v.y) g.pg.line(u.x, u.y, v.x, v.y)
}
s.image(g.pg, 0, 0)
}
s.pop()
// s.stroke(22)
// s.strokeWeight(4)
// s.noFill()
// s.circle(w/2, h/2, w - 40)
}
})
Insert cell
simplex = new SimplexNoise(simplexSeed)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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