We are about to switch to a new forum software. Until then we have removed the registration on this forum.
This isn't really a problem i'm having but i'd just like to understand better what's going on. Following the instructions in the book, i embedded two for loops into each other and gave them parametres that point the lines to centre, here's the code:
background(0);
fill(255);
stroke(102);
for (int y = 20; y <= height-20; y += 10) {
for (int x = 20; x <= width-20; x += 10) {
ellipse(x, y, 4, 4);
line(x, y, 240, 60);
Can someone please explain to me what causes the loops to point those lines from the ellipses to the centre specifically? Would just like know, thanks in advance!
Answers
The loops create
x
andy
variables that increment in a grid around the screen.Then the
line(x, y, 240, 60)
line draws a line from eachx
andy
position to the position240,60
which is in the middle of your screen. Try changing the size of your window to see this. Or draw a red ellipse at240,60
. Or change that240,60
tomouseX, mouseY
.Of course, why didn't i think of that before, thanks :)