memononen / nanosvg

Simple stupid SVG parser
zlib License
1.71k stars 363 forks source link

Loss of precision in nsvg__parseColorRGB() #114

Open martinlindhe opened 6 years ago

martinlindhe commented 6 years ago

Consider the following input:

rgb(39.2%, 58.4%, 92.9%)

The nsvg__parseColorRGB() function parses the numbers to integers, thus loosing precision when converting % values into an absolute color at https://github.com/memononen/nanosvg/blob/47697e1414dd2aaf59d4df61edb70f36058069f1/src/nanosvg.h#L1222-L1226

SergeySlice commented 6 years ago

SVG specification assumes high precision, probably RGB16. But in real life you may use RGB8 thus values in 0..255. Well percentage must be float to differ 199(78.0%), 200 (78.4%) and 201 (78.8%)

Who is maintainer of the project? How to tell with him?