xxxxxxxxxx
/* ARTIST's name : ANTHONY LAM
Instructions foe the ART:
1. The background consists of a yellow to orange gradient background.
2. After this, image there is a split in the middle of the canvas.
3. For the left side ,there are broad lines that eventually leads to a single point at the top middle of the image.
4. For the right side is the same idea, but the lines lead to a single point at the bottom of the image.
5. There is a circle that goes around within the canvas, that changes color from black when in the gradient background, to orange when in the broad lines.
6. The speed of the circle is slow, but not insanely slow.
7. The circle also grows and shrinks in size.
*/
myCircle c;
void setup()
{
size(800, 500);
c = new myCircle();//Class declaration. Objet oriented programming.
}
void draw()
{
blendMode(BLEND);
//Gradient Background
color b1 = color(255, 255, 0);//Yellow color.
color b2 = color(255, 97, 3);//Orange color.
for (int i=0;i<=height;i++)//From bottom of the canvas to the top.
{
float temp = map(i, 0, height, 0, 1);// "map" is a predefine function, if you give two ranges and declare the value in 1st range, "map" will give you it's value in the second range.
//"map" calculates the value between two given color values. For figuring out different shades.
color c = lerpColor(b1, b2, temp);// Lerp means linear interpolation. For two colors interoplation, it finds the color between two colors above. The calculation is done by using map.
//Lerp calculates the interpolation between 1st and 2nd color. Returns the color.
stroke(c);
line(0, i, width, i);//(x1, y1, x2, y2)
}
//Broad Lines
stroke(0);
strokeWeight(25);//For loop for multiple lines. Lines coming from horizontal parts of the screen.
for(float ly=0;ly<=height;ly+=100)
//"ly" y cordinate of the line.
{
line(0,ly,width/2,0);//End point stays the same for every line. But y coodinate changes.
line(width,ly,width/2,height);
}
float basex=width/2;
for(float lx=0;lx<=width/2;lx+=100)//Lines coming from vertical part of the screen.
//"lx" x coordinate of the line.
{
line(basex-lx,height,width/2,0);//From center point left side.
line(basex+lx,0,width/2,height);//From center point right side.
}
//Functions of the class
c.drawCircle();//Draws circle.
c.changeX();//Changes the X.
c.changeY();//Changes the Y.
c.changeSize();//Changes size.
}
class myCircle
{
float x=50;//x coordinate.
float xc=3;//xc is change in x coordinate.
float y=50;// y coordinate.
float yc=3;//yc is change in y coordinate.
float s=50;// s is size (diameter of the circle).
float sUpperCap = 150;//The maximum size of the circle.
float sLowerCap = 50;//The minimum size the circle can take.
float sc=1;//Change in size.
void drawCircle()
{
blendMode(SUBTRACT);
noStroke();
fill(255,97,3);
ellipse(x,y,s,s);
}
void changeX()//Consider x direction. Only horizontal movement.
//Should change direction when in contact with the edge.
{
if(x > width-s/2)//s/2 radius of the circle.
x = width-s/2;
else if(x < 0+s/2)//Checking if the center of the circle is s/2 away from the edge.
x = 0+s/2;
x = x+xc;
if(x >= width-s/2)
xc= xc * -1;//Change in the postion of x.
else if(x <= 0+s/2)
xc= xc * -1;
}
void changeY()
{
if(y > height-s/2)
y = height-s/2;
else if(y < 0+s/2)
y = 0+s/2;
y = y+yc;
if(y >= height - s/2)
yc= yc * -1;
else if(y <= 0+s/2)//0+s/2 because size of the circle is constantly changing.
yc= yc * -1;
}
void changeSize()
{
s = s+sc;//For the circle to grow bigger.
if(s >= sUpperCap)//As soon as it reaches the maximum size of the circle.
sc = sc * -1;//Then the circle should reduce size as sc becomes negative.
else if(s <= sLowerCap)//Again grow back after reaching minimum size.
sc = sc * -1;
}
}