Choose Language Hide Translation Bar
Craige_Hales
Staff (Retired)
Wild Road Map

JSL, attached below, modified a bit to make this video.  Best when viewed.  Intended for full screen.  Inspired by Substrate screensaver.


this is a typical picture from the attached JSL.

9435_WildRoad.png

Article Labels

    There are no labels assigned to this post.

Article Tags
6 Comments
Staff

Fantastic!

Staff

Wow Craige, you just turned JMP into a screensaver. What's next -- flying toasters?

Staff (Retired)

Thanks!  I was thinking about a scroller built with transparent bitmaps.

Level III

Great script! I don't see where in the code curved lines are generated. Is there a way to generate more curves?

 

I'm new to JSL.

 

Thank you.

Staff (Retired)

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:

1	{row, col, angle, deltaangle, veclen} = stack[istack];
2	{newrow, newcol, angle} = Eval List( {row + veclen * Sin( angle ), col + veclen * Cos( angle ), angle + deltaangle} );
3	If( newrow >= 1 & newrow <= rowsiz & newcol >= 1 & newcol <= colsiz,
4		stack[istack] = Eval List( {newrow, newcol, angle, deltaangle, veclen} );

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.

Level III

Thank you for the fast reply. I've had lots of fun generating images with different curvature and color combinations.