RGBA128.Parser is a ref struct that helps converting from a string that is representing a color into an actual RGBA128. It is designed to support three modes: HEX, RGB, and HDR. Currently the mode detection and HEX mode are already implemented, but the implementation for RGB and HDR are missing.
RGB mode:
Input string format rgb(123, 456, 789) where 123, 456, and 789 can be any integer between 0 (inclusive) and 256 (exclusive). After the preprocessing that determines the mode, the content field will contain the version with stripped prefix and postfix: 123, 456, 789. Determine the separation between each integer based on the comma , character. Note that there can be optional white spaces between the numbers and the commas. Use the YieldError method if any input error occurs.
HDR mode:
Similar input string format hdr(0.123, 0.456, 0.789) where 0.123, 0.456, and 0.789 can be any decimal larger than or equals to 0 (no upper bound). The content field will also contain the stripped version after preprocessing: 0.123, 0.456, 0.789. Optional white spaces are also allowed.
Implement the ParseRGB and ParseHDR methods in RGBA128.Parser.
RGBA128.Parser
is aref struct
that helps converting from a string that is representing a color into an actualRGBA128
. It is designed to support three modes: HEX, RGB, and HDR. Currently the mode detection and HEX mode are already implemented, but the implementation for RGB and HDR are missing.RGB mode: Input string format
rgb(123, 456, 789)
where123
,456
, and789
can be any integer between 0 (inclusive) and 256 (exclusive). After the preprocessing that determines the mode, thecontent
field will contain the version with stripped prefix and postfix:123, 456, 789
. Determine the separation between each integer based on the comma,
character. Note that there can be optional white spaces between the numbers and the commas. Use theYieldError
method if any input error occurs.HDR mode: Similar input string format
hdr(0.123, 0.456, 0.789)
where0.123
,0.456
, and0.789
can be any decimal larger than or equals to 0 (no upper bound). Thecontent
field will also contain the stripped version after preprocessing:0.123, 0.456, 0.789
. Optional white spaces are also allowed.Implement the
ParseRGB
andParseHDR
methods inRGBA128.Parser
.