Mercurial > touhou
comparison pytouhou/ui/sdl/sprite.pyx @ 525:43ecf0f98f4d
Precalculate the inverse of the texture size at ANM load, to not recalculate at every sprite change.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 18 Dec 2013 18:15:45 +0100 |
parents | 3d4410de78e1 |
children | db28538cd399 |
comparison
equal
deleted
inserted
replaced
524:7f016dfbdfb1 | 525:43ecf0f98f4d |
---|---|
41 y += sprite.dest_offset[1] | 41 y += sprite.dest_offset[1] |
42 if not sprite.corner_relative_placement: # Reposition | 42 if not sprite.corner_relative_placement: # Reposition |
43 x -= width / 2 | 43 x -= width / 2 |
44 y -= height / 2 | 44 y -= height / 2 |
45 | 45 |
46 size = sprite.anm.size | 46 x_1 = sprite.anm.size_inv[0] |
47 x_1 = 1 / <double>size[0] | 47 y_1 = sprite.anm.size_inv[1] |
48 y_1 = 1 / <double>size[1] | |
49 tox, toy = sprite.texoffsets | 48 tox, toy = sprite.texoffsets |
50 uvs = (tx * x_1 + tox, | 49 uvs = (tx * x_1 + tox, |
51 (tx + tw) * x_1 + tox, | 50 (tx + tw) * x_1 + tox, |
52 ty * y_1 + toy, | 51 ty * y_1 + toy, |
53 (ty + th) * y_1 + toy) | 52 (ty + th) * y_1 + toy) |