Created
July 26, 2018 05:38
-
-
Save mgamba/52ed8bcb2ee37e97d9d688b76e86cbbb to your computer and use it in GitHub Desktop.
glowing triangle spinning around circle for Processing P3
This file contains hidden or 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
//PGraphics pg; | |
class Triangle { | |
private float angle = 0; | |
Triangle() { | |
} | |
void rotate() { | |
this.angle += 1; | |
if (this.angle >= 360) { | |
this.angle = 0; | |
} | |
} | |
void display() { | |
stroke(255); | |
noFill(); | |
float radius = 50; | |
float xCenter = 55; | |
float yCenter = 55; | |
float x0 = xCenter + cos(radians(this.angle))*(radius); | |
float y0 = yCenter + sin(radians(this.angle))*(radius); | |
float x1 = xCenter + cos(radians(this.angle+120))*(radius); | |
float y1 = yCenter + sin(radians(this.angle+120))*(radius); | |
float x2 = xCenter + cos(radians(this.angle+240))*(radius); | |
float y2 = yCenter + sin(radians(this.angle+240))*(radius); | |
strokeWeight(6); | |
line(x0, y0, x1, y1); | |
line(x1, y1, x2, y2); | |
line(x2, y2, x0, y0); | |
ellipse(xCenter, yCenter, radius / 2, radius / 2); | |
filter(BLUR, 7); | |
strokeWeight(4); | |
line(x0, y0, x1, y1); | |
line(x1, y1, x2, y2); | |
line(x2, y2, x0, y0); | |
ellipse(xCenter, yCenter, radius / 2, radius / 2); | |
filter(BLUR, 3); | |
strokeWeight(2); | |
line(x0, y0, x1, y1); | |
line(x1, y1, x2, y2); | |
line(x2, y2, x0, y0); | |
ellipse(xCenter, yCenter, radius / 2, radius / 2); | |
} | |
} | |
Triangle triangle; | |
void setup() | |
{ | |
size(110, 110, P3D); | |
triangle = new Triangle(); | |
} | |
void draw() | |
{ | |
background(0); | |
triangle.rotate(); | |
triangle.display(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment