On Sun, Sep 12, 2010 at 8:58 AM,  <oli...@first.in-berlin.de> wrote:
> Hello,


Hi

>
> I tried drawing per Script.
> I'm using Python.
>
> I can already use vectors for drawing circles,
> and set single points.
>
> I did not found a way to create rectangles,
> or lines.


You are probablu using pdb_gimp_vectors_bezier_stroke_new_ellipse
to draw circles, right?
What does prevent you from using the calls for
gimp_vectors_bezier_stroke_new_moveto and
gimp_vectors_bezier_stroke_lineto to draw lines?
(Don't  forget to alias then in your code to shorter names, last you
have really undereadable stuff)

Still, creating a vectors object from stroking is one way of painting
with scripts in GIMP (the recomended one to draw curves and circles,
though) - for stragiht lines you can use pdb.gimp_paintbrush instead.





> Aren't there pdb-functions that draw a line?
>
> Do I have to create it pixelwise?
> In a loop?
>

As I stated above, there are calls to draw lines.
Are you even using the procedure browser? (Help menu - > Procedure browser) -

In Python you can access the image data directly, using calls to get
the pixel regions if you want to as well (that is about 100x  faster
than gimp_drawable_set_pixel  due to the function calls involved for
each pixel change)

>
> When using the circle drawing with vectors I would
> expect that this technique can do it's work fast.
> But it's very slow (using a loop to set paths in those vectors).
> (In OpenGL for example there are Vertex Arrays that can be used to speed up
>  drawing. Something like that in GIMP, and available for scripting would be 
> nice.)

Sorry to tell you that - tehre is some slowdown in using the PDB, but
this is more or less as fast as it gets using GIMP to draw yiu stroken
circles. You probably coukd get some speed-u dealing straight with the
image data if you don't need the stroking engines from GIMP - i.e. -
no need to use different brushes, gradients, dynamics and so on)
If so you can get some significant speed-up using C, or maybe even
python if you get an efficient way to draw your circles using pixel
data.
(A suggestion would be to cache different pixel data for the circles
with the radii you want, as gimp-buffers, and paste then on the desred
places on teh image - that shoul be much  faster than
creating/stroking paths)


> (I also saw, that what on the GUI are Paths internally are called vectors.
> To make things better undesrstandable, it would make sense to give things the
> same name... but maybe there is more to vectors and I don't see it so far.
> Why are there different names?)


 will leave that up to Simon :-)
>
>
> How can I speed up my drawings without switching to C?
> With my Python script I need about 3 or 4 seconds just for drawing 2072 
> circles.


So, besides my hints above: when I need speed on a PDB using script
(which includes python scripts),
I found out that GIMP's undo system is the cause for a significant slow down.
Creating an Undo group does not help - you have to disbale the undo with
pdb.gimp_image_undo_disable
This can give you a 3x to 4x times improvement when you have many
small operations going on (like drawing thousands of circles) .
Unfortunatelly this spoins the undo system for you rimage -even after
a call to "undo_enable".
If you are editing the image interactvely I suggest you make your script to:
- copy the drawable you are interested to a new image
- disable the undo system on the new image
- perform your painting operations
 - copy the drawable back to the original image
(and destroy the newly created image, of course)



>
> This seems very slow to me.
>
> If I also would need to write pixels of a line pixel-wise,
If you weant 1 pixel thick straight lines, use the pencil tool and the
"pixel" brush.

> I would also await to have very slow scripts.
> Special functions for drawing lines from within Python-plugins,
> that use C-speed would be fine.
>


Regards,

 js
 -><-

> Gruß,
>   Oliver
> _______________________________________________
> Gimp-developer mailing list
> Gimp-developer@lists.XCF.Berkeley.EDU
> https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer
>
_______________________________________________
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer

Reply via email to