Last active
May 21, 2017 16:35
-
-
Save murilopolese/a200d5d18ecc29d9799ebf5771500326 to your computer and use it in GitHub Desktop.
Rodando
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pointsArray = []; | |
var points = []; | |
var maxPoints = 500; | |
function setup() { | |
createCanvas(windowWidth, windowHeight) | |
background(0) | |
stroke(255) | |
for(var i = 0; i < maxPoints; i++){ | |
pointsArray.push([windowWidth/2, windowHeight/2]) | |
points.push( | |
createVector(windowWidth/2, windowHeight/2) | |
) | |
} | |
} | |
function draw() { | |
rotatePoints(); | |
//renderDancingBars() | |
//renderChain() | |
//renderTriangles() | |
renderFadingTriangles() | |
} | |
function addPoint() { | |
points.push(createVector( | |
mouseX-(windowWidth/2), | |
mouseY-(windowHeight/2) | |
)); | |
points.shift(); | |
} | |
function rotatePoints() { | |
points.forEach(function(point, index) { | |
point.rotate(Math.PI/180) | |
}); | |
translate(windowWidth/2,windowHeight/2) | |
} | |
function renderDancingBars() { | |
pointsArray.push([mouseX, mouseY]) | |
pointsArray.shift(); | |
background(0, 10) | |
fill(255); | |
stroke(255); | |
strokeWeight(1); | |
pointsArray.forEach(function(point, index) { | |
if(index==0) { return }; | |
line( | |
point[0], point[1], | |
pointsArray[index-1][0], | |
pointsArray[index-1][0]) | |
}); | |
} | |
function renderChain() { | |
addPoint() | |
background(0) | |
fill(255); | |
stroke(255); | |
strokeWeight(17); | |
points.forEach(function(point, index) { | |
if(index==0) { return; } | |
line( | |
point.x, point.y, | |
points[index-1].x, points[index-1].y | |
); | |
}); | |
} | |
function renderTriangles() { | |
addPoint() | |
background(0) | |
fill(255, 30) | |
noStroke() | |
points.forEach(function(point, index) { | |
if(index==0) { return; } | |
triangle( | |
0, 0, | |
point.x, point.y, | |
points[index-1].x, points[index-1].y | |
); | |
}); | |
} | |
function renderFadingTriangles() { | |
if(mouseIsPressed) { | |
addPoint() | |
} | |
background(0, 10) | |
fill(255, 20) | |
noStroke() | |
points.forEach(function(point, index) { | |
if(index==0) { return; } | |
triangle( | |
0, 0, | |
point.x, point.y, | |
points[index-1].x, points[index-1].y | |
); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ArrayList<PVector> points = new ArrayList(); | |
int l = 2880; | |
void setup() { | |
//size(600, 600); | |
fullScreen(P2D); | |
//fill(0); | |
strokeWeight(5); | |
stroke(0, 100); | |
for(int i = 0; i < l; i++) { | |
points.add(new PVector(0, height/2)); | |
} | |
} | |
void draw() { | |
background(0); | |
//renderBars(); | |
//renderRadialLines(); | |
//renderChain(); | |
//renderTriangle(); | |
renderTriangle2(); | |
//renderDots(); | |
} | |
void renderBars() { | |
PVector p = new PVector(mouseX, mouseY); | |
points.add(p); | |
points.remove(0); | |
stroke(0); | |
for(int i = 0; i < l; i++) { | |
line(20*i, height, points.get(i).x, points.get(i).y); | |
} | |
} | |
void renderRadialLines() { | |
PVector p = new PVector(mouseX-(width/2), mouseY-(height/2)); | |
points.add(p); | |
points.remove(0); | |
for(int i = 0; i < l; i++) { | |
points.get(i).rotate(radians(1)); | |
} | |
translate(width/2, height/2); | |
stroke(0, 100); | |
for(int i = 0; i < l; i++) { | |
line(0, 0, points.get(i).x, points.get(i).y); | |
} | |
} | |
void renderChain() { | |
PVector p = new PVector(mouseX-(width/2), mouseY-(height/2)); | |
points.add(p); | |
points.remove(0); | |
for(int i = 0; i < l; i++) { | |
points.get(i).rotate(radians(1)); | |
} | |
translate(width/2, height/2); | |
stroke(0); | |
for(int i = 1; i < l; i++) { | |
line( | |
points.get(i-1).x, points.get(i-1).y, | |
points.get(i).x, points.get(i).y | |
); | |
} | |
} | |
void renderTriangle() { | |
if(mousePressed) { | |
PVector p = new PVector(mouseX-(width/2), mouseY-(height/2)); | |
points.add(p); | |
points.remove(0); | |
} | |
for(int i = 0; i < l; i++) { | |
points.get(i).rotate(radians(1)); | |
} | |
translate(width/2, height/2); | |
noStroke(); | |
int f = (frameCount/720)%100; | |
colorMode(HSB, 100); | |
fill(color(f, 100, 50, 20)); | |
for(int i = 1; i < l; i++) { | |
fill(color((f+i/10)%100, 100, 100, 10)); | |
triangle( | |
0, 0, | |
points.get(i-1).x, points.get(i-1).y, | |
points.get(i).x, points.get(i).y | |
); | |
} | |
} | |
void renderTriangle2() { | |
if(mousePressed) { | |
PVector p = new PVector(mouseX-(width/2), mouseY-(height/2)); | |
points.add(p); | |
points.remove(0); | |
} | |
for(int i = 0; i < l; i++) { | |
points.get(i).rotate(radians(1)); | |
} | |
translate(width/2, height/2); | |
noStroke(); | |
fill(255,40); | |
for(int i = 1; i < l; i++) { | |
triangle( | |
0, 0, | |
points.get(i-1).x, points.get(i-1).y, | |
points.get(i).x, points.get(i).y | |
); | |
} | |
} | |
void renderDots() { | |
if(mousePressed) { | |
PVector p = new PVector(mouseX-(width/2), mouseY-(height/2)); | |
points.add(p); | |
points.remove(0); | |
} | |
for(int i = 0; i < l; i++) { | |
points.get(i).rotate(radians(1)); | |
} | |
translate(width/2, height/2); | |
noStroke(); | |
int f = (frameCount/720)%100; | |
colorMode(HSB, 100); | |
fill(color(f, 100, 50, 100)); | |
for(int i = 0; i < l; i++) { | |
fill(color((f+i/10)%100, 100, 100, 100)); | |
ellipse( | |
points.get(i).x, points.get(i).y, | |
10, 10 | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment