LinearColor

data class LinearColor(val r: Float, val g: Float, val b: Float)

An RGB color (linear or sRGB depending on the consuming API). Distinct from the spatial vectors so a LinearColor can't be passed as a Position. Components are r/g/b.

Deliberately not called Color: androidx.compose.ui.graphics.Color is in scope in practically every file that uses this library, and two same-named colour types with different transfer functions is a trap.

Interop with Compose UI colours goes through fromComposeColor / toComposeColor, which apply the sRGB transfer function in each direction — Compose colours are gamma-encoded, so copying their components across raw would wash the result out. Alpha is dropped; scene colours are RGB.

val tint = LinearColor.fromComposeColor(MaterialTheme.colorScheme.primary)

Constructors

Link copied to clipboard
constructor(r: Float, g: Float, b: Float)
constructor(v: Float)

Uniform value on all channels (grey).

constructor(v: Float3)

From a filament-utils Float3 (x→r, y→g, z→b), assumed already linear.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val b: Float
Link copied to clipboard
val g: Float
Link copied to clipboard
val r: Float

Functions

Link copied to clipboard
operator fun plus(o: LinearColor): LinearColor
Link copied to clipboard
operator fun times(s: Float): LinearColor
Link copied to clipboard

As a gamma-encoded Compose UI colour (alpha 1), for feeding a scene colour back into Compose UI. Channels are clamped to 0..1 — over-bright values lose their headroom.

Link copied to clipboard