Re: [Gimp-developer] gimp-python: checking if point is in selection

2006-06-03 Thread Sebastian Breuers
Am Freitag, 2. Juni 2006 19:44 schrieb [EMAIL PROTECTED]:
 Quoting Sebastian Breuers [EMAIL PROTECTED]:
  i wondered if there is a possibility to check, if a point is in a given
  selection by using an internal gimp function.
  If it's not, could someone give me a hint, how to achieve this in
  creating an own function?

 I don't use Python-fu but the following Script-fu function should be
 easily ported (or perhaps you can find a better way):

 (define (point-in-selection image x y)
(let* (
(saved (car (gimp-selection-save image)))
(return-value)
)
  (gimp-rect-select image x y 1 1 CHANNEL-OP-INTERSECT 0 0)
  (set! return-value (car (gimp-selection-is-empty image)))
  (gimp-selection-load saved)
  (if (= return-value 0)
1
0
)
  )
)


Hi.

thanks for the tip. works fine.

seb

 Note that the selection does not include the points at the rightmost
 and bottommost edges. For example, if the selection is from (0,0) to
 (10,10) then the point (10,10) is *not* in the selection but (9,9)
 is. You may need to adjust things to account for this.
 ___
 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


[Gimp-developer] Gimp-python: Artefacts when creating layer

2006-06-03 Thread Sebastian Breuers
[EMAIL PROTECTED]

The plug-in, I'm writing, creates a number of layers, every layer receives an 
object, for example a circle (created by ellipse selection, an selection 
fill), but somewhen, don't know why, the layer contains not only the desired 
circle but also some artefacts. Stripes, areas of white, the mouse cursor, 
things they should not be there.
Is that a problem that can be solved by a certain programmable handling or do 
I have to remove these artefacts by hand?

seb
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Gimp-python: Artefacts when creating layer

2006-06-03 Thread Sebastian Breuers
Am Samstag, 3. Juni 2006 16:58 schrieb Joao S. O. Bueno Calligaris:
 On Saturday 03 June 2006 09:53 am, Simon Budig wrote:
  Alan Horkan ([EMAIL PROTECTED]) wrote:
   On Sat, 3 Jun 2006, Simon Budig wrote:
That sounds as if you don't clear the layer before you use it
for the first time. Layers created from a Plugin are not
initialized from the very beginning. They need to be cleared
using e.g. gimp_drawable_fill.
  

Thanks a lot,

that helped. Did it with:

newLayer.fill(TRANSPARENT_FILL)

seb

   I remember getting caught out by this too.  Why is necessary to
   manually clear a new layer rather than have it done
   automatically?
 
  I have no strong opinions on that. I guess the reasoning behind
  this behaviour was a speed optimization: If a plugin later renders
  stuff to a new layer anyway it would be a waste of time to clear it
  automatically. If it doesn't it would just invoke
  gimp_drawable_fill. No harm done, except that you have to know
  about it.
 
  It might even matter for big images...

 For C plug-ins  that might be true. However, python plug-ins are not
 good in dealing directly with pixels - that is, for rendering things.

 I guess the python api for creating a layer could create an empty one
 with no problems.

 Regards,
   JS
   --

  Bye,
   Simon

 ___
 Gimp-developer mailing list
 Gimp-developer@lists.XCF.Berkeley.EDU
 https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer

-- 
Sebastian Breuers
Huhnsgasse 53
50676 Köln

Tel: 0221-2954235
Mobil: 0179-7841404
Mail: [EMAIL PROTECTED]
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


[Gimp-developer] gimp-python: checking if point is in selection

2006-06-02 Thread Sebastian Breuers
[EMAIL PROTECTED]

i wondered if there is a possibility to check, if a point is in a given 
selection by using an internal gimp function.
If it's not, could someone give me a hint, how to achieve this in creating an 
own function?

seb

Mail: [EMAIL PROTECTED]
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] gimp-python: checking if point is in selection

2006-06-02 Thread Sebastian Breuers
Am Freitag, 2. Juni 2006 19:54 schrieben Sie:
 Hi,

 On Fri, 2006-06-02 at 13:48 +0200, Sebastian Breuers wrote:
  i wondered if there is a possibility to check, if a point is in a given
  selection by using an internal gimp function.
  If it's not, could someone give me a hint, how to achieve this in
  creating an own function?

 Use gimp-image-get-selection to get the selection mask and check the
 value of the pixel you are interested in.

Hi, Sven,

i've already found the selection function, but could you tell me how to check 
the value of the pixel?


 Sven

seb
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer