B4J Question String to color

moore_it

Active Member
Licensed User
Hi all,

it's possible to transform a string (es.: rgba(255,255,255,1.00)) to a color ?

Thanks
 

moore_it

Active Member
Licensed User
Found

B4X:
FromStringToColor(CSSUtils.GetStyleProperty(p,"-fx-background-color"))

Sub FromStringToColor(c As String)
    Log(c)
    Dim c1 As String = c.SubString2(5,16)
    oldcolor =  Regex.Split(",",c1)
End Sub
 

Daestrum

Well-Known Member
Licensed User
B4X:
 Dim st As String = "rgba(255,128,255,1.0)"
 Dim cArgs(4) As Object = Regex.Split(",",st.SubString2(st.IndexOf("(")+1,st.IndexOf(")")))
 Dim c As Paint = fx.Colors.ARGB(cArgs(3)*255,cArgs(0),cArgs(1),cArgs(2))
 Log(c)
 
Top