mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-06-27 03:11:46 +00:00
Convenience functions for creating matrices
This commit is contained in:
parent
9df413d9be
commit
57bfd19c59
1 changed files with 36 additions and 0 deletions
|
|
@ -18,6 +18,42 @@ def array(*args, dtype=gl.GLfloat):
|
|||
return (dtype * len(args))(*args)
|
||||
|
||||
|
||||
def translation_matrix(x, y):
|
||||
return array(
|
||||
1, 0, x,
|
||||
0, 1, y,
|
||||
0, 0, 1
|
||||
)
|
||||
|
||||
|
||||
def scaling_matrix(x, y):
|
||||
return array(
|
||||
x, 0, 0,
|
||||
0, y, 0,
|
||||
0, 0, 1
|
||||
)
|
||||
|
||||
|
||||
def multiply(a, b):
|
||||
# 0 1 2
|
||||
# 3 4 5
|
||||
# 6 7 8
|
||||
return array(
|
||||
# Row 1
|
||||
a[0] * b[0] + a[1] * b[3] + a[2] * b[6],
|
||||
a[0] * b[1] + a[1] * b[4] + a[2] * b[7],
|
||||
a[0] * b[2] + a[1] * b[5] + a[2] * b[8],
|
||||
# Row 2
|
||||
a[3] * b[0] + a[4] * b[3] + a[5] * b[6],
|
||||
a[3] * b[1] + a[4] * b[4] + a[5] * b[7],
|
||||
a[3] * b[2] + a[4] * b[5] + a[5] * b[8],
|
||||
# Row 3
|
||||
a[6] * b[0] + a[7] * b[3] + a[8] * b[6],
|
||||
a[6] * b[1] + a[7] * b[4] + a[8] * b[7],
|
||||
a[6] * b[2] + a[7] * b[5] + a[8] * b[8]
|
||||
)
|
||||
|
||||
|
||||
class Sprites:
|
||||
''' Maintain sprite sheets of all rendered characters on the GPU as a texture
|
||||
array with each texture being a sprite sheet. '''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue