Below is my live coding practice for this week.
Demo 1
// feedback
src(s0).mult(osc(10,0,1)).out()
osc(2,0.,1).scale(0.5).modulate(noise(3,0.01),1).out(o1)
src(o2).modulate(src(o1).add(solid(1,1),-0.5),.005).blend(src(o0).add(o0).add(o0).add(o0),0.25).out(o2)
render(o2)
let p5 = new P5()
s0.init({src: p5.canvas})
p5.hide()
let hearts = []
let colors = ["#edbba8", "#e66f3c", "#c6b6d5", "#f1d147", "#a4cd98", "#95accb"]
class Heart {
constructor(p) {
this.p = p
this.x = p.random(p.width)
this.y = -20
this.r = p.random(0.5, 1.2)
this.dy = p.random(1, 3)
this.c = p.random(colors)
}
display() {
this.p.push()
this.p.translate(this.x, this.y)
this.p.fill(this.c)
this.p.noStroke()
this.p.beginShape()
for (let i = 0; i < this.p.TWO_PI; i += 0.1) {
let x = 16 * Math.pow(Math.sin(i), 3) * this.r
let y = (13 * Math.cos(i) - 5 * Math.cos(2 * i) - 2 * Math.cos(3 * i) - Math.cos(4 * i)) * -this.r
this.p.vertex(x, y)
}
this.p.endShape(this.p.CLOSE)
this.p.pop()
}
fall() {
this.y += this.dy
}
}
p5.draw = () => {
p5.clear()
if (p5.frameCount % 10 == 0) {
hearts.push(new Heart(p5))
}
for (let i = hearts.length - 1; i >= 0; i--) {
hearts[i].display()
hearts[i].fall()
if (hearts[i].y > p5.height + 20) {
hearts.splice(i, 1)
}
}
}
src(s0)
.modulate(noise(3), 0.1)
.out()
Demo 2