Advertisement
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).
- * When your device restarts/shuts down the background may freeze. simply go into APDE and hit play again
- * Line 69: Changes the time a flag will stay on screen
- * line 71: Changes the amount of time the transition between two flags takes
- * line 127: the amount of stars that go trough the screen
- * Lines 112-121: What flags will be shown. delete the lines with the flags you don't want
- * lines 131-137 : The sizes of the stars and the twinkles
- * stars are what goes trough the screen to recolor it
- * twinkles are what is created when you tap the screen
- * to make the background more subtle delete the */ /* on line 159, but keep background(0, 0, 0);
- * to make the twinkles not appear, remove line 282
- */
- ArrayList<Twinkle> twinkles;
- Star[] stars;
- color[] colors;
- ArrayList<colorArr> totalColors;
- int twinkleDeletionTimer;
- int colorIndex;
- int colorChangeTimer;
- int colorChangeTimerConst;
- int colorMixTimerConst;
- int minimumStarSize;
- int maximumStarSize;
- int minimumTwinkleSize;
- int maximumTwinkleSize;
- /*****/
- void setup() {
- fullScreen();
- twinkles = new ArrayList<Twinkle>();
- twinkleDeletionTimer=0;
- colorIndex = 0;
- colorChangeTimer = 0;
- colorChangeTimerConst = 2000; /*time that a flag will stay on the screen*/
- colorMixTimerConst = 200; /*time that the transition between 2 flags will happen*/
- /*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) };
- /* bi*/
- color[] bi = { color(214, 2, 112), color(214, 2, 112), color(155, 79, 151), color(0, 56, 167), color(0, 56, 167) };
- /*lesbian*/
- color[] lesbian = { color(213, 45, 0), color(255, 154, 86), color(255, 255, 255), color(211, 98, 164), color(163, 2, 98) };
- /*LGBT*/
- color[] ogLGBT = { color(254, 0, 36), color(255, 123, 0), color(255, 240, 0), color(0, 98, 166), color(132, 0, 148) };
- /*gay*/
- color[] gay = { color(4, 144, 109), color(36, 206, 169), color(255, 255, 255), color(77, 75, 202), color(59, 26, 117) };
- /*aro*/
- color[] aro = { color(61, 165, 66), color(167, 211, 121), color(255, 255, 255), color(169, 169, 169), color(0, 0, 0) };
- /*ace*/
- color[] ace = { color(0, 0, 0), color(169, 169, 169), color(255, 255, 255), color(208, 121, 211), color(126, 0, 126) };
- /*enby*/
- color[] enby = { color(255, 244, 51), color(255, 255, 255), color(155, 89, 208), color(45, 45, 45), color(45, 45, 45) };
- /*Design?*/
- totalColors = new ArrayList<colorArr>();
- totalColors.add(new colorArr(transgender));
- totalColors.add(new colorArr(genderfluid));
- totalColors.add(new colorArr(bi));
- totalColors.add(new colorArr(lesbian));
- totalColors.add(new colorArr(ogLGBT));
- totalColors.add(new colorArr(gay));
- totalColors.add(new colorArr(aro));
- totalColors.add(new colorArr(ace));
- totalColors.add(new colorArr(enby));
- colors = totalColors.get(0).getArr();
- /*Amount of Stars?*/
- int starCount = 1000;
- /*Size of Stars and Twinkles*/
- minimumStarSize = 5;
- maximumStarSize = 8;
- minimumTwinkleSize = 3;
- maximumTwinkleSize = 5;
- 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.update();
- s.display();
- }
- /*println(twinkles.size(), frameRate);*/
- for (Twinkle t : twinkles) {
- t.update();
- t.display();
- }
- if(colorChangeTimer < colorChangeTimerConst){
- colorChangeTimer+=1;
- }else if(colorChangeTimer > (colorChangeTimerConst + colorMixTimerConst)){
- colorChangeTimer = 0;
- colorIndex = (colorIndex+1) % totalColors.size();
- colors = totalColors.get(colorIndex).getArr();
- }else{
- colorChangeTimer+=1;
- color[] left = totalColors.get(colorIndex).getArr();
- color[] right = totalColors.get((colorIndex+1)%(totalColors.size())).getArr();
- float y = colorChangeTimer - colorChangeTimerConst;
- y /= colorMixTimerConst;
- y = constrain(y, 0.0, 1.0);
- color[] tempColors = {
- lerpColor(left[0], right[0], y),
- lerpColor(left[1], right[1], y),
- lerpColor(left[2], right[2], y),
- lerpColor(left[3], right[3], y),
- lerpColor(left[4], right[4], y),
- };
- colors = tempColors;
- }
- if(twinkleDeletionTimer>60){ /*once every 60 ticks, remove the dead twinkles.*/
- int size=twinkles.size();
- boolean move=true;
- int i;
- for(i=0 ; ((i<size)&&move);++i){
- Twinkle t1=twinkles.get(i);
- Twinkle t2=twinkles.get(size-1-i);
- if(!t1.isDead()){
- move=false;
- i=size-1-i;
- }
- if(t2.isDead()){
- i=i-1;
- move=false;
- }
- if(move){
- twinkles.set(i,t2); /*move a living twinkle to the front of the array from the back*/
- }
- }
- for(int j=size-1;j>i;j--){
- twinkles.remove(j); /*remove all the dead twinkles that are now at the back*/
- }
- twinkleDeletionTimer=0;
- }else{
- twinkleDeletionTimer+=1;
- }
- }
- /******/
- 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 fixed_rand) {
- float gradient = 40;
- y += (fixed_rand-0.5)*gradient; /*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*/
- int yi=int(y);
- color c = lerpColor(colors[yi], colors[yi+1], y%1); /*fade between colors*/
- return c;
- }
- /*normal Tangent*/
- public PVector nTangent(PVector center, PVector point){
- PVector tangent=new PVector(center.y-point.y,point.x-center.x);
- return tangent.normalize();
- }
- /*hard constrain*/
- public float hardConstrain(float num,float min, float max){
- float res=num-min;
- if(res<0){res=max-min; }
- else if(res>(max-min)){res=0; }
- return (res+min);
- }
- /*distance*/
- public float distance(PVector p1, PVector p2){
- PVector dist= p1.copy();
- dist.sub(p2);
- return dist.mag();
- }
- class Twinkle {
- PVector pos;
- PVector vel = new PVector();
- color col;
- float size;
- float alpha = 0;
- float startSpeed = 6;
- Twinkle(float x, float y) {
- pos = new PVector(x, y);
- /*randomness*/
- /*movement*/
- float randRad = 20;
- PVector rand = PVector.random2D();
- pos.add(rand.copy().mult(randRad));
- vel.add(rand.mult(startSpeed*random(1.0f)));
- /*appearance*/
- col = getColor(pos.y,random(1.0f));
- size = random(minimumTwinkleSize, maximumTwinkleSize);
- }
- 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);
- }
- boolean isDead(){
- return (vel.mag()<0.01);
- }
- }
- public PVector center= new PVector(-150,-150);
- public float b_width=10; /*border width*/
- class Star {
- PVector pos = new PVector();
- float speed;
- float fixed_rand;
- color col;
- float size;
- Star() {
- pos.set(random(-b_width,width+b_width), random(-b_width,height+b_width));
- speed=random(0.125,0.25);
- fixed_rand=random(1.0f);
- col = getColor(pos.y,fixed_rand);
- minimumStarSize = 5;
- maximumStarSize = 7;
- minimumTwinkleSize = 3;
- maximumTwinkleSize = 5;
- size = random(minimumStarSize, maximumStarSize);
- }
- void update() {
- col = getColor(pos.y,fixed_rand);
- PVector tang=nTangent(center,pos);
- tang.mult((float)(speed*Math.log(distance(center,pos))));
- pos.add(tang);
- pos.x=hardConstrain(pos.x,-b_width,width+b_width);
- pos.y=hardConstrain(pos.y,-b_width,height+b_width);
- }
- void display() {
- ellipseMode(CENTER);
- noStroke();
- fill(col);
- ellipse(pos.x, pos.y, size, size);
- }
- }
- class colorArr{
- color[] arr;
- colorArr(color[] temp)
- {
- arr = temp;
- }
- color[] getArr()
- {
- return arr;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement