{"componentChunkName":"component---src-templates-blog-post-js","path":"/sketches/day025","result":{"data":{"site":{"id":"Site","siteMetadata":{"title":"Creative code daily"}},"src":{"id":"497fd6a5-d6a3-5b8b-8e2d-70e8ae98e76b","publicURL":"/static/day025-7ae2983ea0472173cb30dcbdd01aa83d.pde","childRawCode":{"id":"497fd6a5-d6a3-5b8b-8e2d-70e8ae98e76b >>> RawCode","content":"/**\n Name: Day 25 Oo Ripples\n */\n\nimport com.hamoid.*;\n\nboolean isReadyForExport = true;\ncolor beige = color(249, 248, 235);\ncolor strokeColor = #4c3232;\n\nVideoExport export;\nfloat frame = 0;\nint maxFrameNumber = 600; // The number of frame to record\n// `width` and `height` are automagically set by size\n\nvoid setup() {\n  size(500, 500);\n\n  // Uncomment next line for high DPI support, makes larger files\n  // pixelDensity(displayDensity());\n\n  colorMode(HSB, 100);\n  randomSeed(0);\n\n  if (isReadyForExport) {\n    export = new VideoExport(this, \"out.mp4\");\n    export.setFrameRate(60);\n    export.startMovie();\n  }\n}\n\nvoid reset() {\n  noStroke();\n  background(beige);\n}\n\nfloat LIFE = 120.0;\nfloat MAX_SIZE = 200;\nclass Particle {\n  PVector pos;\n  float lastFrame;\n  float firstFrame;\n  \n  Particle() {\n    pos = new PVector(random( width), random(height));\n    firstFrame = frameCount;\n    lastFrame = frameCount + LIFE;\n  }\n\n  void draw() {\n    pushMatrix();\n    translate(pos.x, pos.y);\n    strokeWeight(5);\n    \n    float normalizedValue = (LIFE - (lastFrame - frameCount)) / LIFE;\n    float alpha = (1 - normalizedValue * normalizedValue * normalizedValue) * 100.0;\n    \n    fill(beige, alpha);\n    stroke(strokeColor, alpha);\n    circle(0, 0, normalizedValue * MAX_SIZE);\n    \n    if(normalizedValue >= 0.33) {\n      circle(0, 0, (normalizedValue - 0.33) * MAX_SIZE);\n    }\n    \n    if(normalizedValue >= 0.66) {\n      circle(0, 0, (normalizedValue - 0.66) * MAX_SIZE);\n    }\n     //<>//\n    popMatrix();\n  }\n\n  boolean isDead() {\n    return frameCount > lastFrame;\n  }\n}\n\nArrayList<Particle> particles = new ArrayList<Particle>();\n\nvoid update() {\n  if (frameCount == (maxFrameNumber - LIFE)) randomSeed(0); \n  if (frameCount % 20 == 0) particles.add(new Particle());\n  // Since we create a particle every 60 frames and they are added at the end, there can be only one removable and it's the first one.\n  if (particles.size() > 0 && particles.get(0).isDead()) {\n    particles.remove(0);\n  }\n}\n\nvoid animation() {\n  update();\n  for (Particle particle : particles) {\n    particle.draw();\n  }\n}\n\nvoid draw() {\n  reset();\n  animation();\n\n  if (isReadyForExport) {\n    if(frameCount >= LIFE + 20) {\n      export.saveFrame();\n    }\n    if (frame == LIFE) saveFrame(\"screenshot-1.png\");\n    if (frame == Math.floor(maxFrameNumber / 3)) saveFrame(\"screenshot-2.png\");\n    if (frame == 2 * Math.floor(maxFrameNumber / 3)) saveFrame(\"screenshot-3.png\");\n  }\n\n  if (frame++ >= maxFrameNumber) {\n    if (isReadyForExport) {\n      export.endMovie();\n    }\n    exit();\n  }\n}\n"}},"video":{"id":"2522bdc9-2993-5ed6-a052-58c919b1b17d","publicURL":"/static/out-551755156a94fd5961cff7628bc1eb2a.mp4"},"screenshot":{"id":"3e2a958a-2eb3-5f5f-b12b-18eae862cdba","publicURL":"/static/screenshot-2-ff5ed0efc547f6c33f997395717a7e5a.png"}},"pageContext":{"nameRegex":"/day025/","name":"day025"}}}