It is currently Sat Jul 06, 2024 8:43 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Looking for a simple python-fu sample of path+stroke [solved]
PostPosted: Tue Feb 28, 2012 7:05 am  (#1) 
Offline
New Member

Joined: Feb 28, 2012
Posts: 4
Location: France
Hi,

I've been searching for hours now, and I haven't found a simple sample of a python-fu script that just:
- creates a path with 2 or 3 strokes
- draw it on the current layer

This is not hard to do, but it's hard to find on the net :gaah

Thank you very much


Last edited by olivierpons on Tue Feb 28, 2012 6:35 pm, edited 1 time in total.

Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Looking for a simple python-fu sample of path+stroke
PostPosted: Tue Feb 28, 2012 7:35 am  (#2) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4756
olivierpons wrote:
Hi,

I've been searching for hours now, and I haven't found a simple sample of a python-fu script that just:
- creates a path with 2 or 3 strokes
- draw it on the current layer

This is not hard to do, but it's hard to find on the net :gaah

Thank you very much

Help yourself there:

http://sourceforge.net/projects/gimp-pa ... s/scripts/

I suggest you start with path-dump (shows you how to retrieve stuff in an existing path), then arrow-heads (creates simple strokes), reverse-strokes/delete-strokes (copies parts of paths), path-mirror (connects paths).

You can also have a look at my FAQ on paths:

http://gimp-path-tools.sourceforge.net/paths-faq.shtml

These scripts usually don't stroke the path (this would have very little added value), but neon-path is mostly about stroking the path (and yes, it's not that simple in a script if done properly).

Call again if you need explanations.

_________________
Image


Top
 Post subject: Re: Looking for a simple python-fu sample of path+stroke
PostPosted: Tue Feb 28, 2012 11:14 am  (#3) 
Offline
New Member

Joined: Feb 28, 2012
Posts: 4
Location: France
Hi,

Many thanks for the answer, but I did already went there, and, as I asked, I would just like a simple example.
Here for example, there are four samples that are perfect to show the use of some stuff : http://gimpfr.org/contrib_template.php
What I mean is that there may be just one or two lines I can't find an example how to create (not use, create) in a few lines (like the 4 examples above) a path then stroke.

I've already written an article on "how to write python fu plugin" with three hints that made me loose one day. One day for small hints :cry .

And I guess this is probably the same: it's very easy once you know how to do it, but it will take ages to find that hint. :gaah :hoh
That's why I'm asking here: I just want to avoid loosing a lot of time if someone already know that "hint".
Thank you very much for your help :tyspin , and your site helped me a lot, so if I get no answer, I'll spend some hours trying to find how to create a path then stroke. :cry

By the way I didn't manage to "use" your source code because you need params:

      (PF_IMAGE, "image", "Input image", None),
      (PF_VECTORS, "refpath", "Input path", None),


I don't know how to precise "refpath". If I start from an empty picture, what are the steps needed to be able to precise "refpath"?

/Update/

Ok I've found what I needed:

Here's a part of my code that works: it creates the image, add the layers, creates new "vectors":

  new_image = pdb.gimp_image_new( new_image_width, new_image_height, RGB )
  new_layer = pdb.gimp_layer_new(
    new_image, new_image.width, new_image.height,
    RGBA_IMAGE, _("Background"), 100, NORMAL_MODE)
  pdb.gimp_image_add_layer(new_image, new_layer, -1)
  pdb.gimp_drawable_fill(new_layer, fill_type )
  new_layer = gimp.Layer(
    new_image, _("New Layer"),
    new_image.width, new_image.height,
    RGBA_IMAGE, 100, NORMAL_MODE)
  pdb.gimp_image_add_layer(new_image, new_layer, -1)
  pdb.gimp_drawable_fill(new_layer, fill_type )

  new_vectors=pdb.gimp_vectors_new(new_image, 'Vectors!')
  t = int(round(step / 1.5))
  pdb.gimp_vectors_stroke_new_from_points(
    new_vectors,
    0, # 0 = Beziers Curve
    30,
    # {controle1} {centre} {controle2}
    [ x-(step-t), y, x-step, y, x-(step-t), y,
      x, y+(step-t), x, y+step, x, y+(step-t),
      x+(step-t), y, x+step, y, x+(step-t), y,
      x, y-(step-t), x, y-step, x, y-(step-t),
      x-(step-t), y, x-step, y, x-(step-t), y],
    False) # Closed = True

  pdb.gimp_image_add_vectors(new_image, new_vectors, 0)

  pdb.gimp_context_set_foreground( (255,255,255) )
  pdb.gimp_context_set_brush( "Circle (07)" )
  pdb.gimp_edit_stroke_vectors(new_layer, new_vectors)

  gimp.Display( new_image )



Top
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) stroke selection/stroke path

2

No new posts Attachment(s) stroke path with pattern

26

No new posts Unable to get simple python plugin to show up

8

No new posts Stroke: how to remove space between test & stroke

3

No new posts Attachment(s) i struggle with the option to copy the path - the path where a file i

3



* Login  



Powered by phpBB3 © phpBB Group