AngleSharp / AngleSharp.Css

:angel: Library to enable support for cascading stylesheets in AngleSharp.

Home Page:https://anglesharp.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parsing color after get computed style

kamekjay opened this issue · comments

Hi! I'm working on a project in Unity (2021.3.16) android/ios.

I'm successfully using a getcomputedstyle for this HTML

<span style="color:#ff973d"><span style="font-size: 18pt; font-family: Roboto; font-weight: normal; background-color: transparent; vertical-align: baseline; text-decoration: none;">ASDASDA</span>
</span>

On the editor side when I do GetPropertyValue "color" it returns rgba(255, 151, 61, 1) which is correct, but when I execute the same on an android device it returns rgba(0, 0, 0, 0.24).

Is there a way to get the color value in hex not converted in rgba from the get computed style?

thanks

HEX and RGBA are just two possible string representations - what you actually want/should look for is the Color struct, which is part of AngleSharp's CSSOM.

Regarding the different values I cannot help you much. From AngleSharp.Css's perspective the platform (editor / Android) is the same, so something else might be different. My guess is that the shown HTML is only a fragment and that the full HTML is derived on the respective platform - their underlying codes might be different.

Hi Florian, sadly the HTML in the post is the only input so is not a part. I'm parsing the exact same string. I'll give it a shot looking for the struct. What makes me think is that the same hex is parsed in a different way depending on the platform, and the one executed in editor is correct. rgba(0, 0, 0, 0.24) is a value that I cannot even think where it came from.
I'll get back you you asap
Thanks

Hi again @FlorianRappl .
Sadly I cannot find how to get the struct. The things I have are the computed style of the entire HTML and the IElement / INode that contains the style. There is a way to get the dictionary of the attributes parsed in the style attribute? Or there is a way to parse the style attribute with the raw data?
If I do GetStyle from the element, obviously I get the same error in the color conversion.

Thank you again