We are about to switch to a new forum software. Until then we have removed the registration on this forum.
hello, I am a beginner in coding with processing I'm following Shiffman channel on youtube, great guy!!
I got stuck with the following tutorial 1.4: Vector Math II - The Nature of Code
I wanted to expand the script but didn't succeed I can't normalize the length of the lines
here is the code below what I want to obtain and what I get so far any idea?
void setup() {
size(800,600);
}
void draw(){
background(0);
for(int x = 0; x < width; x = x+20) {
for(int y = 0; y < height; y = y+20) {
stroke(255);
PVector mouse = new PVector(mouseX,mouseY);
PVector loc = new PVector(x,y);
line(x,y-20,mouse.x,mouse.y);
mouse.sub(loc);
mouse.normalize();
mouse.mult(10);
}
}
}
Answers
you normalise AFTER drawing the line.
Thank you Koogs I tried to put the line before as well, the result is still wrong.. any Idea?
Solved!!! small step but great satisfaction! thank you!