use of int
in
Programming Questions
•
1 year ago
hello everyone,
I'm a newbie here and i recently tried to use integer variables inside of a rect (i'm using CORNERS mode). to my surprise, when i do this nothing happens.
i then used point, tried to put a random value and an int like this
point(x, int);
and then i see a point(x, 0) even if the int's value isn't 0.
hope you can help me.
this is the whole program:
int x1 = width/4 ;
int y1 = height/4 ;
int x2 = width*3/4 ;
int y2 = height*3/4 ;
int x3 = mouseX-width/4 ;
int y3 = mouseY-height/4 ;
int x4 = mouseX+width/4 ;
int y4 = mouseY+height/4 ;
void setup()
{size(500, 500);
stroke(255);
rectMode(CORNERS);
noFill();
}
void draw()
{ background(0);
rect(x1, y1, x2, y2);
line(x1, y1, x3, y3);
line(x1, y2, x3, y4);
line(x2, y1, x4, y3);
line(x2, y2, x4, y4);
rect(x3, y3, x4, y4);
}
thanks for reading.
I'm a newbie here and i recently tried to use integer variables inside of a rect (i'm using CORNERS mode). to my surprise, when i do this nothing happens.
i then used point, tried to put a random value and an int like this
point(x, int);
and then i see a point(x, 0) even if the int's value isn't 0.
hope you can help me.
this is the whole program:
int x1 = width/4 ;
int y1 = height/4 ;
int x2 = width*3/4 ;
int y2 = height*3/4 ;
int x3 = mouseX-width/4 ;
int y3 = mouseY-height/4 ;
int x4 = mouseX+width/4 ;
int y4 = mouseY+height/4 ;
void setup()
{size(500, 500);
stroke(255);
rectMode(CORNERS);
noFill();
}
void draw()
{ background(0);
rect(x1, y1, x2, y2);
line(x1, y1, x3, y3);
line(x1, y2, x3, y4);
line(x2, y1, x4, y3);
line(x2, y2, x4, y4);
rect(x3, y3, x4, y4);
}
thanks for reading.
1