“Keith” by Keith Rowell
https://openprocessing.org/sketch/590272
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 arts02 by Keith Rowell
CC Attribution ShareAlike
Keith
Rowell
xxxxxxxxxx
int fc, num = 3000;
ArrayList ballCollection;
//boolean save = false;
float scal, theta;
PGraphics letter;
PFont font;
String l = "KEITH";
void setup() {
background(20);
//size(900, 500);
fullScreen();
FSize = height/2;
letter = createGraphics(width, height);
font = loadFont("Arial-Black-25.vlw");
ballCollection = new ArrayList();
createStuff();
frameRate(24);
}
void draw() {
background(20);
for (int i=0; i<ballCollection.size (); i++) {
Ball mb = (Ball) ballCollection.get(i);
mb.run();
}
//theta += .0523;
theta += .07;
//if (save) {
//if (frameCount%1==0 && frameCount < fc + 30) saveFrame("image-####.gif");
//}
}
void keyPressed() {
if (key != CODED) l = str(key);
l = l.toUpperCase();
createStuff();
}
//void mouseReleased() {
//createStuff();
//fc = frameCount;
//save = true;
//saveFrame("image-###.gif");
//}
void createStuff() {
ballCollection.clear();
letter.beginDraw();
letter.noStroke();
letter.background(255);
letter.fill(0);
letter.textFont(font, FSize);
letter.textAlign(CENTER);
letter.text(l, width/2, height/2+FSize/4);
letter.endDraw();
letter.loadPixels();
for (int i=0; i<num; i++) {
int x = (int)random(width);
int y = (int)random(height);
color c = letter.get(x, y);
int c = letter.pixels[x+y*width];
if (brightness(c)<255) {
PVector org = new PVector(x, y);
float radius = random(5, 10);
PVector loc = new PVector(org.x+radius, org.y);
float offSet = random(TWO_PI);
int dir = 1;
float r = random(1);
if (r>.5) dir =-1;
Ball myBall = new Ball(org, loc, radius, dir, offSet);
ballCollection.add(myBall);
}
}
}
class Ball {
PVector org, loc;
float sz = 2;
float radius, offSet, a;
//int s, dir, countC, d = 20;
int s, dir, countC, d = 35; //distance lines
boolean[] connection = new boolean[num];
Ball(PVector _org, PVector _loc, float _radius, int _dir, float _offSet) {
org = _org;
loc = _loc;
radius = _radius;
dir = _dir;
offSet = _offSet;
}
void run() {
display();
move();
lineBetween();
}
void move() {
loc.x = org.x + sin(theta*dir+offSet)*radius;
loc.y = org.y + cos(theta*dir+offSet)*radius;
}
void lineBetween() {
countC = 1;
for (int i=0; i<ballCollection.size(); i++) {
Ball other = (Ball) ballCollection.get(i);
float distance = loc.dist(other.loc);
if (distance >0 && distance < d) {
a = map(countC,0,10,10,255);
stroke(255, a);
line(loc.x, loc.y, other.loc.x, other.loc.y);
connection[i] = true;
}
else {
connection[i] = false;
}
}
for (int i=0; i<ballCollection.size(); i++) {
if (connection[i]) countC++;
}
}
void display() {
noStroke();
fill(0,255,255);
ellipse(loc.x, loc.y, sz, sz);
}
}
See More Shortcuts