[Gimp-developer] Drawing a line in a GIMP plugin
Adam C Powell IV
hazelsct at debian.org
Sat May 30 17:47:52 PDT 2009
I'm sorry, I'm developing a C plugin (tried Scheme first and it was DOG
slow). Is there a C equivalent? All I'm seeing is
gimp-paintbrush-register.
Funny, a search for "gimp c api line" turns up this thread. :-) Going
further, searching for "gimp plugin api draw line" and restricting to
developer.gimp.org turns up GDK drawing primitives.
So it sounds like the best way to proceed is to wrap the pixel data into
a GdkPixbuf and use GDK to draw into it. Figured there might be a more
straightforward way to go from a GimpDrawable to a GdkDrawable (since it
is after all the "GIMP Drawing Kit"). Hmm, and there's a GimpCanvas
object, but that doesn't seem to be a plugin thing.
Thanks,
Adam
On Sat, 2009-05-30 at 19:20 -0400, Rob Antonishen wrote:
> Here is the code to draw a single pixel line, black on white, on the
> drawable "layer" and x1 y1 are one end and x2 y2 are the other.
>
> (gimp-context-set-brush "Circle (01)")
> (gimp-context-set-foreground "Black")
> (gimp-context-set-background "White")
> (gimp-context-set-opacity 100)
> (gimp-context-set-paint-mode NORMAL-MODE)
> (gimp-pencil layer 4 (vector x1 y1 x2 x2))
> (gimp-displays-flush)
>
> 0,0 is upper left hand side. This is with the pencil tool. Replace
> with any other tool as desired, for example:
> (gimp-paintbrush-default layer 4 (vector x1 y1 x2 y2))
>
> Hope that helps,
>
> -Rob A>
--
GPG fingerprint: D54D 1AEE B11C CE9B A02B C5DD 526F 01E8 564E E4B6
Engineering consulting with open source tools
http://www.opennovation.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : /lists/gimp-developer/attachments/20090530/a5955cc3/attachment.bin
More information about the Gimp-developer
mailing list