- void setup() {
- size(1000,1000);
- fish(250,250,80,40,23,64,232,1);
- }
- int d;
- if (d=1){
- void fish(int xOffset, int yOffset, float xBody, float yBody, int r, int g, int b, int d) {
- fill(r,g,b);
- ellipse(250 + xOffset,250 + yOffset,xBody,yBody); //body of the fish
- triangle(250 - xBody/2 + xOffset, 250 + yOffset, 250 - xBody/2 - yBody*sqrt(3)/2 + xOffset, 250 - yBody/2 + yOffset, 250 - xBody/2 - yBody*sqrt(3)/2 + xOffset, 250 + yBody/2 + yOffset); //tail of the fish
- fill(255);
- ellipse(250 + (0.25)*(xBody)+ xOffset,250 - (0.25)*(yBody) + yOffset,2*sqrt(xBody*yBody/128),2*sqrt(xBody*yBody/128)); // sclera of the fish (white part of the eye)
- fill(0);
- //ellipse(250 + 0.5*sqrt((xBody+yBody)*(xBody-yBody)) + xOffset,250 - (yBody*yBody/xBody) + sqrt(xBody*yBody/128) + yOffset,2*sqrt(xBody*yBody/pow(2,9)),2*sqrt(xBody*yBody/pow(2,9))); //iris of the fish
- ellipse(250 + (0.25)*(xBody)+ xOffset,250 - (0.25)*(yBody) + yOffset,2*sqrt(xBody*yBody/pow(2,9)),2*sqrt(xBody*yBody/pow(2,9)));
- }
- }
- else if(d=0) {
- void fish(int xOffset, int yOffset, float xBody, float yBody, int r, int g, int b, int d) {
- fill(r,g,b);
- ellipse(250 + xOffset,250 + yOffset,xBody,yBody); //body of the fish
- triangle(250 + xBody/2 + xOffset, 250 + yOffset, 250 + xBody/2 + yBody*sqrt(3)/2 + xOffset, 250 - yBody/2 + yOffset, 250 + xBody/2 + yBody*sqrt(3)/2 + xOffset, 250 + yBody/2 + yOffset); //tail of the fish
- fill(255);
- ellipse(250 - (0.25)*(xBody)+ xOffset,250 - (0.25)*(yBody) + yOffset,2*sqrt(xBody*yBody/128),2*sqrt(xBody*yBody/128)); // sclera of the fish (white part of the eye)
- fill(0);
- //ellipse(250 + 0.5*sqrt((xBody+yBody)*(xBody-yBody)) + xOffset,250 - (yBody*yBody/xBody) + sqrt(xBody*yBody/128) + yOffset,2*sqrt(xBody*yBody/pow(2,9)),2*sqrt(xBody*yBody/pow(2,9))); //iris of the fish
- ellipse(250 - (0.25)*(xBody)+ xOffset,250 - (0.25)*(yBody) + yOffset,2*sqrt(xBody*yBody/pow(2,9)),2*sqrt(xBody*yBody/pow(2,9)));
- }
- }
I've only been programming for 1 week now but i'm not sure if what i'm doing is even possible or if it's more of a language issue that i'm saying.
Basically what i want this to do is the following. I have to draw a fish.
Basically what i want this to do is the following. I have to draw a fish.
um i have a parameter called "d" If I put in a "1", I want the fish to have a "right" orientation. However if i put in a "0", I want the fish to have a "left" orientation. I think I can do this with an if statement
because there's only 2 states right? left and right. I can say if the "d" value is "1" then draw a fish with a right orientation.
(Now this part i'm not sure... ) else if "d" value is "0" then draw a fish with a left orientation.
(Now this part i'm not sure... ) else if "d" value is "0" then draw a fish with a left orientation.
Please help =/
1