Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to fix #2591 #2621

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion renpy/atl.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ def interpolate(t, a, b, type): # @ReservedAssignment
elif callable(b):
a_origin = getattr(a, "origin", None)
rv = b(a_origin, t)
rv.origin = b
if hasattr(b, "get_origin"):
rv.origin = b.get_origin(a_origin, t)
else:
rv.origin = b
return rv

# Interpolate everything else.
Expand Down
52 changes: 52 additions & 0 deletions renpy/common/00matrixcolor.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# This contains ColorMatrix and the various *Matrix classes.

init -1500 python:
import copy as _copy
import math as _math

class ColorMatrix(object):
Expand All @@ -43,6 +44,14 @@ init -1500 python:
value = other.value + (self.value - other.value) * done
return self.get(value)

def get_origin(self, other, done):
if type(other) is not type(self):
return self

rv = _copy.copy(self)
rv.value = other.value + (self.value - other.value) * done
return rv

def __mul__(self, other):
return _MultiplyMatrix(self, other)

Expand Down Expand Up @@ -73,6 +82,15 @@ init -1500 python:

return self.left(other.left, done) * self.right(other.right, done)

def get_origin(self, other, done):
if type(other) is not type(self):
return self

rv = _copy.copy(self)
rv.left = self.left.get_origin(other.left, done)
rv.right = self.right.get_origin(other.right, done)
return rv


class IdentityMatrix(ColorMatrix):
"""
Expand Down Expand Up @@ -182,6 +200,19 @@ init -1500 python:
0, 0, b, 0,
0, 0, 0, a ])

def get_origin(self, other, done):
if type(other) is not type(self):
return self

oldr, oldg, oldb = other.color.rgb
olda = other.color.alpha
r, g, b = self.color.rgb
a = self.color.alpha

rv = _copy.copy(self)
rv.color = Color(rgb=(oldr + (r - oldr) * done, oldg + (g - oldg) * done, oldb + (b - oldb) * done), alpha=olda + (a - olda) * done)
return rv

class BrightnessMatrix(ColorMatrix):
"""
:doc: colormatrix
Expand Down Expand Up @@ -308,6 +339,27 @@ init -1500 python:
0, 0, (wb - bb), bb,
0, 0, 0, 1, ])

def get_origin(self, other, done):
if type(other) is not type(self):
return self

obr, obg, obb = other.black.rgb
owr, owg, owb = other.white.rgb
nbr, nbg, nbb = self.black.rgb
nwr, nwg, nwb = self.white.rgb

br = obr + (nbr - obr) * done
bg = obg + (nbg - obg) * done
bb = obb + (nbb - obb) * done
wr = owr + (nwr - owr) * done
wg = owg + (nwg - owg) * done
wb = owb + (nwb - owb) * done

rv = _copy.copy(self)
rv.black = Color(rgb=(br, bg, bb))
rv.white = Color(rgb=(wr, wg, wb))
return rv


class HueMatrix(ColorMatrix):
"""
Expand Down