Created
October 25, 2019 18:18
-
-
Save Erendis42/28b1d5bb18467a5922788b5b5cacec10 to your computer and use it in GitHub Desktop.
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
PFont f; | |
float ox; | |
float oy; | |
int bg = 0; | |
int minRadius = 20; | |
int maxRadius = 200; | |
char[] letters = explode("Hello!"); | |
int numberOfObjects = letters.length; | |
float[] x = new float[numberOfObjects]; | |
float[] y = new float[numberOfObjects]; | |
int[] r = generateRandomIntegers(numberOfObjects, minRadius, maxRadius, true); | |
int[] angle = generateRandomIntegers(numberOfObjects, 0, 360, false); | |
int[] oX; | |
int[] oY; | |
int minOffset = 10; | |
int maxOffset = 100; | |
void setup() { | |
// width, height | |
size(800, 800); | |
f = createFont("whitrabt.ttf", 32, true); | |
frameRate(60); | |
textFont(f, 50); | |
fill(255, 0, 127); | |
ox = width / 2; | |
oy = height / 2; | |
oX = generateRandomIntegers(numberOfObjects, minOffset, maxOffset, true); | |
//oY = generateRandomIntegers(numberOfObjects, minOffset, maxOffset, false); | |
} | |
float i = 0; | |
void draw() { | |
background(bg); | |
for(int j = 0; j < numberOfObjects; j++) { | |
x[j] = (r[j] * sin(angle[j] + i)) + ox; | |
y[j] = (r[j] * cos(angle[j] + i)) + oy; | |
//text(letters[j], x[j] + oX[j], y[j] + oY[j]); | |
text(letters[j], x[j] + oX[j], oy); | |
} | |
if(i == 360) { | |
i = 0; | |
} | |
i+= 0.01; | |
} | |
char[] explode(String s) { // function explode | |
String theString = s; | |
char[] c = new char[theString.length()]; | |
for (int i = 0; i < theString.length(); i++) { | |
c[i] = theString.charAt(i); | |
} | |
return c; | |
} | |
int[] generateRandomIntegers(int n, int minR, int maxR, boolean sort) { | |
int[] randoms = new int[n]; | |
for(int i = 0; i < n; i++) { | |
randoms[i] = int(random(maxR - minR)) + minR; | |
} | |
if(sort) { | |
sort(randoms); | |
} | |
return randoms; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment