Sorry, I did not finish the code. I dont know how to write. And in this question, I can not move those constants, and also I cant create any global variables
Just for me to get it correct I searched for code containing final variables in draw(); and I found a very nice code from @GoToLoophere at the bottom of the post. But I really think he used it there solely out of ease.
In an article about âThe Final Word On the final Keywordâ here it states:
Because I am a student, and this is a question from my instructor, she said that I can not change those constants. I just learned a new thing which called user defined function. My instructor just want us to practice the new thing.
Iâve got an old example on the previous forum where the anonymous instantiated classTimerTask access the final parameter sec from the function createScheduleTimer():
Thanks for your help. I have modified a little code, but the result is not the same as what I want
void setup() {
size(800, 800);
noStroke(); //No black outline around the circles
}
void draw() {
final int CIRCLE_SIZE = 20;
final int NUM_CIRCLES = 7;
final float ANGLE = -PI/4;
background(0);
lineOfCircles(mouseX, mouseY, ANGLE, CIRCLE_SIZE, NUM_CIRCLES);
}
void lineOfCircles(float xStart, float yStart, float angle, float size, int numCirc) {
for (int i=0; i<numCirc; i++) {
float x1=xAtAngle(xStart+i*size, 13, angle);
float y1=yAtAngle(yStart-i*size, 13, angle);
ellipse(x1, y1, size, size);
}
}
//void drawCircle(float x, float y, float d, float theta, float diam) {
//}
float xAtAngle(float xFrom, float dist, float angle) {
return xFrom+cos(angle)*dist;
}
float yAtAngle(float yFrom, float dist, float angle) {
return yFrom+sin(angle)*dist;
}
In your code, the first circleâs center should stay with mouseâs center. I should set 13 to 0, then the first circleâs center gonna stay with mouseâs center. But I dont think it is correct. Also if I want to use another function which call void drawCircle, you commented it. How can I use it? I mean I will draw all the circles in void drawCircle function, and call this function from void lineOfCircles function.