Guest User

Transgender/Genderfluid Android Live Wallpaper

a guest
Apr 12th, 2020
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.79 KB | None | 0 0
  1. /*
  2.  * README:
  3.  * Paste all of this code into APDE, and change the export mode to wallpaper before hitting play (Android only).
  4.  * Line 24: Changes the mode between trans/genderfluid (sorry I didn't add other ones! If anybody really wants it I can add it!)
  5.  * Line 27: Changes the amount of stars on the screen
  6.  */
  7.  
  8. ArrayList<Twinkle> twinkles = new ArrayList<Twinkle>();
  9. Star[] stars;
  10.  
  11. color[] colors;
  12.  
  13. //***
  14. void setup() {
  15.   fullScreen();
  16.  
  17.   //genderfluid
  18.   color[] genderfluid = { color(255, 118, 163), color(255, 255, 255), color(191, 17, 215), color(0, 0, 0), color(48, 60, 190) };
  19.   //trans
  20.   color[] transgender = { color(91, 207, 250), color(245, 171, 185), color(255, 255, 255), color(245, 171, 185), color(91, 207, 250) };
  21.  
  22.   //Design?
  23.   colors = transgender;
  24.  
  25.   //Amount of Stars?
  26.   int starCount = 1000;
  27.  
  28.   stars = new Star[starCount];
  29.   for (int i = 0; i < starCount; i++) {
  30.     stars[i] = new Star();
  31.   }
  32. }
  33.  
  34. //***
  35. void draw() {
  36.   background(0, 0, 0);
  37.  
  38.   for (Star s : stars) {
  39.     s.display();
  40.   }
  41.  
  42.   println(twinkles.size(), frameRate);
  43.   for (Twinkle t : twinkles) {
  44.     t.update();
  45.     t.display();
  46.   }
  47. }
  48.  
  49. //***
  50. void mouseDragged() {
  51.   for (int i = 0; i < 3; i++) twinkles.add(new Twinkle(mouseX, mouseY)); //add twinkles when dragging screen
  52. }
  53.  
  54. //Color Stuff
  55. public color getColor(float y) {
  56.   float random = 20;
  57.   y = random(y-random, y+random); //randomize a bit
  58.   y = constrain(y, 0, height-1); //keep value inside of screen
  59.   y /= height; //put between 0 and 1
  60.   y *= colors.length-1; //make valid for array
  61.  
  62.   color c = lerpColor(colors[int(y)], colors[int(y+1)], y%1); //fade between colors
  63.   return c;
  64. }
  65.  
  66. class Twinkle {
  67.   PVector pos;
  68.   PVector vel = new PVector();
  69.  
  70.   color col;
  71.   float size;
  72.   float alpha = 0;
  73.  
  74.   float startSpeed = 2;
  75.  
  76.   Twinkle(float x, float y) {
  77.     pos = new PVector(x, y);
  78.  
  79.     //randomness
  80.     //movement
  81.     float randRad = 200;
  82.     PVector rand = PVector.random2D();
  83.     pos.add(rand.copy().mult(randRad));
  84.     vel.add(rand.mult(startSpeed));
  85.     //appearance
  86.     col = getColor(pos.y);
  87.     size = random(3, 5);
  88.   }
  89.  
  90.   void update() {
  91.     pos.add(vel);
  92.     vel.mult(0.95);
  93.  
  94.     float sX = map(vel.mag(), startSpeed, 0, -PI/2, 3*PI/2);
  95.     float s = ((sin(sX)+1)/2)*255;
  96.     alpha = s;
  97.   }
  98.  
  99.   void display() {
  100.     ellipseMode(CENTER);
  101.     noStroke();
  102.     fill(red(col), green(col), blue(col), alpha);
  103.     ellipse(pos.x, pos.y, size, size);
  104.   }
  105. }
  106.  
  107. class Star {
  108.   PVector pos = new PVector();
  109.  
  110.   color col;
  111.   float size;
  112.  
  113.   Star() {
  114.     pos.set(random(width), random(height));
  115.  
  116.     col = getColor(pos.y);
  117.     size = random(5, 8);
  118.   }
  119.  
  120.   void update() {
  121.   }
  122.  
  123.   void display() {
  124.     ellipseMode(CENTER);
  125.     noStroke();
  126.     fill(col);
  127.     ellipse(pos.x, pos.y, size, size);
  128.   }
  129. }
Add Comment
Please, Sign In to add comment