not sure, but that's my analyze
You're using the same variable, random1, 2, 3
to draw two different line.
I do not know how stroke()
should draw your line, but since you're changing random1, 2, 3
to then reuse them into the second stroke()
method you'll change the reference of the first stroke, which may result on draying twice the same line.
+ you seems to be declaring this variable outside the for loop.
What may be a quick fix could be the following
Edit: you can use either the first or second randomNumber()
function below taken from this question
/**
* Returns a random number between min (inclusive) and max (exclusive)
*/
function randomNumber(min, max) {
return Math.random() * (max - min) + min;
}
/**
* Returns a random integer between min (inclusive) and max (inclusive).
* The value is no lower than min (or the next integer greater than min
* if min isn't an integer) and no greater than max (or the next integer
* lower than max if max isn't an integer).
* Using Math.round() will give you a non-uniform distribution!
*/
function randomNumber(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
for (var i = 0; i < 11; i++) {
stroke(rgb(randomNumber(0, 255), randomNumber(0, 255), randomNumber(0, 255)));
liftUp();
backward(100);
turnLeft(45);
forward(200);
stroke(rgb(randomNumber(0, 255), randomNumber(0, 255), randomNumber(0, 255)));
liftDown();
backward(150);
turnRight(45);
forward(150);
turnRight(135);
forward(150);
}
Didn't test it, but this is the only logical way of solving your problem.