Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get the (x;y) coordinates of a layer ? [Script-Fu]
#1
Hi again ...

So ... another stupid question about which I can't find the answer anywhere ... (again loosing my hair .... the few still here ....).

How can I get the position of a layer (or any drawable) in my image ??
I mean, its coordinates (no its "position" like Script-Fu defines it = the position in the tree).


I know how to get its width, its heigth, its name, its position in the stack, its opacity, its merging mode, its parent, its children, its... everything ...but its damn coordinates ! Angry

Ok ... I know I've necessary missed something (again... Confused ) ... but if someone has the answer... Heart
Reply
#2
Hi,

I don't know Scheme, but I knew to look for 'offsets', and I found this in a version of Akkana Peck's 'arrow.scm' script.

Code:
            (set! x_offset (car (gimp-drawable-get-offsets drawable)))
            (set! y_offset (cadr (gimp-drawable-get-offsets drawable)))
Reply
#3
(07-23-2024, 02:44 PM)gasMask Wrote: Hi,

I don't know Scheme, but I knew to look for 'offsets', and I found this in a version of Akkana Peck's 'arrow.scm' script.

Code:
            (set! x_offset (car (gimp-drawable-get-offsets drawable)))
            (set! y_offset (cadr (gimp-drawable-get-offsets drawable)))

The call that is documented in the current versions is (gimp-drawable-offsets drawable). (gimp-drawable-get-offsets drawable) is probably deprecated.

But, caution, there is also a (gimp-drawable-offset drawable wrap-around fill-type offset-x offset-y) (no final s) which is a different animal (it shifts the layer contents within the current layer boundaries).
Reply
#4
(07-23-2024, 03:49 PM)Ofnuts Wrote:
(07-23-2024, 02:44 PM)gasMask Wrote: Hi,

I don't know Scheme, but I knew to look for 'offsets', and I found this in a version of Akkana Peck's 'arrow.scm' script.

Code:
            (set! x_offset (car (gimp-drawable-get-offsets drawable)))
            (set! y_offset (cadr (gimp-drawable-get-offsets drawable)))

The call that is documented in the current versions is (gimp-drawable-offsets drawable). (gimp-drawable-get-offsets drawable) is probably deprecated.

But, caution, there is also a  (gimp-drawable-offset drawable wrap-around fill-type offset-x offset-y) (no final s) which is a different animal (it shifts the layer contents within the current layer boundaries).

So my first experience Scheme is incorrect. I should have known to check the procedural browser. Thanks Ofnuts for pointing out my bad input.
Reply
#5
Oh thanks both !!

I tried by searching with "position" (not that...), "coordinates", "x" / "y", ... and checked all procedure with "get" in it ....
Ok, the key-word is "offset" !! Big Grin

I see no "*-get-offsets" in the procedures reference ... even though "-layer-set-offsets" exists .......
... but in fact I see a gimp-drawable-offsets notified as "returns the offsets for the drawable" !!
Disturbing in some ways because this name is not consistent with the names used for the other procedures ... in addition there is a gimp-drawable-offset ... which "offset the drawable by the specified amounts in the X and Y directions" ... nonsensical, just with or without "s" ?? it should be "get" and "set" procedures .... but, finally ... if it works it will be ok ! Tongue 

Thanks again !

(Ok, I'm getting a little angry on my own ... I forgot that for width and height it's gimp-drawable-width / -height ... without "-get-" ...  Confused Big Grin )
Reply


Forum Jump: