vmath.pyi 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. from typing import overload, Iterator
  2. class _vecF[T]:
  3. ONE: T
  4. ZERO: T
  5. def __add__(self, other: T) -> T: ...
  6. def __sub__(self, other: T) -> T: ...
  7. @overload
  8. def __mul__(self, other: float) -> T: ...
  9. @overload
  10. def __mul__(self, other: T) -> T: ...
  11. def __truediv__(self, other: float) -> T: ...
  12. def dot(self, other: T) -> float: ...
  13. def length(self) -> float: ...
  14. def length_squared(self) -> float: ...
  15. def normalize(self) -> T: ...
  16. # dummy iter for unpacking
  17. def __iter__(self) -> Iterator[float]: ...
  18. class _vecI[T]:
  19. ONE: T
  20. ZERO: T
  21. def __add__(self, other: T) -> T: ...
  22. def __sub__(self, other: T) -> T: ...
  23. @overload
  24. def __mul__(self, other: int) -> T: ...
  25. @overload
  26. def __mul__(self, other: T) -> T: ...
  27. def __floordiv__(self, other: int) -> T: ...
  28. def __mod__(self, other: int) -> T: ...
  29. def __hash__(self) -> int: ...
  30. def dot(self, other: T) -> int: ...
  31. # dummy iter for unpacking
  32. def __iter__(self) -> Iterator[int]: ...
  33. class vec2(_vecF['vec2']):
  34. LEFT: vec2
  35. RIGHT: vec2
  36. UP: vec2
  37. DOWN: vec2
  38. @property
  39. def x(self) -> float: ...
  40. @property
  41. def y(self) -> float: ...
  42. def with_x(self, x: float) -> vec2: ...
  43. def with_y(self, y: float) -> vec2: ...
  44. def with_z(self, z: float) -> vec3: ...
  45. @overload
  46. def __init__(self, x: float, y: float) -> None: ...
  47. @overload
  48. def __init__(self, xy: vec2i) -> None: ...
  49. def rotate(self, radians: float) -> vec2:
  50. """Rotate the vector by `radians`.
  51. + If y axis is top to bottom, positive value means clockwise (default)
  52. + If y axis is bottom to top, positive value means counter-clockwise
  53. """
  54. @staticmethod
  55. def angle(__from: vec2, __to: vec2) -> float:
  56. """Return the angle in radians between vectors `from` and `to`.
  57. The result range is `[-pi, pi]`.
  58. + If y axis is top to bottom, positive value means clockwise (default)
  59. + If y axis is bottom to top, positive value means counter-clockwise
  60. """
  61. @staticmethod
  62. def smooth_damp(current: vec2, target: vec2, current_velocity: vec2, smooth_time: float, max_speed: float, delta_time: float) -> tuple[vec2, vec2]:
  63. """Smoothly change a vector towards a desired goal over time.
  64. Returns a new value that is closer to the target and current velocity.
  65. """
  66. class mat3x3:
  67. def __init__(self, _11, _12, _13, _21, _22, _23, _31, _32, _33) -> None: ...
  68. def __getitem__(self, index: tuple[int, int]) -> float: ...
  69. def __setitem__(self, index: tuple[int, int], value: float) -> None: ...
  70. @overload
  71. def __matmul__(self, other: mat3x3) -> mat3x3: ...
  72. @overload
  73. def __matmul__(self, other: vec3) -> vec3: ...
  74. def __invert__(self) -> mat3x3: ...
  75. def matmul(self, other: mat3x3, out: mat3x3) -> mat3x3 | None: ...
  76. def determinant(self) -> float: ...
  77. def copy(self) -> mat3x3: ...
  78. def inverse(self) -> mat3x3: ...
  79. def copy_(self, other: mat3x3) -> None: ...
  80. def inverse_(self) -> None: ...
  81. @staticmethod
  82. def zeros() -> mat3x3: ...
  83. @staticmethod
  84. def identity() -> mat3x3: ...
  85. # affine transformations
  86. @staticmethod
  87. def trs(t: vec2, r: float, s: vec2) -> mat3x3: ...
  88. def copy_trs_(self, t: vec2, r: float, s: vec2) -> None: ...
  89. def t(self) -> vec2: ...
  90. def r(self) -> float: ...
  91. def s(self) -> vec2: ...
  92. def transform_point(self, p: vec2) -> vec2: ...
  93. def transform_vector(self, v: vec2) -> vec2: ...
  94. class vec2i(_vecI['vec2i']):
  95. LEFT: vec2i
  96. RIGHT: vec2i
  97. UP: vec2i
  98. DOWN: vec2i
  99. @property
  100. def x(self) -> int: ...
  101. @property
  102. def y(self) -> int: ...
  103. def with_x(self, x: int) -> vec2i: ...
  104. def with_y(self, y: int) -> vec2i: ...
  105. def __init__(self, x: int, y: int) -> None: ...
  106. class vec3i(_vecI['vec3i']):
  107. @property
  108. def x(self) -> int: ...
  109. @property
  110. def y(self) -> int: ...
  111. @property
  112. def z(self) -> int: ...
  113. def with_x(self, x: int) -> vec3i: ...
  114. def with_y(self, y: int) -> vec3i: ...
  115. def with_z(self, z: int) -> vec3i: ...
  116. def __init__(self, x: int, y: int, z: int) -> None: ...
  117. class vec4i(_vecI['vec4i']):
  118. @property
  119. def x(self) -> int: ...
  120. @property
  121. def y(self) -> int: ...
  122. @property
  123. def z(self) -> int: ...
  124. @property
  125. def w(self) -> int: ...
  126. def with_x(self, x: int) -> vec4i: ...
  127. def with_y(self, y: int) -> vec4i: ...
  128. def with_z(self, z: int) -> vec4i: ...
  129. def with_w(self, w: int) -> vec4i: ...
  130. def __init__(self, x: int, y: int, z: int, w: int) -> None: ...
  131. class vec3(_vecF['vec3']):
  132. @property
  133. def x(self) -> float: ...
  134. @property
  135. def y(self) -> float: ...
  136. @property
  137. def z(self) -> float: ...
  138. @property
  139. def xy(self) -> vec2: ...
  140. def with_x(self, x: float) -> vec3: ...
  141. def with_y(self, y: float) -> vec3: ...
  142. def with_z(self, z: float) -> vec3: ...
  143. def with_xy(self, xy: vec2) -> vec3: ...
  144. @overload
  145. def __init__(self, x: float, y: float, z: float) -> None: ...
  146. @overload
  147. def __init__(self, xyz: vec3i) -> None: ...
  148. # Color32
  149. class color32:
  150. def __new__(cls, r: int, g: int, b: int, a: int) -> 'color32': ...
  151. def __eq__(self, other: object) -> bool: ...
  152. def __ne__(self, other: object) -> bool: ...
  153. def __repr__(self) -> str: ...
  154. def __hash__(self) -> int: ...
  155. @property
  156. def r(self) -> int: ...
  157. @property
  158. def g(self) -> int: ...
  159. @property
  160. def b(self) -> int: ...
  161. @property
  162. def a(self) -> int: ...
  163. def with_r(self, r: int) -> 'color32': ...
  164. def with_g(self, g: int) -> 'color32': ...
  165. def with_b(self, b: int) -> 'color32': ...
  166. def with_a(self, a: int) -> 'color32': ...
  167. @staticmethod
  168. def from_hex(hex: str) -> 'color32': ...
  169. @staticmethod
  170. def from_vec3(vec: vec3) -> 'color32': ...
  171. @staticmethod
  172. def from_vec3i(vec: vec3i) -> 'color32': ...
  173. def to_hex(self) -> str: ...
  174. def to_vec3(self) -> vec3: ...
  175. def to_vec3i(self) -> vec3i: ...
  176. def to_rgb565(self) -> int: ...
  177. def ansi_fg(self, text: str) -> str: ...
  178. def ansi_bg(self, text: str) -> str: ...
  179. @staticmethod
  180. def alpha_blend(src: color32, dst: color32 | None) -> color32: ...
  181. def rgb(r: int, g: int, b: int) -> color32: ...
  182. def rgba(r: int, g: int, b: int, a: float) -> color32: ...