ColorSpace

sealed class ColorSpace

Colour-space resolution + sample-to-RGB conversion (ISO 32000-1 §8.6).

Supported families:

  • DeviceGray / DeviceRGB / DeviceCMYK (the device families)

  • Indexed (palette lookup; base is one of the device families)

  • ICCBased — falls back to DeviceRGB / DeviceCMYK / DeviceGray based on /N component count (the ICC profile is not applied).

  • CalGray, CalRGB, Lab — treated as their device equivalent (no gamma / whitepoint correction); good enough for visual approximation.

Not yet handled: DeviceN, Separation, Pattern. Those degrade to grey for stroke / fill operands.

Conversion always lands in RgbColor for the renderer; sRGB component values 0..1. Out-of-gamut colours are clamped, never thrown.

Inheritors

Types

Link copied to clipboard
object Companion
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
class Indexed(val base: ColorSpace, val hival: Int, val palette: ByteArray) : ColorSpace

Indexed colour space. Each sample is a single byte 0..hival that indexes into palette; the palette stores base.componentCount bytes per entry.

Link copied to clipboard
class Unsupported(val name: String, val componentCount: Int) : ColorSpace

Fallback for spaces we don't fully model. Routes to grey.

Properties

Link copied to clipboard
abstract val componentCount: Int

Number of input components (1 for Gray, 3 for RGB/Lab, 4 for CMYK).

Functions

Link copied to clipboard

Default fill colour at "the colour space is set to me" — black-equivalent.

Link copied to clipboard
abstract fun toRgb(components: DoubleArray): RgbColor

Convert a sample (one float per component, all in 0,1) to RGB.