Newbie drawing tool
in
Programming Questions
•
2 years ago
Hello. I was working on this script and I can't seem to find my issue (i am positive there is more then one)
I will post it here. Any feedback is greatly appreciated. When I run this, I don't even get the println ("mouseClicked"); to appear, which baffles me.
--------------------------------------
//Geoff Matheson
//2011
//Credit to Neil Burdick
http://openprocessing.org/visuals/?visualID=19098
int N1 =7; //number 1 set to 7
int N2 =0; //number 2 used to determine when to stop running
int pX; //last mouseX position
int pY; //last mouse Y position
int mX = width/2; //mX is current mouseX position, starts with a mid screen value
int mY = height/2; //mY is current mouseY position, starts with a mid screen value
int difX; //difference between mX and pX
int difY; // difference between mY and pY
int Dist; // distance between mX and pX
int Dstep; // the increment at which the Diameter will increase
int Astep; // the increment and which alpha will decrease
int Alp =100; //current alpha value
int Dia =10; //curent diameter value
void setup() {
size(800,600);
colorMode(HSB,100);
background(10);
noFill();
strokeWeight(5);
smooth();
println("hello world");
}
//when the mouse is clicked reslot the x&y variables. place the current mX and mY values into
//the pX and pY variables and set mX and mY to the values of mouseX and mouseY at the point when
//the user clicked
void mouseClicked() {
println("MouseClicked");
pX = mX;
pY = mY;
mX = mouseX;
mY = mouseY;
//then run Math() and Draw() until N2 is larger then Dstep, at that point run Reset();
if(N2<Dstep) {
Math();
Draw();
} else {
Reset();
}
}
//This function uses the current pX,pY + mX,mY to determine the distance between those two points.
//then Dstep is valued at distance/N1 which gives the number of ring the ellipse will have
//to increase to reach the pX,pY point. Astep is calculated so that those rings will have an even
//gradation
void Math() {
difX = pX-mX;
difY = pY-mY;
Dist = int(sqrt(difX^2 + difY^2));
Dstep = Dist/N1;
Astep = 100/Dstep;
}
//now the rings are drawn. Starting from the point the user clicked rings are drawn with an
//increasing diameter and decreasing alpha. N2 is counted up. When N2 is greated then Dstep
//which (I think) means the rings have reached the pX,pY point the IF statement should trigger
//the reset feature.
void Draw() {
stroke(50,100,100,Alp);
ellipse(mX,mY,Dia,Dia);
Dia=Dia+Dstep;
Alp=Alp-Astep;
N2=N2+1;
}
void Reset() {
Dia = 10;
Alp = 100;
N2=0;
}
---------------------------------
1