renpy/doc/reference/functions/im.MatrixColor - Ren'Py

documentation index ◦ reference manual ◦ function index

# im.MatrixColor

Function: | im.MatrixColor | (im, matrix):

This is an image operator that creates an image by using a matrix to linearly transform the colors in the image im.

matrix should be a list, tuple, or im.matrix that is 20 or 25 elements long. If the object has 25 elements, then elements past the 20th are ignored. If the elements of the matrix are named as follows:

    [ a, b, c, d, e,
      f, g, h, i, j,
      k, l, m, n, o,
      p, q, r, s, t ]

and R, G, B, and A are the red, green, blue, and alpha components of the color, respectively, then the transformed color R', G', B', A' is computed as follows:

    R' = (a * R) + (b * G) + (c * B) + (d * A) + (e * 255)
    G' = (f * R) + (g * G) + (h * B) + (i * A) + (j * 255)
    B' = (k * R) + (l * G) + (m * B) + (n * A) + (o * 255)
    A' = (p * R) + (q * G) + (r * B) + (s * A) + (t * 255)

R', G', B', and A' are clamped to the range [0, 255].

## Example

    init:
        image eileen inverted = im.MatrixColor("eileen_happy.png",
           [ -1,  0,  0, 0, 1,
              0, -1,  0, 0, 1,
              0,  0, -1, 0, 1,
              0,  0,  0, 1, 0, ])

        # Or equivalently:
        image eileen inverted2 = im.MatrixColor("eileen_happy.png",
          im.matrix.invert())

documentation index ◦ reference manual ◦ function index