const origPalette = ["#f398c3", "#cf3895", "#a0d28d", "#06b4b0", "#fef45f", "#fed000", "#0c163f"]
let palette = [...origPalette]
description: 'Redefine pi'
OPC.button('reset', 'Rerun')
Math.cos = (a) => prevCos(a / prevPi * newPi)
Math.sin = (a) => prevSin(a / prevPi * newPi)
function buttonPressed(variableName, value) {
while (blobs.length > 0) {
palette = [...origPalette]
blobs.push(new Blob(random(-1,1)*100, 50, 100, palette.pop()))
engine = Matter.Engine.create()
const ground = Matter.Bodies.rectangle(0, height / 2 + 30, width, 60, {
const wallLeft = Matter.Bodies.rectangle(-width/2 - 30, 0, 60, 3 * height, {
const wallRight = Matter.Bodies.rectangle(width/2 + 30, 0, 60, 3 * height, {
Matter.World.add(engine.world, [ground, wallLeft, wallRight])
translate(width/2, height/2)
if (frameCount % (60 * 3) === 0 && palette.length > 0) {
blobs.push(new Blob(random(-1,1)*100, -height/2 - 150, random(25, 150), palette.pop()))
for (const blob of blobs) {
Matter.Engine.update(engine, 1000 / 60)
for (const blob of blobs) {