This website uses Cookies. Click Accept to agree to our website's cookie use as described in our Privacy Policy. Click Preferences to customize your cookie settings.
Thanks! In my excitement to post, it looks like I forgot to write comments!
This program is using a JSL list named stack (which is misnamed, but ignore that.) Stack holds a list of active roads. Each element on the stack is a list of
the last row,col location of a pixel in the road
the last angle the road was headed
the delta angle the road turns as each pixel is drawn
There is also a veclen, which I believe is always .7, close to .707.
The driver loop, near the end, calls the doodle function N times with indexes to the N front-most items in stack. doodle draws one pixel for each of those roads, so it looks like N roads are built at the same time. Look at the code at the front of doodle and you'll see the code that implements the turn:
Line 1 grabs the state of the nth (istack) road. Line 2 computes a row and col for the next pixel AND a new angle (for next time.) Line 3 is testing if the row,col is still on the screen, and if so, line 4 updates the info for the road back into the stack.
If you are still following in the source, you'll see a black pixel set at row,col, or if off screen, you'll see the stack element removed...which will make a new road, further down the stack, start drawing next time.
You'll also see code that spawns new roads at right angles (by adding +/- pi/2 to the current angle), and code that sprays the lightly colored sand at right angles as well.
The code that spawns a new road
// new doodle at right angle
stack[N Items( stack ) + 1] = Eval List({newrow, newcol, angle + If( Random Integer( 0, 1 ), Pi() / 2, -Pi() / 2 ), Random Normal( 0, .0001 ), .7});
is the answer to your question: random normal is generating a delta angle that is very close to zero, most of the time. Make the .0001 a shade larger and more of the lines will have more curvature.
Thanks for puzzling over the code, and ask again if the missing comments are a problem.