Skip navigation
Currently Being Moderated

[CS4/JS] Mazes, Mazes, *Everywhere*!

Sep 16, 2010 5:32 PM

A sample of what's possible when you combine Javascript with InDesign: a Maze generator.

 

I set out to find a Javascript that created mazes for HTML websites, but, while there are tons of those, they were not as easily converted to InDesign as I hoped. So I wrote one of my own using a description of Maze Generators on http://www.astrolog.org/labyrnth/maze.htm, but the code is entirely my own.

 

Screen shot 2010-09-17 at 2.10.18 AM.png

 

Not yet satisfied, I changed it from the usual rectangular shape to fill any object you care to draw! With this one constraint: curved edges are converted rather bluntly into straight lines. It won't work on a circle, for example (this will be 'straightened' into a rectangle), but it will work on, for example, a 5 pointed star!

 

Screen shot 2010-09-17 at 2.16.43 AM.png

Each small rectangle is about 5 mm wide and high, so make sure your object is large enough.

 

Download the code from my website: http://www.jongware.com/binaries/mazes-everywhere.zip

 

Start it in a blank document with no selection to get a crude "width/height" dialog, or draw a rectangle and have it selected to fill it with 5 mm wide maze paths. If you're feeling experimentally, draw polygons, or tack together a few shapes and combine their paths into one.

And if you're feeling really courageous, experiment with how to get 'holes' in your maze!

 

This one started out as Arial Black text, tracked to join the letters together; then it took some tries to get the "winding" of the holes right. (Techno-babble: There seems to be a bug in my code that doesn't always seems to return the correct winding order.)

 

Screen shot 2010-09-17 at 2.09.33 AM.png

 

Have fun!

 
Replies
  • Currently Being Moderated
    Sep 16, 2010 5:49 PM   in reply to [Jongware]

    You obviously have too much time on your hands but too COOL!!

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 16, 2010 7:52 PM   in reply to [Jongware]

    Jongware,

    Great script!

    I couldn't make it work with text like you did with the letters in your name. I don't do fancy scripting like Jongware, but for anyone else wanting to put the maze into text, I would suggest:

    1. Create a maze using Jongware's script.
    2. Group the maze shapes.
    3. Type your text and convert to outlines.
    4. Copy or cut the grouped maze.
    5. Select type and paste into. (Maze must be at least as large as the text.)
     
    |
    Mark as:
  • Currently Being Moderated
    Sep 16, 2010 11:16 PM   in reply to [Jongware]

     

    I'm shocked! Great work!

     

    --

    tomaxxi

    http://indisnip.wordpress.com/

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 17, 2010 1:49 AM   in reply to [Jongware]

    Just awesome!

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 17, 2010 2:07 AM   in reply to [Jongware]

    It worked on Win7/CS4 just fine, with complex paths also!

     

    myMaze.jpg

     

    --

    tomaxxi

    http://indisnip.wordpress.com/

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 17, 2010 2:11 AM   in reply to [Jongware]

    [Jongware] wrote:

     

    [...] It seems Javascript on Windows is not as solid as on the Mac -- I've had a few sudden freezes and InDesign crashes [...]

     

    Yeah! I know what you're talking about. Specially with scripts that use a huge amount of pathpoint calculations/transformations. I'm still looking for a solution to monitor InDesign JS memory leaks experienced on Win64 platforms...

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 17, 2010 6:39 AM   in reply to [Jongware]

    What do you mean by winding order?

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 17, 2010 7:40 AM   in reply to [Jongware]

    Have you tried going from a filled black square and cutting out the boxes (making them white) during your depth-first search? That way the outline of your text will be sharper (and the maze will be harder to solve, since all paths are connected.

     

    Edit: My bad. I thought the white part was the path in the maze and the black was the walls, but it seems like it's the other way around.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 17, 2010 7:41 AM   in reply to [Jongware]

    Awesome! That's exactly what I meant

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 17, 2010 10:15 AM   in reply to [Jongware]

    Jongware,

    Thanks for giving details of the method you used to create the maze in your name. That is a better process than I used.

    However, when I ran the script I got the following:

    Untitled-1.gif

    I used the script in CS4 yesterday; today I used it in CS5. Would that make a difference?

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 17, 2010 12:11 PM   in reply to [Jongware]

    Does versioning work in CS5 like it used to in CS4 and earlier?

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 17, 2010 2:05 PM   in reply to [Jongware]

    Wow, this is awesome Jong.  Now that you've done spirographs and mazes, what's next?  Checkers?

     

    /dan

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 19, 2010 12:11 AM   in reply to [Jongware]

    WAY too much time on your hands...

     

    Excellent work (or rather play...)!

     

    Very cool stuff.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 19, 2010 2:07 AM   in reply to [Jongware]

    Great stuff, Theun!

     

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 30, 2010 5:28 PM   in reply to [Jongware]

    Hello,

    we are publishing a childrens magazine. This is really really useful for us. Thank you so much.

    best regards,

    Stephan

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 31, 2010 11:09 PM   in reply to [Jongware]

    Thanks, Jongware. This one works in InDesign CS5. Your scripts are delightful!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)