Skip to content

@fabwcie/free-drawing / utils/color

utils/color ​

Functions ​

fromDarkColor() ​

fromDarkColor(color): string

Defined in: packages/free-drawing/src/utils/color.ts:50

Color of the drawing shown at a color of the screen in dark mode: inverse of the filter invert(93%) hue-rotate(180deg) of the drawing (see toDarkColor of utils/export), for a color picked on the screen

Parameters

color

string

Color seen on the screen

Returns

string

#rrggbb color of the drawing; a color whose dark color the filter clamps (saturated or pale ones) comes back near it, not exactly


normalizeColor() ​

normalizeColor(color): string

Defined in: packages/free-drawing/src/utils/color.ts:20

Color as canvas normalizes it: #rrggbb when opaque, rgba(...) else (e.g. #000 and black give #000000)

Parameters

color

string

any CSS color

Returns

string

normalized color in lower case (#000000 for an invalid color), the color itself without canvas context


toFill() ​

toFill(color): ColorLike | undefined

Defined in: packages/free-drawing/src/utils/color.ts:11

Konva fill of a background color: none when transparent, so inside is not hit (eraser), as before fill colors

Parameters

color

ColorLike

background color (fillColor option or chosen color)

Returns

ColorLike | undefined

the color, undefined when transparent


toHexColor() ​

toHexColor(color): string | undefined

Defined in: packages/free-drawing/src/utils/color.ts:37

#rrggbb value of an opaque color (color input value), undefined for transparent colors

Parameters

color

string

any CSS color

Returns

string | undefined

lower case #rrggbb color, undefined when not opaque