RenderColor¶
Overview¶
RenderColor displays a single solid color everywhere, and is a basic building-block for many other RenderPrograms.
@author Jonathan Olson <jonathan.olson@colorado.edu>
Class RenderColor¶
Constructor¶
new RenderColor( color : Vector4 )¶
Instance Methods¶
getName() : string¶
withChildren( children : RenderProgram[] ) : RenderColor¶
equalsTyped( other : this ) : boolean¶
(protected)
evaluate( context : RenderEvaluationContext ) : Vector4¶
writeInstructions( instructions : RenderInstruction[] )¶
getExtraDebugString() : string¶
(protected)
serialize() : SerializedRenderColor¶
Static Methods¶
applyProgram( vector : Vector4, color : Vector4 )¶
sRGBToLinear( sRGB : Vector4 ) : Vector4¶
linearToSRGB( linear : Vector4 ) : Vector4¶
linearToOklab( linear : Vector4 ) : Vector4¶
Oklab is a perceptually uniform color space, which is useful for color blending. https://bottosson.github.io/posts/oklab/ returned as (L,a,b,alpha)
oklabToLinear( oklab : Vector4 ) : Vector4¶
multiplyMatrixTimesColor( matrix : Matrix3, color : Vector4 ) : Vector4¶
linearToLinearDisplayP3( color : Vector4 ) : Vector4¶
linearDisplayP3ToLinear( color : Vector4 ) : Vector4¶
linearDisplayP3ToDisplayP3( linear : Vector4 ) : Vector4¶
displayP3ToLinearDisplayP3( displayP3 : Vector4 ) : Vector4¶
oklabToOklch( oklab : Vector4 ) : Vector4¶
A radian-based oklch?
oklchToOklab( oklch : Vector4 ) : Vector4¶
A radian-based oklch
linearToOklch( linear : Vector4 ) : Vector4¶
oklchToLinear( oklch : Vector4 ) : Vector4¶
TODO: consistent "linear" naming? (means linear SRGB here)
linearDisplayP3ToOklch( linear : Vector4 ) : Vector4¶
oklchToLinearDisplayP3( oklch : Vector4 ) : Vector4¶
convert( color : Vector4, fromSpace : RenderColorSpace, toSpace : RenderColorSpace ) : Vector4¶
isColorInRange( color : Vector4 ) : boolean¶
ONLY remaps the r,g,b parts, not alpha
gamutMapColor( color : Vector4, toOklab : ( c: Vector4 ) => Vector4, fromOklab : ( c: Vector4 ) => Vector4 ) : Vector4¶
Relative colorimetric mapping. We could add more of a perceptual intent, but this is a good start.
Modeled after https://drafts.csswg.org/css-color-4/#binsearch
gamutMapLinearSRGB( color : Vector4 ) : Vector4¶
gamutMapLinearDisplayP3( color : Vector4 ) : Vector4¶
gamutMapSRGB( color : Vector4 ) : Vector4¶
gamutMapDisplayP3( color : Vector4 ) : Vector4¶
gamutMapPremultipliedSRGB( color : Vector4 ) : Vector4¶
OUTPUTS unpremultiplied sRGB, with a valid alpha value
gamutMapPremultipliedDisplayP3( color : Vector4 ) : Vector4¶
OUTPUTS unpremultiplied Display P3, with a valid alpha value
oklabToLinearDisplayP3( oklab : Vector4 ) : Vector4¶
linearDisplayP3ToOklab( linearP3 : Vector4 ) : Vector4¶
premultiply( color : Vector4 ) : Vector4¶
unpremultiply( color : Vector4 ) : Vector4¶
xyYToXYZ( xyY : Vector3 ) : Vector3¶
xyToXYZ( xy : Vector2 ) : Vector3¶
xyzToLinear( xyz : Vector4 ) : Vector4¶
linearToXYZ( linear : Vector4 ) : Vector4¶
getMatrixRGBToXYZ( redChromaticity : Vector2, greenChromaticity : Vector2, blueChromaticity : Vector2, whiteChromaticity : Vector2 ) : Matrix3¶
canvasSupportsDisplayP3() : boolean¶
ratioBlend( zeroColor : Vector4, oneColor : Vector4, ratio : number ) : Vector4¶
deserialize( obj : SerializedRenderColor ) : RenderColor¶
Static Properties¶
sRGBToXYZMatrix¶
XYZTosRGBMatrix¶
displayP3ToXYZMatrix¶
XYZToDisplayP3Matrix¶
sRGBToDisplayP3Matrix¶
displayP3TosRGBMatrix¶
TRANSPARENT : RenderColor¶
(readonly)
Type SerializedRenderColor¶
- type: "RenderColor"
- color:
- r: number
- g: number
- b: number
- a: number
Source Code¶
See the source for RenderColor.ts in the alpenglow repository.