It is currently Sun Jun 07, 2026 3:10 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: How can I find centre of selection Scripting problem[solved]
PostPosted: Thu Mar 22, 2012 1:26 am  (#1) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4826
Location: Bendigo Vic. Australia
I am trying to Radial-blend from the centre of selection but have failed,I'll show an example then what I have tried

Image

(set! selection-bounds (cdr (gimp-selection-bounds image)))
   (set! bounds-x1 (car selection-bounds));x coordinate of upper left corner of selection bounds
    (set! bounds-y1 (cadr selection-bounds));y coordinate of upper left corner of selection bounds
    (set! bounds-x2 (caddr selection-bounds));x coordinate of lower right corner of selection bounds
    (set! bounds-y2 (cadddr selection-bounds));y coordinate of lower right corner of selection bounds
   (set! centre-bounds-x (/ (- bounds-x2 bounds-x1) 2));centre of width
   (set! centre-bounds-y (/ (- bounds-y2 bounds-y1) 2));centre of height
(gimp-edit-blend bkg-layer FG-BG-RGB-MODE NORMAL-MODE GRADIENT-RADIAL 100 0 REPEAT-NONE TRUE FALSE 3 0.2 TRUE centre-bounds-x centre-bounds-y width height)

It allways blend from image centre and not the selection centre,as intended :bawl

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Last edited by Graechan on Thu Mar 22, 2012 11:22 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: How can I find centre of selection Scripting problem
PostPosted: Thu Mar 22, 2012 2:11 am  (#2) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
Your maths is wrong. You should either
be adding, not subtracting the x1 x2 points and dividing by two:
   (set! centre-bounds-x (/ (+ bounds-x2 bounds-x1) 2));centre of width
   (set! centre-bounds-y (/ (+ bounds-y2 bounds-y1) 2));centre of height


or adding the value you've calculated by subtraction to the x1/y1 points
   (set! centre-bounds-x (+ bounds-x1 (- (+ bounds-x2 bounds-x1) 2)));centre of width
   (set! centre-bounds-y (+ bounds-y1 (- (+ bounds-y2 bounds-y1) 2)));centre of height


Kevin


Top
 Post subject: Re: How can I find centre of selection Scripting problem
PostPosted: Thu Mar 22, 2012 4:56 am  (#3) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Also, be aware that 'gimp-edit-blend' uses the drawable's coordinates, so if your script is processing a layer that is not located in the image's upper-left corner (or a layermask belonging to such a layer) then your blend calculations need to adjust for the layer's offsets.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: How can I find centre of selection Scripting problem
PostPosted: Thu Mar 22, 2012 11:21 pm  (#4) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4826
Location: Bendigo Vic. Australia
Thankyou Paynekj and Saulgoode, I had found the centre of the selection, but what was needed was the co-ordinates of the centre of the selection in relation to the layer. In other words my maths was wrong

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group