“Blue growth” by Elisabeth TheAwsome
https://openprocessing.org/sketch/178381
License CreativeCommons Attribution ShareAlike
https://creativecommons.org/licenses/by-sa/3.0
{{filePath}}
{{width}} x {{height}}
Report Sketch
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
A fork of Original program, off the interwebbery by Elisabeth TheAwsome
CC Attribution ShareAlike
Blue growth
TheAwsome
xxxxxxxxxx
//Raven Kwok aka Guo, Ruiwen
//ravenkwok.com
//vimeo.com/ravenkwok
//flickr.com/photos/ravenkwok
ArrayList<Particle> pts;
boolean onPressed, showInstruction;
PFont f;
void setup() {
size(720, 720, P2D);
smooth();
frameRate(30);
colorMode(RGB);
rectMode(CENTER);
pts = new ArrayList<Particle>();
showInstruction = true;
f = createFont("Calibri", 24, true);
background(255);
}
void draw() {
if (showInstruction) {
background(255);
fill(128);
textAlign(CENTER, CENTER);
textFont(f);
textLeading(36);
text("Drag and draw." + "\n" +
"Press 'c' to clear the stage." + "\n"
, width*0.5, height*0.5);
}
if (onPressed) {
for (int i=0;i<10;i++) {
Particle newP = new Particle(mouseX, mouseY, i+pts.size(), i+pts.size());
pts.add(newP);
}
}
for (int i=0; i<pts.size(); i++) {
Particle p = pts.get(i);
p.update();
p.display();
}
for (int i=pts.size()-1; i>-1; i--) {
Particle p = pts.get(i);
if (p.dead) {
pts.remove(i);
}
}
}
void mousePressed() {
onPressed = true;
if (showInstruction) {
background(255);
showInstruction = false;
}
}
void mouseReleased() {
onPressed = false;
}
void keyPressed() {
if (key == 'c') {
for (int i=pts.size()-1; i>-1; i--) {
Particle p = pts.get(i);
pts.remove(i);
}
background(255);
}
}
class Particle{
PVector loc, vel, acc;
int lifeSpan, passedLife;
boolean dead;
float alpha, weight, weightRange, decay, xOffset, yOffset;
color c;
Particle(float x, float y, float xOffset, float yOffset){
loc = new PVector(x,y);
float randDegrees = random(360);
vel = new PVector(cos(radians(randDegrees)), sin(radians(randDegrees)));
vel.mult(random(5));
acc = new PVector(0,0);
lifeSpan = int(random(30, 90));
decay = random(0.75, 0.9);
c = color(random(255),random(255),255);
weightRange = random(3,50);
this.xOffset = xOffset;
this.yOffset = yOffset;
}
void update(){
if(passedLife>=lifeSpan){
dead = true;
}else{
passedLife++;
}
alpha = float(lifeSpan-passedLife)/lifeSpan * 70+50;
weight = float(lifeSpan-passedLife)/lifeSpan * weightRange;
acc.set(0,0);
float rn = (noise((loc.x+frameCount+xOffset)*0.01, (loc.y+frameCount+yOffset)*0.01)-0.5)*4*PI;
float mag = noise((loc.y+frameCount)*0.01, (loc.x+frameCount)*0.01);
PVector dir = new PVector(cos(rn),sin(rn));
acc.add(dir);
acc.mult(mag);
float randDegrees = random(360);
PVector randV = new PVector(cos(radians(randDegrees)), sin(radians(randDegrees)));
randV.mult(0.5);
acc.add(randV);
vel.add(acc);
vel.mult(decay);
vel.limit(3);
loc.add(vel);
}
void display(){
strokeWeight(weight+1.5);
stroke(0, alpha);
point(loc.x, loc.y);
strokeWeight(weight);
stroke(c);
point(loc.x, loc.y);
}
}
See More Shortcuts