Skip to content

Commit

Permalink
Fixed scaling with the replace effect.
Browse files Browse the repository at this point in the history
  • Loading branch information
erodozer committed Nov 15, 2010
1 parent 0d157a5 commit 223fc31
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion data/themes/MegaLight V4/rockmeter.ini
Expand Up @@ -48,7 +48,7 @@ xpos = 620
ypos = .75
rect = (1.0 - (streak%10/10.0), 1, .2 + .2*(streak/10), .4 + .2*(streak/10))
alignment = right
condition = streak <= streakMax
condition = streak > 0
inPixels = xpos

[layer6:fx0:Replace]
Expand Down
23 changes: 23 additions & 0 deletions src/Rockmeter.py
Expand Up @@ -441,6 +441,28 @@ def __init__(self, layer, section):

self.conditions = self.get("condition", str, "True").split("|")

#fixes the scale after the rect is changed
def fixScale(self):
w, h, = self.layer.engine.view.geometry[2:4]

rect = self.layer.rect
scale = [eval(self.layer.get("xscale", str, "0.5")),
eval(self.layer.get("yscale", str, "0.5"))]
scale[0] *= (rect[1] - rect[0])
scale[1] *= (rect[3] - rect[2])
#this allows you to scale images in relation to pixels instead
#of percentage of the size of the image.
if "xscale" in self.layer.inPixels:
scale[0] /= self.layer.texture.pixelSize[0]
if "yscale" in self.layer.inPixels:
scale[1] /= self.layer.texture.pixelSize[1]

scale[1] = -scale[1]
scale[0] *= w/640.0
scale[1] *= h/480.0

self.layer.scale = scale

def update(self):

if self.type == "font":
Expand All @@ -456,6 +478,7 @@ def update(self):
self.layer.drawing = self.drawings[i]
if len(self.rects) > 1:
self.layer.rect = self.rects[i]
self.fixScale()
break

class Rockmeter:
Expand Down

0 comments on commit 223fc31

Please sign in to comment.