Drawing selection in canvas
Author Message
Drawing selection in canvas

Hi all,
I was wondering if someone could help me out with a little canvas
trouble I'm having. What I want to do is draw the "selection" effect
(for example, like when you select a folder in the finder) on my
canvas.
I have drawn a grid of hexagons in a canvas and when someone clicks
the canvas in a certain location I would like the hexagon in question
to become "selected".
The way I'm doing this is first determining exactly in which hexagon
the user clicked, then pass these (x,y) coordinates on to my
drawselection method.
Here is some code:
'This first part sets the points of the hexagon to be drawn, based on
the (x,y) passed
iPoints(1)=x
iPoints(2)=y+12
iPoints(3)=x+20
iPoints(4)=y
iPoints(5)=x+40
iPoints(6)=y+12
iPoints(7)=x+40
iPoints(8)=y+34
iPoints(9)=x+21
iPoints(10)=y+46
iPoints(11)=x+19
iPoints(12)=y+46
iPoints(13)=x
iPoints(14)=y+34

'pNodeSelection is a picture
pNodeSelection.Graphics.ForeColor=RGB(100,100,100)
pNodeSelection.Graphics.FillPolygon(iPoints)

And then I draw this part of the new drawing to the screen. However,
the hexagon that is being drawn to the screen is not transluscent at
all, and the portion of the square not filled up by the hexagon shows
up as white. Setting the transparent property did not help.

I know this should be relatively straight forward, but I can't figure
it out. Any help is much appreciated.
Thanks, Jonck

Sat, 10 Dec 2005 10:26:10 GMT
Drawing selection in canvas
A small reply to my own post :-)
I tried the following:
first draw a completely white mask in the entire square that will be
drawn to screen, then to draw a darker mask in the space where the
hexagon should be shown.

'Draw the square white maskt to make the edges invisible

'Draw the hexagon shaped mask to make the hexagon transluscent
pNodeSelection.Graphics.FillPolygon(iPoints)

'draw the "selection" to screen
cnvSomGrid.Graphics.DrawPicture pNodeSelection, x, y, 40, 46, y, x,
40, 46

However, now the entire picture is completely invisible! This seems
strange to me, since I draw over the completely white mask with a
non-white portion. At least this portion should show on screen I would
have thought, but I guess I'm still doing something wrong.

Thanks for any help, Jonck

Quote:
> Hi all,
> I was wondering if someone could help me out with a little canvas
> trouble I'm having. What I want to do is draw the "selection" effect
> (for example, like when you select a folder in the finder) on my
> canvas.
> I have drawn a grid of hexagons in a canvas and when someone clicks
> the canvas in a certain location I would like the hexagon in question
> to become "selected".
> The way I'm doing this is first determining exactly in which hexagon
> the user clicked, then pass these (x,y) coordinates on to my
> drawselection method.
> Here is some code:
> 'This first part sets the points of the hexagon to be drawn, based on
> the (x,y) passed
>   iPoints(1)=x
>   iPoints(2)=y+12
>   iPoints(3)=x+20
>   iPoints(4)=y
>   iPoints(5)=x+40
>   iPoints(6)=y+12
>   iPoints(7)=x+40
>   iPoints(8)=y+34
>   iPoints(9)=x+21
>   iPoints(10)=y+46
>   iPoints(11)=x+19
>   iPoints(12)=y+46
>   iPoints(13)=x
>   iPoints(14)=y+34

> 'pNodeSelection is a picture
>   pNodeSelection.Graphics.ForeColor=RGB(100,100,100)
>   pNodeSelection.Graphics.FillPolygon(iPoints)

> And then I draw this part of the new drawing to the screen. However,
> the hexagon that is being drawn to the screen is not transluscent at
> all, and the portion of the square not filled up by the hexagon shows
> up as white. Setting the transparent property did not help.

> I know this should be relatively straight forward, but I can't figure
> it out. Any help is much appreciated.
> Thanks, Jonck

Sat, 10 Dec 2005 19:28:50 GMT
Drawing selection in canvas
Hi all,
Never mind, it's working now. I don't know what was the matter but I
started RB today, and without changing any code to my program, this
time round it works. So something was screwed up, not sure what, but
restarting RB solved it. I have tried to reproduce this behavior but
it's working fine now.
--Jonck

Quote:
> Hi all,
> I was wondering if someone could help me out with a little canvas
> trouble I'm having. What I want to do is draw the "selection" effect
> (for example, like when you select a folder in the finder) on my
> canvas.
> I have drawn a grid of hexagons in a canvas and when someone clicks
> the canvas in a certain location I would like the hexagon in question
> to become "selected".
> The way I'm doing this is first determining exactly in which hexagon
> the user clicked, then pass these (x,y) coordinates on to my
> drawselection method.
> Here is some code:
> 'This first part sets the points of the hexagon to be drawn, based on
> the (x,y) passed
>   iPoints(1)=x
>   iPoints(2)=y+12
>   iPoints(3)=x+20
>   iPoints(4)=y
>   iPoints(5)=x+40
>   iPoints(6)=y+12
>   iPoints(7)=x+40
>   iPoints(8)=y+34
>   iPoints(9)=x+21
>   iPoints(10)=y+46
>   iPoints(11)=x+19
>   iPoints(12)=y+46
>   iPoints(13)=x
>   iPoints(14)=y+34

> 'pNodeSelection is a picture
>   pNodeSelection.Graphics.ForeColor=RGB(100,100,100)
>   pNodeSelection.Graphics.FillPolygon(iPoints)

> And then I draw this part of the new drawing to the screen. However,
> the hexagon that is being drawn to the screen is not transluscent at
> all, and the portion of the square not filled up by the hexagon shows
> up as white. Setting the transparent property did not help.

> I know this should be relatively straight forward, but I can't figure
> it out. Any help is much appreciated.
> Thanks, Jonck

Sat, 10 Dec 2005 22:21:43 GMT
Drawing selection in canvas

Quote:
> A small reply to my own post :-)
> I tried the following:
> first draw a completely white mask in the entire square that will be
> drawn to screen, then to draw a darker mask in the space where the
> hexagon should be shown.

> 'Draw the square white maskt to make the edges invisible

Yes.  Or, the more standard way, which is to use ClearRect to clear the
mask first (then you don't have to muck with the ForeColor).

BTW, the parameters on the RGB function range from 0-255 (not 256).

Cheers,
- Joe

,------------------------------------------------------------------.
|    Joseph J. Strout         Check out the Mac Web Directory:     |

`------------------------------------------------------------------'

Sat, 10 Dec 2005 22:45:58 GMT

 Page 1 of 1 [ 4 post ]

Relevant Pages