Gimptalk - Premier Gimp Community: [Script] Animated Path Stroking/Path Suite - Gimptalk - Premier Gimp Community

Jump to content

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

[Script] Animated Path Stroking/Path Suite

#1 User is offline   fencepost 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 2,643
  • Joined: 01-March 05

Posted 16 January 2010 - 03:42 PM

This script will allow you to take paths and turn them into an animated hand-drawn look by choosing a couple of options. Here's a couple of samples (although this only scratches the surface on what can be done.) In addition to the main script, I've included several "supplemental" tools to help you with the process. The script can be downloaded here: Fencepost's Path Suite. Open the zip file and save the .scm file to your GIMP scripts folder (ie...C:\Program Files\GIMP-2.0\share\gimp\2.0\scripts). Refresh your scripts and you're ready to go.

Posted Image Posted Image

I plan on preparing some usage tips and posting them, but I don't have time at the moment to do that. However, I have prepared a couple of screenshots with some information to get you started.

This script was created as a gift to two individuals who have inspired me through their commitment to GIMP, their willingness to share knowledge, and dedication to artists all around the world.

First and foremost is ClayOgre. Like me, ClayOgre, whom I haven't seen online in awhile, had a fascination with animations and paths. When I first began scripting, he suggested that I try and figure out how to create scripts combining animations and paths. I laughed! No way it would ever happen. Well, here we are today with my very first animated path script. Thanks, CO, for your inspiration.

Secondly, and certainly not least, is to saulgoode. Saulgoode is a silent giant in the GIMP community. You never see much artwork produced by him, but the bestows on the GIMP community through his tutorials, scripts, understanding of programming and computers, and the inner-workings of GIMP is definitely "artwork!" Without his sharing of knowledge, I would never have attempted scripting.

My hats off to both of you for your inspiration! Thanks for all you do and I hope this script meets your satisfaction.


The scripts can be found at two locations (one for the animation and the other for the supplemental tools).

The scripts are found by right-clicking on a path in the path dialog and choosing the desired script:

Posted Image

Some other useful scripts to use in conjunction with mine:

Saulgoode's
http://www.flashingtwelve.brickfilms.co ... ine-bg.scm
http://www.flashingtwelve.brickfilms.co ... ttings.scm


LIMN's
http://www.mediafire.com/?jzmre45q1oi (the split strokes script will let you separate all the strokes in a given path to individual paths)

Insanity Prevails
http://insanity-prevails.deviantart.com ... s-72632286


Open up a image (at this time it should be RGB/Grayscale) - haven't been able to figure out the painting for Indexed images yet.

Prepare a path(s) and you can begin. Pick a brush tool (can be paintbrush, eraser, smudge, airbrush, pencil, or dodge/burn tool. If you choose any other tool, it defaults to paintbrush), choose the desired brush, set the brush opacity, mode and run the script. When you open the animation script, you will see this window:

Posted Image

Starting at the top:

Choose the stroke (a stroke is when a path has more than one piece to it. For example, when you use fonts in many of the letters - a, e, p, q, etc. - have "holes" in them. The holes are created by a separate piece (stroke).
Choose the number of frames you want the animation to paint
I've included several paint/path options (see image below)

Posted Image

The options are generally straightforward, but here's a general description...

"Paint paths and add segments"
- This will paint the layers and add every segment created to the image. That way you can use them later if needed.
"Paint paths, but don't add segments" - Just paints the segments
"Don't paint paths, but add segments" - Pretty self-explanatory
Paint paths that have been previously segmented" - Select any path in the path list, tell it the number of frames to paint and it will do the rest.
"Paint by keyframes and add segments" - Let's say you want the animation to be at a specific location at a certain time, this option is for you! Pick the start/end point numbers for the path and run the script. If you don't know where the points are or what their ID number is, this is where the supplemental scripts come in handy.
"Paint by keyframes, but don't add segments" - Same as above without adding the segments.


Now, back to the main window options:

Add a copy of the final painted path segment to each layer above it in the layer stack. If end your painting on a layer below the top of the stack, this option will copy it up to the top so that your animation doesn't abruptly cut off after that. You can disable this feature.
The Start Point for keyframing.
The End Point for keyframing.
Color Method - Solid Color or Gradient
Choose the color/gradient to paint with
If you paint with a gradient, you need to specify a distance or it won't come out right.
Paint Method (only used with the paintbrush and eraser) - Constant or Incremental. See the GIMP manual for a description

Some options can only be used in scripts through the script interface, some can't be used at all. The ones required to be done through scripting have been included in the script. The others (and there are only a few) can be changed in the appropriate brush dialog.

Fade out (paintbrush only) - the length of the brush stroke before fading. This doesn't lend itself to the animation process at this time because it isn't set up to increment. I may add that to the code later.
Airbrush/Smudge pressure or Dodge/Burn Exposure - This option sets the parameters for the tools listed.
Eraser hardness or Dodge/Burn - Another option that works depending on which tool you've selected.
Dodge/Burn Method - whether to paint on Shadows, Midtones, or Highlights

The brush spacing must be set here:

Posted Image

The brush opacity and paint mode could have been scripted, but I was running out of room on the script window.

Now, for a brief discussion of the supplemental tools.

Path Details - Gives you some basic information about the path/stroke (length, number of points, if the path is too long to be painted with the script - you may have to split up longer paths, etc.)
Path Direction - Paths are always stroked in the direction they are created. But, what if you didn't create the paths manually? You don't know the direction. This script will paint the direction on a new layer for you. The starting point will be green and it will transition to red. The script will also tell you if the path is closed.
Reverse Path Direction - If you want a path to move in the opposite direction than it does, run this script. A new path will be added with the points reversed.
Show Point - Need to know where a specific point is on a path? This script will do it. Very handy for keyframing.
Stroke Delete - Lets you delete a stroke in the path. Just specify it's number.


Well, that's all for now. I'll prepare more later. Let me know if you have any questions or need more information. If you find any errors in the script or would like to see it improved, suggestions are welcome.

Enjoy! Cheers!

Art
0

#2 User is offline   PhotoComix 

  • GT Senior Moderator
  • Group: Senior Moderators
  • Posts: 11,288
  • Joined: 13-June 05

Posted 16 January 2010 - 04:14 PM

Wow... you created a really powerful tool for animation
I will need some time to read your indication and get used to the various control, anyway you did the miracle to attract my interest on paths, the function of gimp i must overlooked till your very first wip of the script

I am just amazed of what you have done and all changes and improvement from then

Just a question before i going in the details to start to experiment:
how the script handle now intercrossing paths and paths with "islands " ? :?:
0

#3 User is offline   fencepost 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 2,643
  • Joined: 01-March 05

Posted 16 January 2010 - 04:20 PM

PhotoComix said:

Wow... you created a really powerful tool for animation
I will need some time to read your indication and get used to the various control, anyway you did the miracle to attract my interest on paths, the function of gimp i must overlooked till your very first wip of the script

I am just amazed of what you have done and all changes and improvement from then


Thanks, PC! This has been an incredible learning process! A lot of fun.

Quote

Just a question before i going in the details to start to experiment:
how the script handle now intercrossing paths and paths with "islands " ? :?:


Intercrossing paths? Two separate path segments that cross or a path that crosses over itself?

If it's two separate path segments that cross, there's no problem. Two separate paths within the same path are called strokes. I've set up the script for you to choose which stroke to work with. This is the same for islands. I've covered some stroke details above in the description and my supplemental scripts will help too.

If you're just wondering whether a single path can pass over itself....no problem there either.

Let me know if you have any questions or troubles with it.
0

#4 User is offline   PhotoComix 

  • GT Senior Moderator
  • Group: Senior Moderators
  • Posts: 11,288
  • Joined: 13-June 05

Posted 16 January 2010 - 04:49 PM

Amazing ...i will try soon
0

#5 User is offline   mikethedj4 

  • mikethedj4
  • PipPipPip
  • Group: Members
  • Posts: 1,083
  • Joined: 20-June 08
  • LocationRockford, IL

Posted 16 January 2010 - 10:32 PM

All I haft to say is WOW! :shock:
Posted Image
0

#6 User is offline   fencepost 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 2,643
  • Joined: 01-March 05

Posted 16 January 2010 - 11:14 PM

Thank you!
0

#7 User is offline   saulgoode 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 5,324
  • Joined: 22-August 05

Posted 17 January 2010 - 01:38 AM

Thank you for the kind words and the tribute. The script is quite impressive and I am well aware of how involved dealing with paths and strokes can be -- there is a lot to keep track of and you've certainly demonstrated how far along your scripting abilities have progressed.

Being the non-artistic person that I am, I made the following animation from a SVG version of Tuomas Kuosmanen's "Wilber" made available for free use by GIMP's project leader, Sven Neumann.

Posted Image

I did make a couple of modifications to the script as I kept choosing the wrong path, or the wrong layer, as I processed the image. I moved the command to the Paths (context) Menu; I may be missing something but by having the command associated with a particular Path's right-click menu there is no need to examine the path names (and no need for your script to test whether a valid path was provided). I also eliminated the "The layer to paint on" choice and instead just assume this to be the active layer (is there a reason for ever not to be the currently active layer?). Also, if you are looking for space to add more options, you might also consider removing the "Disable selection?" choice. It is typically assumed that filters will honor selections if they are present and if a user wishes to "disable" it, she needs only to Select->None before running the script.


Nonetheless, the script appears both well-written and quite functional. Hopefully, the artistic members of GIMPtalk will be able to put it to better use than I -- though I expect I will be availing myself of it as well.

Nicely done!
Everybody makes their own fun. If you don't make it yourself it's not fun, it's entertainment.
0

#8 User is offline   fencepost 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 2,643
  • Joined: 01-March 05

Posted 17 January 2010 - 02:01 AM

saulgoode said:

Thank you for the kind words and the tribute. The script is quite impressive and I am well aware of how involved dealing with paths and strokes can be -- there is a lot to keep track of and you've certainly demonstrated how far along your scripting abilities have progressed.


Thanks for the kind words and, again, for all the assistance & inspiration. This certainly was a challenge and I'm really glad I kept at it. There were many times I would solve one problem and create a new one. Just wanted to either give up or post what I had done and left it "unfinished." But, I'm rather anal and just couldn't let it go. I think it allowed me to really learn a lot. You may have noticed how much I commented the script. I knew I would never remember why I did what I did and I figured I better do a good job of documenting (I've been lazy in my recent scripts about commenting.)

Thanks for testing it out and providing me with your feedback. That's what I need to make it even better.

Quote

I did make a couple of modifications to the script as I kept choosing the wrong path, or the wrong layer, as I processed the image. I moved the command to the Paths Menu; I may be missing something but by having the command associated with a particular Path's right-click menu there is no need to examine the path names (and no need for your script to test whether a valid path was provided).


So, you put the whole thing in the Path Menu instead of under the Animation menu? I thought about that, but decided against it. No reason behind my decision, just the way I did it. However, I like your thought process as it allows more interface space. I'll also see about the valid path test. What I noticed from other scripts that work on images, if you don't have an image open, it's of the wrong type, or doesn't have a layer in it, the scripts are unavailable. This doesn't appear to be the case for paths (at least not on my system). As long as I had a layer in the image - and no paths - the path options were available. I was concerned that if they were available, it would just result in an error. Again, hand-holding. So, I added the tests in to be safe and cover all the bases.

Quote

I also eliminated the "The layer to paint on" choice and instead just assume this to be the active layer (is there a reason for ever not to be the currently active layer?).


Actually, there is a reason one could choose a layer other than the currently active one. If the user wants to start painting on a layer other than the active one, they can set it in the script. However, I only included it as a last minute option because I've gotten into the habit of hand-holding people along and wanted to make sure I didn't leave anything out and create confusion. I think I will eliminate it though, because it will save interface space. When it all comes down to it, GIMPers shouldn't need their hands held. We should hold them to a much higher standard. :o

Quote

Also, if you are looking for space to add more options, you might also consider removing the "Disable selection?" choice. It is typically assumed that filters will honor selections if they are present and if a user wishes to "disable" it, she needs only to Select->None before running the script.


Well, said. That will come out.


Quote

Nonetheless, the script appears both well-written and quite functional. Hopefully, the artistic members of GIMPtalk will be able to put it to better use than I -- though I expect I will be availing myself of it as well.

Nicely done!


Thank you!
0

#9 User is offline   ccbarr 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 1,701
  • Joined: 23-February 06

Posted 17 January 2010 - 09:16 AM

Art,

The potential uses for this script seem quite large indeed. I really look forward to using it. You are a person willing to take on a challenge and it shows by the excellent quality of the scripts that you create. You really have become quite a premier Gimp scripter.

But you are not yet a Gimp Jedi. I am your true Gimp father. Join me on the Gimp darkside and together we can rule the Gimpiverse!

Ok, maybe that last statement was a bit melodramatic and possibly not quite even remotely true.

:mrgreen:

On a more serious note of concern, I just loaded it here on Gimp 2.6.8 and I received the following message in my console window where I run Gimp from:

Quote

fp-script-fu-anim-path-stroke: image-type contains unrecognizable parts:'RGB* GRAYSCALE*'


I tested out the script a few times on a simple path with different parameters and it worked as expected for a script written by you - terribly. Just joking (again), it worked great. I think I'm already addicted to it.

:D

Edit: Here is a "Thanks Art" Animation ala your script:

Posted Image

And cause they are so much fun:

Posted Image

And one more:

Posted Image


:)
0

#10 User is offline   BernieW 

  • Member
  • PipPip
  • Group: Members
  • Posts: 101
  • Joined: 22-December 05

Posted 17 January 2010 - 07:59 PM

Wow, thank you fencepost for the script and links.

I had no idea how powerful paths could be.
0

#11 User is offline   fencepost 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 2,643
  • Joined: 01-March 05

Posted 18 January 2010 - 02:32 PM

ccbarr said:

Art,

The potential uses for this script seem quite large indeed. I really look forward to using it. You are a person willing to take on a challenge and it shows by the excellent quality of the scripts that you create. You really have become quite a premier Gimp scripter.

But you are not yet a Gimp Jedi. I am your true Gimp father. Join me on the Gimp darkside and together we can rule the Gimpiverse!

Ok, maybe that last statement was a bit melodramatic and possibly not quite even remotely true.


Thank you, Lord VaderGIMP! :mrgreen:

Quote

On a more serious note of concern, I just loaded it here on Gimp 2.6.8 and I received the following message in my console window where I run Gimp from:

fp-script-fu-anim-path-stroke: image-type contains unrecognizable parts:'RGB* GRAYSCALE*'


I'll have to look into that and see if changes have been made to GIMP's Scheme implementation. Is 2.6.8 a stable release?

Quote

I tested out the script a few times on a simple path with different parameters and it worked as expected for a script written by you - terribly. Just joking (again), it worked great. I think I'm already addicted to it.


Thanks for giving it a test drive!

BernieW said:

Wow, thank you fencepost for the script and links. I had no idea how powerful paths could be.


You're welcome! They are very powerful. Be careful when using them; don't want you to get hurt! :o :roll:




I have a programming question: I set up the script to define a function a painting tool function so that it could be used frequently throughout the script. I'm modifying the code to allow it to make better use of the "fade" parameter (will allow the fade to automatically increase with the segment length). I appears though that once a function has a parameter assigned to it, it doesn't change. Is that correct? Here's the code that I used for the tool:

(if (or (string=? "gimp-ink" paintTool)(string=? "gimp-paintbrush" paintTool)
	(string=? "gimp-clone" paintTool) (string=? "gimp-heal" paintTool)
	(string=? "gimp-perspective-clone" paintTool) (string=? "gimp-convolve" paintTool)
	)
	(define (user-paint-tool activeLayer)(gimp-paintbrush activeLayer fade pos points paintMethod gradLength))
)


When I increased the fade parameter with the segment length increase, nothing changes when the paint function is actually used....it uses whatever it started with. Is there a way to change the code to allow for changes to the fade parameter using the same structure I have now or do I need to create an "if" section in the middle of the code to test and apply new settings each time it's called? Only the paintbrush tool can utilize the fade parameter, so changes shouldn't be too bad.

As an FYI, I'm also in the process of modifying the code to remove the options for selecting the path and layer to work with, as well as the distance increment option. I also moved it to the menu location to the Path Dialog window. They just take up too much real estate on the interface. Once I get the fade parameter fixed, I'll post the newest version with new screenshots, usage information.
0

#12 User is offline   saulgoode 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 5,324
  • Joined: 22-August 05

Posted 18 January 2010 - 03:50 PM

fencepost said:

I appears though that once a function has a parameter assigned to it, it doesn't change. Is that correct? Here's the code that I used for the tool:

(if (or (string=? "gimp-ink" paintTool)(string=? "gimp-paintbrush" paintTool)
	(string=? "gimp-clone" paintTool) (string=? "gimp-heal" paintTool)
	(string=? "gimp-perspective-clone" paintTool) (string=? "gimp-convolve" paintTool)
	)
	(define (user-paint-tool activeLayer)(gimp-paintbrush activeLayer fade pos points paintMethod gradLength))
)

The value of 'fade' at the time the painting is performed should be the value used (not it's value when the function is defined). In other words, I don't believe your observance is correct and suspect the problem lay elsewhere. I'm confused as to why 'pos' is being used here -- shouldn't this be the number of points (arrayLength?) and not the position of the points in the stroke?
Everybody makes their own fun. If you don't make it yourself it's not fun, it's entertainment.
0

#13 User is offline   fencepost 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 2,643
  • Joined: 01-March 05

Posted 18 January 2010 - 04:26 PM

saulgoode said:

The value of 'fade' at the time the painting is performed should be the value used (not it's value when the function is defined). In other words, I don't believe your observance is correct and suspect the problem lay elsewhere.


Thanks. I'll check it out again this evening and see what I come up with.

Quote

I'm confused as to why 'pos' is being used here -- shouldn't this be the number of points
(arrayLength?) and not the position of the points in the stroke?


'pos' is used in 2 ways - depending on the situation: one to keep track of the number of points in the array and the pos of the points in the stroke. I thought using 'pos' like this might raise confusion to others reviewing the code, but forgot to make another variable to track the number of points. It's not actually the arrayLength, however. Because I don't completely understand management of arrays, I couldn't figure out if it's possible to create an array, develop one path segment, take the previously created array, increase its size and fill it with the next set of points for the next segment, and so on. (I guess it would be called appending an array?) What I did figure out is that if I created a maximum array based on the the path length. Fill it with points and then when the segment length is reached based on those points, tell GIMP to create the path based on the first "x number of points" and fill it with (x * 6) coordinates.

For example:

Path length = 1000
Based on a simplified version that points are collected at every 1 pixel, there will be 1006(?) points within the array, and I set up the array based on that number. Then the array is filled with only those points for the current segment. If there are 2 points within the segment, only 12 elements of the array are filled and when the path is created, it uses 12 and the associated points #(x1 y1 x2 y2 x3 y3 x4 y4 x5 y5 x6 y6). However, the array length is still 1006. Then, I just keep adding points as needed for the additional segments. I recognize this probably isn't correct, but it worked and I went with it! :D Does my approach make sense, even if it's done incorrectly?

Based on your question, however, I will change the code to use a different variable to track the number of elements in the array.

EDIT 12:45 PM - After reconsidering my response to your question, I realize it's kinda right/kinda wrong. It's right in the sense of how I created the path, but might not be correct with regard to the actual painting of the path. I was in a rush while responding and didn't think things through properly. I'll clean up the code so that it's easier to follow there.
0

#14 User is offline   molly 

  • Member
  • PipPip
  • Group: Members
  • Posts: 647
  • Joined: 03-September 09

Posted 09 February 2010 - 05:45 PM

That path stroking script looks awesome but when I try to use it I can't get to the bottom of the script page. There should be an OK to click but there is no way to shrink or minimize the page in order to get to the bottom where the OK exists.
someone help me please... It is also like that on the animated fire script..... just an X in the top right corner.....
Posted Image
Posted Image Click Me!
0

#15 User is offline   RobA 

  • Member
  • PipPip
  • Group: Members
  • Posts: 697
  • Joined: 05-November 07

Posted 10 February 2010 - 02:45 PM

molly said:

That path stroking script looks awesome but when I try to use it I can't get to the bottom of the script page. There should be an OK to click but there is no way to shrink or minimize the page in order to get to the bottom where the OK exists.
someone help me please... It is also like that on the animated fire script..... just an X in the top right corner.....


What is your screen resolution?

-Rob A>
Posted Image
Fantasy Cartography and Mapping by RobA
0

#16 User is offline   molly 

  • Member
  • PipPip
  • Group: Members
  • Posts: 647
  • Joined: 03-September 09

Posted 10 February 2010 - 02:50 PM

1024 x 768
Posted Image
Posted Image Click Me!
0

#17 User is offline   fencepost 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 2,643
  • Joined: 01-March 05

Posted 10 February 2010 - 03:39 PM

Molly, can you post a screenshot of what you're seeing? I understand your question, but maybe there's something we can help you with by seeing your screen.

Also, I responded to your question on deviantArt.

Art
0

#18 User is offline   molly 

  • Member
  • PipPip
  • Group: Members
  • Posts: 647
  • Joined: 03-September 09

Posted 10 February 2010 - 05:24 PM

Here you go. It fills the whole page with no sidebars to scroll to the bottom where the OK is....
Posted Image
Posted Image
Posted Image Click Me!
0

#19 User is offline   PhotoComix 

  • GT Senior Moderator
  • Group: Senior Moderators
  • Posts: 11,288
  • Joined: 13-June 05

Posted 10 February 2010 - 07:11 PM

i believe that may be a problem in the dimensions used to define the monitor

Often the dimension of the screen is automatically set, anyway may be errors, i had one similar because the dimension set were too large

Usually application never use all the available space, there is usually a margin left so the problem was not evident, except that few gimp script that were needed all the available space..in that case button as ok cancel and reset were going out of reach

Well as i said my problem was incorrect propriety for the screen, basically you should recover the booklet of your screen, or found its data on the web then enter in my computer /screen and check that all data there, and specifically for width and height are correct
0

#20 User is offline   PhotoComix 

  • GT Senior Moderator
  • Group: Senior Moderators
  • Posts: 11,288
  • Joined: 13-June 05

Posted 10 February 2010 - 07:16 PM

in more simple word is not gimp but is your computer convinced to have a monitor bigger then in reality
0

Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic