make alpho go light to dark + vice versa
in
Programming Questions
•
2 years ago
i am trying to make "stars" and i am starting off simple, i made a variable "a", and if its less than 255 it adds 1 to "a", if its greater than 255 it takes away 1. but obviosuly as soon as it takea 1 away it will add 1, again and be stuf at 255. i am not sure how i can workaround this... without an array though.
int[] starx = new int[50];
int[] stary = new int[50];
int a = 0;
int[] stary = new int[50];
int a = 0;
void setup()//open setup
{
smooth();
size(500,500);
//set x, y values
for (int i = 0; i <50; i++)
{
starx[i] = int(random(500));
stary[i] = int(random(500));
}
}//end setup
//
void draw()//open draw
{
smooth();
background(0);
//check the alpha value
if (a < 255)
{
a += 1;
}
if(a<255) ///<<<<<@@@@@@ if it goes below it will add 1 again
{
a -= 1;
}
//draws all the circles
for (int i = 0; i <50; i++)
{
fill(255, a);
ellipse(starx[i],stary[i], 5, 5);
}
}//end draw
{
smooth();
size(500,500);
//set x, y values
for (int i = 0; i <50; i++)
{
starx[i] = int(random(500));
stary[i] = int(random(500));
}
}//end setup
//
void draw()//open draw
{
smooth();
background(0);
//check the alpha value
if (a < 255)
{
a += 1;
}
if(a<255) ///<<<<<@@@@@@ if it goes below it will add 1 again
{
a -= 1;
}
//draws all the circles
for (int i = 0; i <50; i++)
{
fill(255, a);
ellipse(starx[i],stary[i], 5, 5);
}
}//end draw
1