Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * README:
- * Paste all of this code into APDE, and change the export mode to wallpaper before hitting play (Android only).
- * Line 24: Changes the mode between trans/genderfluid (sorry I didn't add other ones! If anybody really wants it I can add it!)
- * Line 27: Changes the amount of stars on the screen
- */
- ArrayList<Twinkle> twinkles = new ArrayList<Twinkle>();
- Star[] stars;
- color[] colors;
- //***
- void setup() {
- fullScreen();
- //genderfluid
- color[] genderfluid = { color(255, 118, 163), color(255, 255, 255), color(191, 17, 215), color(0, 0, 0), color(48, 60, 190) };
- //trans
- color[] transgender = { color(91, 207, 250), color(245, 171, 185), color(255, 255, 255), color(245, 171, 185), color(91, 207, 250) };
- //Design?
- colors = transgender;
- //Amount of Stars?
- int starCount = 1000;
- stars = new Star[starCount];
- for (int i = 0; i < starCount; i++) {
- stars[i] = new Star();
- }
- }
- //***
- void draw() {
- background(0, 0, 0);
- for (Star s : stars) {
- s.display();
- }
- println(twinkles.size(), frameRate);
- for (Twinkle t : twinkles) {
- t.update();
- t.display();
- }
- }
- //***
- void mouseDragged() {
- for (int i = 0; i < 3; i++) twinkles.add(new Twinkle(mouseX, mouseY)); //add twinkles when dragging screen
- }
- //Color Stuff
- public color getColor(float y) {
- float random = 20;
- y = random(y-random, y+random); //randomize a bit
- y = constrain(y, 0, height-1); //keep value inside of screen
- y /= height; //put between 0 and 1
- y *= colors.length-1; //make valid for array
- color c = lerpColor(colors[int(y)], colors[int(y+1)], y%1); //fade between colors
- return c;
- }
- class Twinkle {
- PVector pos;
- PVector vel = new PVector();
- color col;
- float size;
- float alpha = 0;
- float startSpeed = 2;
- Twinkle(float x, float y) {
- pos = new PVector(x, y);
- //randomness
- //movement
- float randRad = 200;
- PVector rand = PVector.random2D();
- pos.add(rand.copy().mult(randRad));
- vel.add(rand.mult(startSpeed));
- //appearance
- col = getColor(pos.y);
- size = random(3, 5);
- }
- void update() {
- pos.add(vel);
- vel.mult(0.95);
- float sX = map(vel.mag(), startSpeed, 0, -PI/2, 3*PI/2);
- float s = ((sin(sX)+1)/2)*255;
- alpha = s;
- }
- void display() {
- ellipseMode(CENTER);
- noStroke();
- fill(red(col), green(col), blue(col), alpha);
- ellipse(pos.x, pos.y, size, size);
- }
- }
- class Star {
- PVector pos = new PVector();
- color col;
- float size;
- Star() {
- pos.set(random(width), random(height));
- col = getColor(pos.y);
- size = random(5, 8);
- }
- void update() {
- }
- void display() {
- ellipseMode(CENTER);
- noStroke();
- fill(col);
- ellipse(pos.x, pos.y, size, size);
- }
- }
Add Comment
Please, Sign In to add comment