Skip to content

Instantly share code, notes, and snippets.

@jkwok91
Created March 15, 2014 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkwok91/46cb0b921b113d76c365 to your computer and use it in GitHub Desktop.
Save jkwok91/46cb0b921b113d76c365 to your computer and use it in GitHub Desktop.
WOW needs refactoring lol
/*
test for things that draw outward
generate 4 random points, and draw lines from center to those points
with each frame drawing another pixel so that it looks animated
*/
int w = 200;
int h = 200;
int cx = w/2;
int cy = h/2;
Point center = new Point(cx,cy);
Point p1, p2, p3, p4;
ArrayList<Point> line1;
ArrayList<Point> line2;
ArrayList<Point> line3;
ArrayList<Point> line4;
int c1, c2, c3, c4;
color c;
void setup() {
size(w,h);
background(0);
frameRate(120);
pickPts();
c = color(255);
}
void pickPts() {
c1 = c2 = c3 = c4 = 0;
Point p1 = new Point((int)(Math.random()*(width)),(int)(Math.random()*(height)));
Point p2 = new Point((int)(Math.random()*(width)),(int)(Math.random()*(height)));
Point p3 = new Point((int)(Math.random()*(width)),(int)(Math.random()*(height)));
Point p4 = new Point((int)(Math.random()*(width)),(int)(Math.random()*(height)));
line1 = makeLine(center, p1);
line2 = makeLine(center, p2);
line3 = makeLine(center, p3);
line4 = makeLine(center, p4);
}
void draw() {
if (c1 < line1.size() && c2 < line2.size() && c3 < line3.size() && c4 < line4.size()) {
loadPixels();
if (c1 < line1.size()) {
Point p = line1.get(c1);
pixels[p.ycor*width+p.xcor] = c;
c1++;
}
if (c2 < line2.size()) {
Point p = line2.get(c2);
pixels[p.ycor*width+p.xcor] = c;
c2++;
}
if (c3 < line3.size()) {
Point p = line3.get(c3);
pixels[p.ycor*width+p.xcor] = c;
c3++;
}
if (c4 < line4.size()) {
Point p = line4.get(c4);
pixels[p.ycor*width+p.xcor] = c;
c4++;
}
updatePixels();
} else {
c = getColor(c1);
pickPts();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment