Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: GIMP script: Random cave generator

  1. #1

    Post GIMP script: Random cave generator

    Here's a random cave generator I just wrote with GIMP's script-fu; it's basically a reimplementation of my online cave generator, except instead of using the old-school TSR blue style with a grid, this was designed to be used with RobA's subterranean map prettier script.

    This is only my second attempt at GIMP scripting, and it's only the first draft, so no doubt I've done something stupid somewhere; advice from more experienced scripters is welcome (is there really no floating-point random number generator? No pi?).

    I've attached a map made with my script, followed by the result of scaling it by 200% and applying RobA's script (grid size 15, all other parameters default).

    Installation and use:

    Once you've installed the .scm file in your gimp scripts directory, it's accessible under Xtns / Script-Fu / Utils (if there's a more appropriate place to put it let me know, and let me know how).

    Parameters: image size (the dimensions of the image in pixels), number of random walks (the caves are excavated by drunken dwarves), and length of the walks. Default values should work well enough.

    The code is free -- do with it what you will.

    I hope you enjoy it, and feedback is always welcome.

    Updated: Version 0.3.1 - fixed error with grid toggle
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	step1.png 
Views:	436 
Size:	3.9 KB 
ID:	8260   Click image for larger version. 

Name:	step2.jpg 
Views:	1103 
Size:	193.1 KB 
ID:	8261  
    Attached Files Attached Files
    Last edited by isomage; 12-11-2008 at 03:02 PM. Reason: New version
    My random map generators and GIMP scripts: http://axiscity.hexamon.net/users/isomage/

  2. #2

    Post

    And the first problem appears: it seems to generate the same sequence of caves each time. How does one seed the random number generator randomly in GIMP?

    Edit: Fixed.
    Last edited by isomage; 12-09-2008 at 01:27 PM.
    My random map generators and GIMP scripts: http://axiscity.hexamon.net/users/isomage/

  3. #3
    Guild Journeyer Sagenlicht's Avatar
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    249

    Post

    Hmm sry isomage, I've got some troubles reading script-fu, which makes troubleshooting tough for me. If you give me a python code I'll help ya.
    My Map Challenge Entries

    I use GIMP for all my maps.

    GIMP scripts and plug-ins overview


    Everything I post on this site uses the Creative Common Attribution-Noncommercial-Share Alike license. Only exception to this are any pyhton scripts which use the GPL.

    If you are using any of my posted stuff just use your rep stick on me

    Should you be interested in using anything I posted on commercial purpose drop me a pm.

  4. #4

    Post

    Here's another example, this from version 0.1.2 (with improved path rendering to reduce square features), again rendered with RobA's script.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	step1.png 
Views:	296 
Size:	6.0 KB 
ID:	8279   Click image for larger version. 

Name:	step2.jpg 
Views:	629 
Size:	273.4 KB 
ID:	8280  
    Last edited by isomage; 12-09-2008 at 09:24 PM.
    My random map generators and GIMP scripts: http://axiscity.hexamon.net/users/isomage/

  5. #5

  6. #6
    Community Leader Facebook Connected Steel General's Avatar
    Join Date
    Jun 2008
    Location
    Ft. Wayne, IN
    Posts
    9,530

    Default

    Cool stuff Isomage!
    My Finished Maps | My Challenge Maps | Still poking around occasionally...

    Unless otherwise stated by me in the post, all work is licensed under a Creative Commons Attribution-Noncommercial 3.0 United States License.



  7. #7
    Community Leader Facebook Connected Ascension's Avatar
    Join Date
    Jun 2008
    Location
    St. Charles, Missouri, United States
    Posts
    8,392

    Post

    Makes me want to learn how to GIMP.
    If the radiance of a thousand suns was to burst at once into the sky, that would be like the splendor of the Mighty One...I am become Death, the Shatterer of worlds.
    -J. Robert Oppenheimer (father of the atom bomb) alluding to The Bhagavad Gita (Chapter 11, Verse 32)


    My Maps ~ My Brushes ~ My Tutorials ~ My Challenge Maps

  8. #8

    Default

    Well, your scheme coding skills are waaay better than mine... I'm assuming you actually know scheme!

    The only thing I don't get is what this bit a the end is for:
    Code:
          ; Magic!
    
          (gimp-invert layer)
          (plug-in-sobel  RUN-NONINTERACTIVE image layer 1 1 1)
          (gimp-invert layer)
          (let ((select-point (screen-coordinates '(0 0))))
    	(gimp-fuzzy-select layer
    			   (car select-point) (cadr select-point)
    			   1 CHANNEL-OP-ADD TRUE FALSE 0 FALSE))
          (gimp-selection-invert image)
          (gimp-edit-bucket-fill layer FG-BUCKET-FILL NORMAL-MODE 100 0 FALSE 0 0)
          (gimp-selection-none image)
    I think the same could be done with a simple erode and invert.

    One other suggestion would be to have the user specify the brush size rather than using the 12 px brush.... You'd also have to space the random walk step size proportionately, of course.

    The code to programmaticly define a hard edged brush is:
    Code:
        ;Set up Brush	
        (set! brushTemp (car (gimp-brush-new "MyBrush")))
    	(gimp-brush-set-shape brushTemp BRUSH-GENERATED-CIRCLE)
        (gimp-brush-set-hardness brushTemp 1)
        (gimp-brush-set-radius brushTemp varRadius)
        (gimp-brush-set-spacing brushTemp varSpacing)
        (gimp-brush-set-spikes brushTemp 2)
        (gimp-brush-set-aspect-ratio brushTemp 1)
        (gimp-brush-set-angle brushTemp 0)
        (gimp-context-set-brush brushTemp)
    and then destroy after use by:
    Code:
    	(gimp-brush-delete brushTemp)
    (Of course this would also let you vary the brush size in a random walk itself! just call the gimp-brush-set-radius whenever)

    -Rob A>

  9. #9

    Post

    Quote Originally Posted by RobA View Post
    I'm assuming you actually know scheme!
    I like Lisp, and Scheme's just a dialect -- they have a lot in common.

    The only thing I don't get is what this bit a the end is for:
    ...
    I think the same could be done with a simple erode and invert.
    Ah, you're right -- that stuff follows the process I used to use when I first started playing with this sort of thing, and it's basically redundant now. I've replaced it with an erode. Thanks

    One other suggestion would be to have the user specify the brush size
    I've been thinking about that; it'll probably make it into a future version.

    Of course this would also let you vary the brush size in a random walk itself!
    That's definitely worth investigating.

    Thanks for the advice; I've updated the zip file in the first post to remove that redundant code.
    Last edited by isomage; 12-10-2008 at 10:07 PM.
    My random map generators and GIMP scripts: http://axiscity.hexamon.net/users/isomage/

  10. #10

    Post

    Added color, brush sizing, optional grid. Default settings will still work as input for RobA's script, but it can now make blue, gridded TSR-style maps as well.
    Last edited by isomage; 12-11-2008 at 06:29 AM.
    My random map generators and GIMP scripts: http://axiscity.hexamon.net/users/isomage/

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •