-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLyricsAnimation.py
62 lines (48 loc) · 1.88 KB
/
LyricsAnimation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from gtk.gdk import Rectangle
from LyricsPanel import LyricsPanel
class LyricsAnimation(LyricsPanel):
def __init__(self):
LyricsPanel.__init__(self)
#"""
def drawComponent(self, ctx):
if self.layout == None:
self.layout = ctx.create_layout()
self.setAlignment()
self.layout.set_font_description(self.font)
if self.lyrics_need_update:
self.updateLyrics()
self.clipBounds = Rectangle(*ctx.clip_extents())
if self.anim_fraction == 1.0:
self.anim_fraction = 0.0
self.textForAnimation = None
self.actualLine += 1
if self.lyrics != None and self.actualLine < len(self.lyrics.entities):
print self.anim_fraction
center_y = 60
ctx.translate(0, center_y)
if self.actualLine > 0:
ctx.set_source_rgba(*self.color_normal)
ctx.translate(0, -self.lyrics.entities[self.actualLine-1].height)
#if self.anim_fraction > 0:
ctx.save()
ctx.translate(-200*self.anim_fraction, 0)
self.drawScaledLyric(ctx, self.lyrics.entities[self.actualLine-1])
ctx.restore()
ctx.translate(0, self.lyrics.entities[self.actualLine-1].height)
ctx.set_source_rgba(*self.color_highlight)
ctx.translate((self.anim_fraction)*200, 0)
self.drawScaledLyric(ctx, self.lyrics.entities[self.actualLine])
ctx.translate(-self.anim_fraction*200, 0)
if self.actualLine+1 < len(self.lyrics.entities):
if self.anim_fraction > 0:
ctx.save()
ctx.translate((1-self.anim_fraction)*-200, 0)
self.drawScaledLyric(ctx, self.lyrics.entities[self.actualLine+1])
ctx.restore()
ctx.translate(0, max(self.lyrics.entities[self.actualLine].height, self.lyrics.entities[self.actualLine+1].height))
ctx.set_source_rgba(*self.color_normal)
if self.anim_fraction > 0:
ctx.translate(-200*self.anim_fraction, 0)
self.drawScaledLyric(ctx, self.lyrics.entities[self.actualLine+1])
#self.layout.set_text("")
#"""