This page is out of date

You've reached a page on the Ren'Py wiki. Due to massive spam, the wiki hasn't been updated in over 5 years, and much of the information here is very out of date. We've kept it because some of it is of historic interest, but all the information relevant to modern versions of Ren'Py has been moved elsewhere.

Some places to look are:

Please do not create new links to this page.


im.matrix

Constructs an im.matrix object from the given matrix. im.matrix objects represent 5x5 matrices, and support a number of mathematical operations. The operations supported are matrix multiplication, scalar multiplication, element-wise addition, and element-wise subtraction. These operations are invoked using the standard mathematical operators (*, *, +, and -), respectively. If two im.matrix objects are multiplied, matrix multiplication is performed, otherwise scalar multiplication is used.

matrix is a 20 or 25 element list. If the list is 20 elements long, it is padded with [0, 0, 0, 0, 1 ] to make a 5x5 matrix, suitable for multiplication.

Example

# This matrix raises the brightness by 10%.
$ brightness = im.matrix([ 1, 0, 0, 0, .1,
                           0, 1, 0, 0, .1,
                           0, 0, 1, 0, .1,
                           0, 0, 0, 1, 0 ])

# This matrix halves the opacity.
$ opacity = im.matrix([ 1, 0, 0, 0, 0,
                        0, 1, 0, 0, 0,
                        0, 0, 1, 0, 0,
                        0, 0, 0, .5, 0 ])

# We can multiply them together, to get a matrix that modifies brightness and opacity.
$ brightness_opacity = brightness * opacity

# And supply that to im.MatrixColor.
image eileen altered = im.MatrixColor("eileen_happy.png", brightness_opacity)