ComponentTransfer#

Added in version 4.20.

class ComponentTransfer(*args, **kwargs)#

Specifies a transfer function for a color component to be applied while rendering.

The available functions include linear, piecewise-linear, gamma and step functions.

Note that the transfer function is applied to un-premultiplied values, and all results are clamped to the [0, 1] range.

Constructors#

class ComponentTransfer
classmethod new_discrete(values: list[float]) ComponentTransfer#

Creates a new component transfer that applies a step function.

The new value is computed as

C’ = values[k]

where k is the smallest value such that

k / n <= C < (k + 1) / n

https://docs.gtk.org/gsk4/discrete-light.png

Added in version 4.20.

Parameters:

values – Values

classmethod new_gamma(amp: float, exp: float, ofs: float) ComponentTransfer#

Creates a new component transfer that applies a gamma transform.

The new value is computed as

C’ = amp * pow (C, exp) + ofs

https://docs.gtk.org/gsk4/gamma-light.png

Added in version 4.20.

Parameters:
  • amp – Amplitude

  • exp – Exponent

  • ofs – Offset

classmethod new_identity() ComponentTransfer#

Creates a new component transfer that doesn’t change the component value.

https://docs.gtk.org/gsk4/identity-light.png

Added in version 4.20.

classmethod new_levels(n: float) ComponentTransfer#

Creates a new component transfer that limits the values of the component to n levels.

The new value is computed as

C’ = (floor (C * n) + 0.5) / n

https://docs.gtk.org/gsk4/levels-light.png

Added in version 4.20.

Parameters:

n – Number of levels

classmethod new_linear(m: float, b: float) ComponentTransfer#

Creates a new component transfer that applies a linear transform.

The new value is computed as

C’ = C * m + b

https://docs.gtk.org/gsk4/linear-light.png

Added in version 4.20.

Parameters:
  • m – Slope

  • b – Offset

classmethod new_table(values: list[float]) ComponentTransfer#

Creates a new component transfer that applies a piecewise linear function.

The new value is computed as

C’ = values[k] + (C - k / (n - 1)) * n * (values[k + 1] - values[k])

where k is the smallest value such that

k / (n - 1) <= C < (k + 1) / (n - 1)

https://docs.gtk.org/gsk4/table-light.png

Added in version 4.20.

Parameters:

values – Values

Methods#

class ComponentTransfer
classmethod equal(other: Any) bool#

Compares two component transfers for equality.

Added in version 4.20.

Parameters:

other – another component transfer

free() None#

Frees a component transfer.

Added in version 4.20.