B4J Question String to color

moore_it

Well-Known Member
Licensed User
Longtime User
Hi all,

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

Thanks
 

moore_it

Well-Known Member
Licensed User
Longtime 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
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime 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)
 
Upvote 0
Top