I'm trying to use a custom property of type Color, in a canvas, in a drawline code, but am getting a wrong type error...
Do I need to convert the custom property value in some way?
I use the custom color property in several CSS styles by trimming the string returned by the props map and adding a "#" to it...
But the drawline uses a paint as color type, and I don't see how to set it from the custom color property!
The fx.Colors object can create a color from a 32-bit integer. You might try using ByteConverter to convert a CSS color hex string (make sure it represents 32 bits) to an Int.
I did, I converted a small routine that took an Hex string (AARRGGBB) and converted it to Dec (255,255,255,255).
But also found ou that the Hex value returned to the props map, has the Alpha value at the end of the string!
So in order to correctly retrieve the color, I used:
B4X:
Private Sub GetColor(hex As String) As Paint
Dim a,r,g,b As Int
r = Bit.ParseInt(hex.SubString2(2,4), 16)
g = Bit.ParseInt(hex.SubString2(4,6), 16)
b = Bit.ParseInt(hex.SubString2(6,8), 16)
a = Bit.ParseInt(hex.SubString2(8,10), 16)
Return fx.Colors.ARGB(a, r, g, b)
End Sub