Added more anim equations in pygauge class, changed gauge anim equation from OUT_QUAD to OUT_QUART

This commit is contained in:
HomeWorld
2010-10-10 22:31:19 +03:00
parent 7105c23277
commit 4278b602c3
2 changed files with 56 additions and 5 deletions

View File

@@ -29,6 +29,8 @@ class ResistancesViewFull(StatsView):
def __init__(self, parent):
StatsView.__init__(self)
self.parent = parent
self._cachedValues = []
def getHeaderText(self, fit):
return "Resistances"
@@ -114,7 +116,7 @@ class ResistancesViewFull(StatsView):
lbl.SetBarGradient()
lbl.SetFractionDigits(1)
setattr(self, "labelResistance%s%s" % (tankType.capitalize(), damageType.capitalize()), lbl)
setattr(self, "gaugeResistance%s%s" % (tankType.capitalize(), damageType.capitalize()), lbl)
box.Add(lbl, 0, wx.ALIGN_CENTER)
col+=1
@@ -144,7 +146,7 @@ class ResistancesViewFull(StatsView):
else:
resonance = 0
lbl = getattr(self, "labelResistance%s%s" % (tankType.capitalize(), damageType.capitalize()))
lbl = getattr(self, "gaugeResistance%s%s" % (tankType.capitalize(), damageType.capitalize()))
lbl.SetValue(resonance)
@@ -165,7 +167,7 @@ class ResistancesViewFull(StatsView):
damagePattern = fit.damagePattern if fit is not None else None
for damageType in ("em", "thermal", "kinetic", "explosive"):
lbl = getattr(self, "labelResistanceDamagepattern%s" % damageType.capitalize())
lbl = getattr(self, "gaugeResistanceDamagepattern%s" % damageType.capitalize())
if damagePattern is not None:
lbl.SetValue(getattr(damagePattern, "%sAmount" % damageType))
else:

View File

@@ -13,6 +13,7 @@ It uses the easeOutQuad equation from caurina.transitions.Tweener to do the anim
import wx
import copy
import math
class PyGauge(wx.PyWindow):
"""
@@ -54,7 +55,7 @@ class PyGauge(wx.PyWindow):
self._animDuration = 600
self._animStep = 0
self._period = 25
self._period = 10
self._animValue = 0
@@ -341,6 +342,41 @@ class PyGauge(wx.PyWindow):
formatStr = "{0:." + str(self._fractionDigits) + "f}%"
dc.DrawLabel(formatStr.format(value), rect, wx.ALIGN_CENTER)
def OUT_CIRC (self, t, b, c, d):
t=float(t)
b=float(b)
c=float(c)
d=float(d)
t = t/d -1
return c * math.sqrt(1 - t*t) + b;
def OUT_QUART(self, t, b, c, d):
t=float(t)
b=float(b)
c=float(c)
d=float(d)
t = t/d -1
return -c * ((t)*t*t*t - 1) + b;
def INOUT_CIRC(self, t, b, c, d):
t=float(t)
b=float(b)
c=float(c)
d=float(d)
t1 = t / (d / 2)
if ((t / (d/2)) < 1):
return -c/2 * (math.sqrt(1 - (t/(d/2))**2) - 1) + b
return c/2 * (math.sqrt(1 - (t1-2)**2) + 1) + b;
def IN_CUBIC (self, t, b, c, d):
t=float(t)
b=float(b)
c=float(c)
d=float(d)
t = t/d
return c*t*t*t + b
def OUT_QUAD (self, t, b, c, d):
t=float(t)
b=float(b)
@@ -373,6 +409,19 @@ class PyGauge(wx.PyWindow):
t-=(2.625/2.75)
return c*(7.5625*(t)*t + .984375) + b
def INOUT_EXP(self, t, b, c, d):
t=float(t)
b=float(b)
c=float(c)
d=float(d)
t1 = t / (d/2)
if t==0:
return b
if t==d:
return b+c
if (t1) < 1:
return c/2 * math.pow(2, 10 * (t1 - 1)) + b - c * 0.0005
return c/2 * 1.0005 * (-math.pow(2, -10 * (t1-1)) + 2) + b
def OnTimer(self,event):
@@ -393,7 +442,7 @@ class PyGauge(wx.PyWindow):
start = 0
end = oldValue - value
step=self.OUT_QUAD(self._animStep, start, end, self._animDuration)
step=self.OUT_QUART(self._animStep, start, end, self._animDuration)
self._animStep += self._period
if self._timerId == event.GetId():