We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm trying to use mouseClicked to make these arcs move to the top right corner and shrink in size. I momentarily had it, but lost it while trying to add something else haha.
void setup(){
fullScreen();
}
int x1 = 0;
int x2 = 0;
int y1 = 0;
int y2 = 0;
void draw(){
x1 = width/2;
x2 = 600;
y1 = height/2;
y2 = 600;
stroke(0);
strokeWeight(5);
fill(0);
arc(x1, y1, x2, y2, PI, PI*3.25); //Arc1
stroke(0);
strokeWeight(5);
fill(#FFF700);
arc(x1, y1, x2, y2, PI*2.25, PI*2.75);//Arc2
fill(#FF0000);
stroke(0);
strokeWeight(5);
arc(x1, y1, x2, x2, PI*2.75, PI*3.25);//Arc3
stroke(0);
strokeWeight(5);
fill(#FFFFFF);
arc(x1, y1, x2, y2, TWO_PI-PI/4, PI*2.25);//Arc4
}
void mouseclicked(){
x1 = (width/3 + (width/3 + width/4));
y1 = height/3;
x2 = 80;
y2 = 80;
}
Answers
mouseClicked
ok, first, the in-build function is called
mouseClicked()
, notmouseclicked()
. Big "C".Processing is case-sensitive.
Because you had your spelling wrong,
mouseclicked()
was never executed.You can find out those things by guessing, and by putting a
println("here 1");
into the functionmouseclicked()
or the code area you expect to be wrong.background
Also, you might want to use
background(0);
at the beginning ofdraw()
. Because otherwise, you have 2 shapesBest, Chrisir ;-)
Thank you again this was helpful.
Great!
I don't understand why my arc's start in the upper left corner? I am trying to have the arc's form a circle around the middle of the screen. The issue seems to be somewhere in how I declare my variables using width/2...What am I doing wrong?
Line 1 and 2 don't work before setup
Place at end of setup
For an explanation of why global variables assigned to width/height don't work, and why these assignments need to be done in
setup()
aftersize()
is called, see for example this description:I am using the fullScreen(); for my size does this affect declaring my variable in setup? It doesn't seem to work. However I have found a way around it so I'm just wondering for the sake of knowing.
I guess fullscreen does internally the same as size
only there width and height are defined
so you can use them only after fullscreen or size
Right -- calling a screen-size-setting function (such as
size()
orfullscreen()
will definewidth
andheight
-- and then you can safely define other variables based on width and height, after they have been set.btw ctrl-t in the processing editor will indent your code nicely.