Last active
January 22, 2017 15:06
-
-
Save AlcaDesign/7ec612e94b19f9a2865a8f1cbcd95573 to your computer and use it in GitHub Desktop.
Mystic Rose
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
PVector[] points; | |
int pointCount = 0; | |
int lastPointCount = 0; | |
void setup() { | |
size(600, 600, P3D); | |
colorMode(HSB); | |
} | |
void draw() { | |
long t = System.nanoTime(); | |
background(0); | |
pushMatrix(); | |
translate(width / 2.0, height / 2.0); | |
scale(0.5, 0.5); | |
rotateZ(cos(frameCount / 60.0) / 2.0); | |
rotateY(frameCount / 100.0); | |
rotateX(sin(frameCount / 120.0) / 4.0); | |
fill(255); | |
stroke(255); | |
pointCount = floor(map(mouseX, 0, width, 2, 300)); | |
if(points == null || pointCount != lastPointCount) { | |
lastPointCount = pointCount; | |
points = new PVector[pointCount]; | |
for(int i = 0; i < pointCount; i++) { | |
float angle = map(i, 0, pointCount, -PI, PI) + HALF_PI; | |
float x = sin(angle); | |
float y = cos(angle); | |
points[i] = new PVector(x * width / 2.0, y * height / 2.0); | |
} | |
} | |
for(int i = 0; i < points.length; i++) { | |
PVector p = points[i]; | |
float z = map(i, 0, points.length, 0, -255); | |
for(int j = i + 1; j < points.length; j++) { | |
PVector p2 = points[j]; | |
if(p == p2) { | |
continue; | |
} | |
stroke(map(j, i + 1, points.length, 0, 255), 255, 255); | |
float z2 = map(j, i + 1, points.length, 0, -255); | |
line(p.x, p.y, z, p2.x, p2.y, z2); | |
} | |
} | |
noFill(); | |
stroke(255); | |
ellipse(0, 0, width, height); | |
noStroke(); | |
fill(255); | |
for(PVector p : points) { | |
ellipse(p.x, p.y, 10, 10); | |
} | |
popMatrix(); | |
text("Milliseconds " + (System.nanoTime() - t) / 1000000.0, 10, 20); | |
text("FPS " + frameRate, 10, 40); | |
text("Points " + pointCount, 10, 60); | |
} |
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
function setup() { | |
createCanvas(600, 600); | |
} | |
function draw() { | |
background(0); | |
translate(width / 2, height / 2); | |
rotate(frameCount / 100); | |
fill(255); | |
stroke(255); | |
let pointCount = floor(map(mouseX, 0, width, 2, 24)); | |
let points = []; | |
for(let i = 0; i < pointCount; i++) { | |
let angle = map(i, 0, pointCount, -PI, PI) + HALF_PI, | |
x = sin(angle); | |
y = cos(angle); | |
points[i] = createVector(x * width / 2.0, y * height / 2.0); | |
} | |
points.forEach((p, i) => { | |
points.forEach((p2, i2) => { | |
if(i === i2) { | |
return; | |
} | |
line(p.x, p.y, p2.x, p2.y); | |
}); | |
}); | |
noFill(); | |
ellipse(0, 0, width, height); | |
noStroke(); | |
fill(255); | |
points.forEach((p, i) => { | |
ellipse(p.x, p.y, 10, 10); | |
}); | |
} |
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
PVector[] points; | |
int pointCount = 0; | |
int lastPointCount = 0; | |
void setup() { | |
size(600, 600); | |
} | |
void draw() { | |
long t = System.nanoTime(); | |
background(0); | |
translate(width / 2.0, height / 2.0); | |
rotate(frameCount / 100.0); | |
fill(255); | |
stroke(255); | |
pointCount = floor(map(mouseX, 0, width, 2, 24)); | |
if(points == null || pointCount != lastPointCount) { | |
lastPointCount = pointCount; | |
points = new PVector[pointCount]; | |
for(int i = 0; i < pointCount; i++) { | |
float angle = map(i, 0, pointCount, -PI, PI) + HALF_PI; | |
float x = sin(angle); | |
float y = cos(angle); | |
points[i] = new PVector(x * width / 2.0, y * height / 2.0); | |
} | |
} | |
for(int i = 0; i < points.length; i++) { | |
PVector p = points[i]; | |
for(int j = i + 1; j < points.length; j++) { | |
PVector p2 = points[j]; | |
if(p == p2) { | |
continue; | |
} | |
line(p.x, p.y, p2.x, p2.y); | |
} | |
} | |
noFill(); | |
ellipse(0, 0, width, height); | |
noStroke(); | |
fill(255); | |
for(PVector p : points) { | |
ellipse(p.x, p.y, 10, 10); | |
} | |
println((System.nanoTime() - t) / 1000000.0, "milliseconds"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment