As mentioned in my last post, I am trying to merge these codes but I keep getting the error; “java.lang.reflect.InvocationTargetException” . From my research I was not able to understand (I am new to coding), could anyone explain the issue and what I need to change for it to run?
Thanks
float angle;
float x, y;
float xStep = 50;
float yStep = 50;
float a, a_;
int num = 328;
void setup() {
size(200, 200);
surface.setLocation(175,0);
strokeWeight (5);
}
void draw () {
background(15, 20, 30);
strokeWeight(xStep);
strokeCap(CORNER);
int n=8;
while (n<num) {
stroke (255-255*cos(radians (a)),255*cos(radians(a)),255-255*sin(radians(a)), 255-255*sin(radians(a)));
line (x, y, x, y+yStep);
x+=xStep;
if (x>width) {
x=xStep/2;
y+=yStep;
}
if (y>=height) {
y=0;
a=0;
}
n++;
a+=a_;
}
a_+=0.1;
}
{
background (300);
translate(width/2, height/2);
for (int i=0; i < 10; i ++){
fill (i*90, 300-i*90, 400-i*800);
scale (0.99);
rotate(radians(angle));
rect (0, 0, 75, 75);
angle+=0.03;
}
}
Hello glv,
Thank you for responding to my post! Though I am still having difficulty finding where to place the code into the void drawing section. After trying to place it as written between every line within void draw, it either becomes a black screen or the background code spins around instead of the foreground. When you say place it into the drawing do you mean keep the code (down below) as written, or rather separate the text, (within the drawing) in order to get it to merge?
Thankyou
{
background (300);
translate(width/2, height/2);
for (int i=0; i < 10; i ++) {
fill (i*90, 300-i*90, 400-i*800);
scale (0.99);
rotate(radians(angle));
rect (0, 0, 75, 75);
angle+=0.03;
}
}