[Gambas-user] Find color on point in drawingarea

Timothy Marshal-Nichols timothy.marshal-nichols at ...247...
Mon May 22 07:21:44 CEST 2006


Try this.

The Grab() function on a control returns a Picture. But you can not get
the color of a point from a Picture. You get the color from a Image.
So convert the Picture to a Image. Then its easy.


PUBLIC SUB Form_Open()
  DrawingAreaColor.Cached = TRUE
  DrawingAreaColor.BackColor = Color.White
  Draw.Begin(DrawingAreaColor)
  Draw.ForeColor = Color.Blue
  Draw.Line(10, 10, 290, 10)
  Draw.ForeColor = Color.Red
  Draw.Line(290, 10, 290, 290)
  Draw.ForeColor = Color.DarkGreen
  Draw.Line(290, 290, 10, 290)
  Draw.ForeColor = Color.DarkYellow
  Draw.Line(10, 290, 10, 10)
  Draw.End
END

PUBLIC SUB DrawingAreaColor_MouseDown()
  DIM c AS Integer
  c = DrawingAreaColor.Grab().Image[Mouse.X, Mouse.Y]
  PRINT "Color: 0x" & Hex(c, 6) & " at " & Mouse.X & ", " & Mouse.Y
END 

Thanks

8-{)} Timothy Marshal-Nichols
<mailto: timothy.marshal-nichols at ...247...>


> -----Original Message-----
> From: gambas-user-admin at lists.sourceforge.net
> [mailto:gambas-user-admin at lists.sourceforge.net]On Behalf Of ron
> Sent: Sunday, 21 May 2006 10:20
> To: gambas-user at lists.sourceforge.net
> Subject: [Gambas-user] Find color on point in drawingarea
> 
> 
> Hi all,
> 
> Any bode who know how to get the color information of a point
> in the DrawingArea ?
> 
> In this area I have drawn several lines where the x/y point for
> start en end location are in a array.
> I need to find on a MouseDown event on a line the index in that array.
> 
> pts[0]=[1,2,3,4]
> pts[1]=[5,6,7,8]
> 
> draw.begin(DrawingArea)
>   for x = 0 to pts.count-1
>     t=pts[x]
>     draw.line(t[0],t[1],t[2],t[3])
>   next
> draw.end
> 
> sub DA_MouseDown()
>   'find if point by mouse.x and .y is drawn in linecolor
>   checkhit how?
> end
> 
> 
> TIA Ron.
> 
> 
> -------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make 
> your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 






More information about the User mailing list