getColor method

Color getColor(
  1. String name
)

Effective value of a vec4 parameter as a Color, the assigned value if set, otherwise the sidecar default. For a source_color-hinted parameter the rgb channels are sRGB-encoded back from the stored linear value, the inverse of setColor; alpha is read as-is. A non-source_color parameter reads its raw channels unencoded. Throws on an unknown name or wrong type.

Implementation

Color getColor(String name) {
  final slot = _slot(name, FmatType.vec4);
  final f = _readFloats(slot.offsetBytes, 4);
  var r = f[0], g = f[1], b = f[2];
  if (slot.sourceColor) {
    r = _linearToSrgb(r);
    g = _linearToSrgb(g);
    b = _linearToSrgb(b);
  }
  return Color.from(alpha: f[3], red: r, green: g, blue: b);
}