You can have one touch event for the whole panel and then check the color in the x y point. That will work if every piece has a different color.I need to set different event for every slot on the ball
Sub coverpanel_Touch (Action As Int, X As Float, Y As Float) As Boolean 'Return True to consume the event
If getcolor(bmp.GetPixel(x,y )) then ...
end sub
Sub getcolor(clr As Int) As Boolean
Dim argb() As Int
argb = GetARGB(clr)
' For black :
If argb(1) < 2 AND _
argb(2) < 2 AND _
argb(3) < 2 Then Return True Else Return False
End Sub
Sub GetARGB(Color As Int) As Int()
Dim res(4) As Int
res(0) = Bit.UnsignedShiftRight(Bit.AND(Color, 0xff000000), 24)
res(1) = Bit.UnsignedShiftRight(Bit.AND(Color, 0xff0000), 16)
res(2) = Bit.UnsignedShiftRight(Bit.AND(Color, 0xff00), 8)
res(3) = Bit.AND(Color, 0xff)
Return res
End Sub
You can have one touch event for the whole panel and then check the color in the x y point. That will work if every piece has a different color.
If it is red - do one thing, if another color - do something else...
For example, the following code checks for black:
B4X:Sub coverpanel_Touch (Action As Int, X As Float, Y As Float) As Boolean 'Return True to consume the event If getcolor(bmp.GetPixel(x,y )) then ... end sub Sub getcolor(clr As Int) As Boolean Dim argb() As Int argb = GetARGB(clr) ' For black : If argb(1) < 2 AND _ argb(2) < 2 AND _ argb(3) < 2 Then Return True Else Return False End Sub Sub GetARGB(Color As Int) As Int() Dim res(4) As Int res(0) = Bit.UnsignedShiftRight(Bit.AND(Color, 0xff000000), 24) res(1) = Bit.UnsignedShiftRight(Bit.AND(Color, 0xff0000), 16) res(2) = Bit.UnsignedShiftRight(Bit.AND(Color, 0xff00), 8) res(3) = Bit.AND(Color, 0xff) Return res End Sub
For each color leave margin for the test to enable some variation in the getpixel function.
Nice Idea. But I would like to keep the image gray in this case and not to color every each slot. Any idea?
not bad.. But I don't know what hotspot is because I never worked with thensimple, you have the image twice.
once with hotspot colors that is hidden and a visible one with the gray colors.
Yep, I did it ... Do you advise me labels for each slot?If the panel width is less then 100%x, you should multiply all the variables by panel.width, to get the ratio correct.
cx and cy should be the values of the center of the panel. R1 and r2 should match the radius accordingly.
Also note that the strokewidth (sw variable) should also be in percentage to meet all kinds of display size.
You can draw text or put labels. If you put labels you cannot make them click because then the panel's touch will not work.Do you advise me labels for each slot?
Looking something like this (attacched):You can draw text or put labels. If you put labels you cannot make them click because then the panel's touch will not work.