Description
The Color class methods for parsing and serializing color values could benefit from memoization to avoid redundant computation:
Parsing (cache by input):
parseRGB() — parses "rgb(...)" / "rgba(...)" strings
parseHex() — parses "#RRGGBB" / "#RRGGBBAA" hex strings
Serialization (cache by r,g,b,a state, invalidate on change):
toHex() — returns "#RRGGBB"
toHex8() — returns "#RRGGBBAA"
toRGB() — returns "rgb(R,G,B)"
toRGBA() — returns "rgba(R,G,B,A)"
For serialization, the cache should be invalidated whenever r, g, b, or a values change (e.g. via setColor, parseHex, etc.).
Context
These were tracked as inline TODO comments in src/math/color.ts. Moved to a ticket for better visibility and tracking.
Description
The
Colorclass methods for parsing and serializing color values could benefit from memoization to avoid redundant computation:Parsing (cache by input):
parseRGB()— parses "rgb(...)" / "rgba(...)" stringsparseHex()— parses "#RRGGBB" / "#RRGGBBAA" hex stringsSerialization (cache by r,g,b,a state, invalidate on change):
toHex()— returns "#RRGGBB"toHex8()— returns "#RRGGBBAA"toRGB()— returns "rgb(R,G,B)"toRGBA()— returns "rgba(R,G,B,A)"For serialization, the cache should be invalidated whenever r, g, b, or a values change (e.g. via
setColor,parseHex, etc.).Context
These were tracked as inline TODO comments in
src/math/color.ts. Moved to a ticket for better visibility and tracking.