sonolus.py 0.3.3__py3-none-any.whl → 0.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of sonolus.py might be problematic. Click here for more details.

Files changed (66) hide show
  1. sonolus/backend/excepthook.py +30 -0
  2. sonolus/backend/finalize.py +15 -1
  3. sonolus/backend/ops.py +4 -0
  4. sonolus/backend/optimize/allocate.py +5 -5
  5. sonolus/backend/optimize/constant_evaluation.py +124 -19
  6. sonolus/backend/optimize/copy_coalesce.py +15 -12
  7. sonolus/backend/optimize/dead_code.py +7 -6
  8. sonolus/backend/optimize/dominance.py +2 -2
  9. sonolus/backend/optimize/flow.py +54 -8
  10. sonolus/backend/optimize/inlining.py +137 -30
  11. sonolus/backend/optimize/liveness.py +2 -2
  12. sonolus/backend/optimize/optimize.py +15 -1
  13. sonolus/backend/optimize/passes.py +11 -3
  14. sonolus/backend/optimize/simplify.py +137 -8
  15. sonolus/backend/optimize/ssa.py +47 -13
  16. sonolus/backend/place.py +5 -4
  17. sonolus/backend/utils.py +24 -0
  18. sonolus/backend/visitor.py +260 -17
  19. sonolus/build/cli.py +47 -19
  20. sonolus/build/compile.py +12 -5
  21. sonolus/build/engine.py +70 -1
  22. sonolus/build/level.py +3 -3
  23. sonolus/build/project.py +2 -2
  24. sonolus/script/archetype.py +27 -24
  25. sonolus/script/array.py +25 -19
  26. sonolus/script/array_like.py +46 -49
  27. sonolus/script/bucket.py +1 -1
  28. sonolus/script/containers.py +22 -26
  29. sonolus/script/debug.py +24 -47
  30. sonolus/script/effect.py +1 -1
  31. sonolus/script/engine.py +2 -2
  32. sonolus/script/globals.py +3 -3
  33. sonolus/script/instruction.py +3 -3
  34. sonolus/script/internal/builtin_impls.py +155 -28
  35. sonolus/script/internal/constant.py +13 -3
  36. sonolus/script/internal/context.py +46 -15
  37. sonolus/script/internal/impl.py +9 -3
  38. sonolus/script/internal/introspection.py +8 -1
  39. sonolus/script/internal/math_impls.py +17 -0
  40. sonolus/script/internal/native.py +5 -5
  41. sonolus/script/internal/range.py +14 -17
  42. sonolus/script/internal/simulation_context.py +1 -1
  43. sonolus/script/internal/transient.py +2 -2
  44. sonolus/script/internal/value.py +42 -4
  45. sonolus/script/interval.py +15 -15
  46. sonolus/script/iterator.py +38 -107
  47. sonolus/script/maybe.py +139 -0
  48. sonolus/script/num.py +30 -15
  49. sonolus/script/options.py +1 -1
  50. sonolus/script/particle.py +1 -1
  51. sonolus/script/pointer.py +1 -1
  52. sonolus/script/project.py +24 -5
  53. sonolus/script/quad.py +15 -15
  54. sonolus/script/record.py +21 -12
  55. sonolus/script/runtime.py +22 -18
  56. sonolus/script/sprite.py +1 -1
  57. sonolus/script/stream.py +69 -85
  58. sonolus/script/transform.py +35 -34
  59. sonolus/script/values.py +10 -10
  60. sonolus/script/vec.py +23 -20
  61. {sonolus_py-0.3.3.dist-info → sonolus_py-0.4.0.dist-info}/METADATA +1 -1
  62. sonolus_py-0.4.0.dist-info/RECORD +93 -0
  63. sonolus_py-0.3.3.dist-info/RECORD +0 -92
  64. {sonolus_py-0.3.3.dist-info → sonolus_py-0.4.0.dist-info}/WHEEL +0 -0
  65. {sonolus_py-0.3.3.dist-info → sonolus_py-0.4.0.dist-info}/entry_points.txt +0 -0
  66. {sonolus_py-0.3.3.dist-info → sonolus_py-0.4.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,5 +1,6 @@
1
+ from __future__ import annotations
2
+
1
3
  from math import cos, sin
2
- from typing import Self
3
4
 
4
5
  from sonolus.script.interval import lerp, remap
5
6
  from sonolus.script.quad import Quad, QuadLike
@@ -27,7 +28,7 @@ class Transform2d(Record):
27
28
  a22: float
28
29
 
29
30
  @classmethod
30
- def new(cls) -> Self:
31
+ def new(cls) -> Transform2d:
31
32
  """Create a new identity transform.
32
33
 
33
34
  Returns:
@@ -56,7 +57,7 @@ class Transform2d(Record):
56
57
  b20: float,
57
58
  b21: float,
58
59
  b22: float,
59
- ) -> Self:
60
+ ) -> Transform2d:
60
61
  # Multiply by b on the left (b @ a)
61
62
  a00 = self.a00 * b00 + self.a10 * b01 + self.a20 * b02
62
63
  a01 = self.a01 * b00 + self.a11 * b01 + self.a21 * b02
@@ -79,7 +80,7 @@ class Transform2d(Record):
79
80
  a22,
80
81
  )
81
82
 
82
- def translate(self, translation: Vec2, /) -> Self:
83
+ def translate(self, translation: Vec2, /) -> Transform2d:
83
84
  """Translate along the x and y axes and return a new transform.
84
85
 
85
86
  Args:
@@ -100,7 +101,7 @@ class Transform2d(Record):
100
101
  1,
101
102
  )
102
103
 
103
- def scale(self, factor: Vec2, /) -> Self:
104
+ def scale(self, factor: Vec2, /) -> Transform2d:
104
105
  """Scale about the origin and return a new transform.
105
106
 
106
107
  Args:
@@ -121,7 +122,7 @@ class Transform2d(Record):
121
122
  1,
122
123
  )
123
124
 
124
- def scale_about(self, factor: Vec2, /, pivot: Vec2) -> Self:
125
+ def scale_about(self, factor: Vec2, /, pivot: Vec2) -> Transform2d:
125
126
  """Scale about the pivot and return a new transform.
126
127
 
127
128
  Args:
@@ -133,7 +134,7 @@ class Transform2d(Record):
133
134
  """
134
135
  return self.translate(-pivot).scale(factor).translate(pivot)
135
136
 
136
- def rotate(self, angle: float, /) -> Self:
137
+ def rotate(self, angle: float, /) -> Transform2d:
137
138
  """Rotate about the origin and return a new transform.
138
139
 
139
140
  Args:
@@ -156,7 +157,7 @@ class Transform2d(Record):
156
157
  1,
157
158
  )
158
159
 
159
- def rotate_about(self, angle: float, /, pivot: Vec2) -> Self:
160
+ def rotate_about(self, angle: float, /, pivot: Vec2) -> Transform2d:
160
161
  """Rotate about the pivot and return a new transform.
161
162
 
162
163
  Args:
@@ -168,7 +169,7 @@ class Transform2d(Record):
168
169
  """
169
170
  return self.translate(-pivot).rotate(angle).translate(pivot)
170
171
 
171
- def shear_x(self, m: float, /) -> Self:
172
+ def shear_x(self, m: float, /) -> Transform2d:
172
173
  """Shear along the x-axis and return a new transform.
173
174
 
174
175
  Args:
@@ -189,7 +190,7 @@ class Transform2d(Record):
189
190
  1,
190
191
  )
191
192
 
192
- def shear_y(self, m: float, /) -> Self:
193
+ def shear_y(self, m: float, /) -> Transform2d:
193
194
  """Shear along the y-axis and return a new transform.
194
195
 
195
196
  Args:
@@ -210,7 +211,7 @@ class Transform2d(Record):
210
211
  1,
211
212
  )
212
213
 
213
- def simple_perspective_x(self, x: float, /) -> Self:
214
+ def simple_perspective_x(self, x: float, /) -> Transform2d:
214
215
  """Apply perspective along the x-axis with vanishing point at the given x coordinate and return a new transform.
215
216
 
216
217
  Args:
@@ -231,7 +232,7 @@ class Transform2d(Record):
231
232
  1,
232
233
  )
233
234
 
234
- def simple_perspective_y(self, y: float, /) -> Self:
235
+ def simple_perspective_y(self, y: float, /) -> Transform2d:
235
236
  """Apply perspective along the y-axis with vanishing point at the given y coordinate and return a new transform.
236
237
 
237
238
  Args:
@@ -252,7 +253,7 @@ class Transform2d(Record):
252
253
  1,
253
254
  )
254
255
 
255
- def perspective_x(self, foreground_x: float, vanishing_point: Vec2, /) -> Self:
256
+ def perspective_x(self, foreground_x: float, vanishing_point: Vec2, /) -> Transform2d:
256
257
  """Apply a perspective transformation along the x-axis and return a new transform.
257
258
 
258
259
  Args:
@@ -268,7 +269,7 @@ class Transform2d(Record):
268
269
  .translate(Vec2(foreground_x, 0))
269
270
  )
270
271
 
271
- def perspective_y(self, foreground_y: float, vanishing_point: Vec2, /) -> Self:
272
+ def perspective_y(self, foreground_y: float, vanishing_point: Vec2, /) -> Transform2d:
272
273
  """Apply a perspective transformation along the y-axis and return a new transform.
273
274
 
274
275
  Args:
@@ -284,7 +285,7 @@ class Transform2d(Record):
284
285
  .translate(Vec2(0, foreground_y))
285
286
  )
286
287
 
287
- def inverse_perspective_x(self, foreground_x: float, vanishing_point: Vec2, /) -> Self:
288
+ def inverse_perspective_x(self, foreground_x: float, vanishing_point: Vec2, /) -> Transform2d:
288
289
  """Apply the inverse of a perspective transformation along the x-axis and return a new transform.
289
290
 
290
291
  Args:
@@ -300,7 +301,7 @@ class Transform2d(Record):
300
301
  .simple_perspective_x(-vanishing_point.x + foreground_x)
301
302
  )
302
303
 
303
- def inverse_perspective_y(self, foreground_y: float, vanishing_point: Vec2, /) -> Self:
304
+ def inverse_perspective_y(self, foreground_y: float, vanishing_point: Vec2, /) -> Transform2d:
304
305
  """Apply the inverse of a perspective transformation along the y-axis and return a new transform.
305
306
 
306
307
  Args:
@@ -316,7 +317,7 @@ class Transform2d(Record):
316
317
  .simple_perspective_y(-vanishing_point.y + foreground_y)
317
318
  )
318
319
 
319
- def normalize(self) -> Self:
320
+ def normalize(self) -> Transform2d:
320
321
  """Normalize the transform to have a 1 in the bottom right corner and return a new transform.
321
322
 
322
323
  This may fail in some special cases involving perspective transformations where the bottom right corner is 0.
@@ -336,7 +337,7 @@ class Transform2d(Record):
336
337
  1,
337
338
  )
338
339
 
339
- def compose(self, other: Self, /) -> Self:
340
+ def compose(self, other: Transform2d, /) -> Transform2d:
340
341
  """Compose with another transform which is applied after this transform and return a new transform.
341
342
 
342
343
  Args:
@@ -357,7 +358,7 @@ class Transform2d(Record):
357
358
  other.a22,
358
359
  )
359
360
 
360
- def compose_before(self, other: Self, /) -> Self:
361
+ def compose_before(self, other: Transform2d, /) -> Transform2d:
361
362
  """Compose with another transform which is applied before this transform and return a new transform.
362
363
 
363
364
  Args:
@@ -412,7 +413,7 @@ class InvertibleTransform2d(Record):
412
413
  inverse: Transform2d
413
414
 
414
415
  @classmethod
415
- def new(cls) -> Self:
416
+ def new(cls) -> InvertibleTransform2d:
416
417
  """Create a new identity transform.
417
418
 
418
419
  Returns:
@@ -423,7 +424,7 @@ class InvertibleTransform2d(Record):
423
424
  inverse=Transform2d.new(),
424
425
  )
425
426
 
426
- def translate(self, translation: Vec2, /) -> Self:
427
+ def translate(self, translation: Vec2, /) -> InvertibleTransform2d:
427
428
  """Translate along the x and y axes and return a new transform.
428
429
 
429
430
  Args:
@@ -437,7 +438,7 @@ class InvertibleTransform2d(Record):
437
438
  inverse=Transform2d.new().translate(-translation).compose(self.inverse),
438
439
  )
439
440
 
440
- def scale(self, factor: Vec2, /) -> Self:
441
+ def scale(self, factor: Vec2, /) -> InvertibleTransform2d:
441
442
  """Scale about the origin and return a new transform.
442
443
 
443
444
  Args:
@@ -451,7 +452,7 @@ class InvertibleTransform2d(Record):
451
452
  inverse=Transform2d.new().scale(Vec2.one() / factor).compose(self.inverse),
452
453
  )
453
454
 
454
- def scale_about(self, factor: Vec2, /, pivot: Vec2) -> Self:
455
+ def scale_about(self, factor: Vec2, /, pivot: Vec2) -> InvertibleTransform2d:
455
456
  """Scale about the pivot and return a new transform.
456
457
 
457
458
  Args:
@@ -466,7 +467,7 @@ class InvertibleTransform2d(Record):
466
467
  inverse=Transform2d.new().scale_about(Vec2.one() / factor, pivot).compose(self.inverse),
467
468
  )
468
469
 
469
- def rotate(self, angle: float, /) -> Self:
470
+ def rotate(self, angle: float, /) -> InvertibleTransform2d:
470
471
  """Rotate about the origin and return a new transform.
471
472
 
472
473
  Args:
@@ -480,7 +481,7 @@ class InvertibleTransform2d(Record):
480
481
  inverse=Transform2d.new().rotate(-angle).compose(self.inverse),
481
482
  )
482
483
 
483
- def rotate_about(self, angle: float, /, pivot: Vec2) -> Self:
484
+ def rotate_about(self, angle: float, /, pivot: Vec2) -> InvertibleTransform2d:
484
485
  """Rotate about the pivot and return a new transform.
485
486
 
486
487
  Args:
@@ -495,7 +496,7 @@ class InvertibleTransform2d(Record):
495
496
  inverse=Transform2d.new().rotate_about(-angle, pivot).compose(self.inverse),
496
497
  )
497
498
 
498
- def shear_x(self, m: float, /) -> Self:
499
+ def shear_x(self, m: float, /) -> InvertibleTransform2d:
499
500
  """Shear along the x-axis and return a new transform.
500
501
 
501
502
  Args:
@@ -509,7 +510,7 @@ class InvertibleTransform2d(Record):
509
510
  inverse=Transform2d.new().shear_x(-m).compose(self.inverse),
510
511
  )
511
512
 
512
- def shear_y(self, m: float, /) -> Self:
513
+ def shear_y(self, m: float, /) -> InvertibleTransform2d:
513
514
  """Shear along the y-axis and return a new transform.
514
515
 
515
516
  Args:
@@ -523,7 +524,7 @@ class InvertibleTransform2d(Record):
523
524
  inverse=Transform2d.new().shear_y(-m).compose(self.inverse),
524
525
  )
525
526
 
526
- def simple_perspective_x(self, x: float, /) -> Self:
527
+ def simple_perspective_x(self, x: float, /) -> InvertibleTransform2d:
527
528
  """Apply perspective along the x-axis with vanishing point at the given x coordinate and return a new transform.
528
529
 
529
530
  Args:
@@ -537,7 +538,7 @@ class InvertibleTransform2d(Record):
537
538
  inverse=Transform2d.new().simple_perspective_x(-x).compose(self.inverse),
538
539
  )
539
540
 
540
- def simple_perspective_y(self, y: float, /) -> Self:
541
+ def simple_perspective_y(self, y: float, /) -> InvertibleTransform2d:
541
542
  """Apply perspective along the y-axis with vanishing point at the given y coordinate and return a new transform.
542
543
 
543
544
  Args:
@@ -551,7 +552,7 @@ class InvertibleTransform2d(Record):
551
552
  inverse=Transform2d.new().simple_perspective_y(-y).compose(self.inverse),
552
553
  )
553
554
 
554
- def perspective_x(self, foreground_x: float, vanishing_point: Vec2, /) -> Self:
555
+ def perspective_x(self, foreground_x: float, vanishing_point: Vec2, /) -> InvertibleTransform2d:
555
556
  """Apply a perspective transformation along the x-axis and return a new transform.
556
557
 
557
558
  Args:
@@ -566,7 +567,7 @@ class InvertibleTransform2d(Record):
566
567
  inverse=Transform2d.new().inverse_perspective_x(foreground_x, vanishing_point).compose(self.inverse),
567
568
  )
568
569
 
569
- def perspective_y(self, foreground_y: float, vanishing_point: Vec2, /) -> Self:
570
+ def perspective_y(self, foreground_y: float, vanishing_point: Vec2, /) -> InvertibleTransform2d:
570
571
  """Apply a perspective transformation along the y-axis and return a new transform.
571
572
 
572
573
  Args:
@@ -581,7 +582,7 @@ class InvertibleTransform2d(Record):
581
582
  inverse=Transform2d.new().inverse_perspective_y(foreground_y, vanishing_point).compose(self.inverse),
582
583
  )
583
584
 
584
- def normalize(self) -> Self:
585
+ def normalize(self) -> InvertibleTransform2d:
585
586
  """Normalize the transform to have a 1 in the bottom right corner and return a new transform.
586
587
 
587
588
  This may fail in some special cases involving perspective transformations where the bottom right corner is 0.
@@ -594,7 +595,7 @@ class InvertibleTransform2d(Record):
594
595
  inverse=self.inverse.normalize(),
595
596
  )
596
597
 
597
- def compose(self, other: Self, /) -> Self:
598
+ def compose(self, other: InvertibleTransform2d, /) -> InvertibleTransform2d:
598
599
  """Compose with another invertible transform which is applied after this transform and return a new transform.
599
600
 
600
601
  Args:
@@ -608,7 +609,7 @@ class InvertibleTransform2d(Record):
608
609
  inverse=other.inverse.compose(self.inverse),
609
610
  )
610
611
 
611
- def compose_before(self, other: Self, /) -> Self:
612
+ def compose_before(self, other: InvertibleTransform2d, /) -> InvertibleTransform2d:
612
613
  """Compose with another invertible transform which is applied before this transform and return a new transform.
613
614
 
614
615
  Args:
sonolus/script/values.py CHANGED
@@ -5,25 +5,25 @@ from sonolus.script.num import Num
5
5
 
6
6
 
7
7
  @meta_fn
8
- def alloc[T](type_: type[T]) -> T:
8
+ def alloc[T](type_: type[T]) -> T: # type: ignore
9
9
  """Return an uninitialized instance of the given type.
10
10
 
11
11
  Use this carefully as reading from uninitialized memory can lead to unexpected behavior.
12
12
  """
13
13
  type_ = validate_concrete_type(type_)
14
14
  if ctx():
15
- return type_._alloc_()
15
+ return type_._alloc_() # type: ignore
16
16
  else:
17
- return type_._alloc_()._as_py_()
17
+ return type_._alloc_()._as_py_() # type: ignore
18
18
 
19
19
 
20
20
  @meta_fn
21
- def zeros[T](type_: type[T]) -> T:
21
+ def zeros[T](type_: type[T]) -> T: # type: ignore
22
22
  """Make a new instance of the given type initialized with zeros.
23
23
 
24
24
  Generally works the same as the unary `+` operator on record and array types.
25
25
  """
26
- return validate_concrete_type(type_)._zero_()
26
+ return validate_concrete_type(type_)._zero_() # type: ignore
27
27
 
28
28
 
29
29
  @meta_fn
@@ -32,18 +32,18 @@ def copy[T](value: T) -> T:
32
32
 
33
33
  Generally works the same as the unary `+` operator on records and arrays.
34
34
  """
35
- value = validate_value(value)
35
+ value = validate_value(value) # type: ignore
36
36
  if ctx():
37
- return value._copy_()
37
+ return value._copy_() # type: ignore
38
38
  else:
39
- return value._copy_()._as_py_()
39
+ return value._copy_()._as_py_() # type: ignore
40
40
 
41
41
 
42
42
  def swap[T](a: T, b: T):
43
43
  """Swap the values of the two provided mutable values."""
44
44
  temp = copy(a)
45
- a @= b
46
- b @= temp
45
+ a @= b # type: ignore
46
+ b @= temp # type: ignore
47
47
 
48
48
 
49
49
  @meta_fn
sonolus/script/vec.py CHANGED
@@ -1,5 +1,6 @@
1
+ from __future__ import annotations
2
+
1
3
  from math import atan2, cos, sin
2
- from typing import Self
3
4
 
4
5
  from sonolus.script.array import Array
5
6
  from sonolus.script.array_like import ArrayLike
@@ -20,7 +21,7 @@ class Vec2(Record):
20
21
  y: float
21
22
 
22
23
  @classmethod
23
- def zero(cls) -> Self:
24
+ def zero(cls) -> Vec2:
24
25
  """Return a vector with x and y set to 0.
25
26
 
26
27
  Returns:
@@ -29,7 +30,7 @@ class Vec2(Record):
29
30
  return cls(x=0, y=0)
30
31
 
31
32
  @classmethod
32
- def one(cls) -> Self:
33
+ def one(cls) -> Vec2:
33
34
  """Return a vector with x and y set to 1.
34
35
 
35
36
  Returns:
@@ -38,7 +39,7 @@ class Vec2(Record):
38
39
  return cls(x=1, y=1)
39
40
 
40
41
  @classmethod
41
- def up(cls) -> Self:
42
+ def up(cls) -> Vec2:
42
43
  """Return a vector pointing upwards (x=0, y=1).
43
44
 
44
45
  Returns:
@@ -47,7 +48,7 @@ class Vec2(Record):
47
48
  return cls(x=0, y=1)
48
49
 
49
50
  @classmethod
50
- def down(cls) -> Self:
51
+ def down(cls) -> Vec2:
51
52
  """Return a vector pointing downwards (x=0, y=-1).
52
53
 
53
54
  Returns:
@@ -56,7 +57,7 @@ class Vec2(Record):
56
57
  return cls(x=0, y=-1)
57
58
 
58
59
  @classmethod
59
- def left(cls) -> Self:
60
+ def left(cls) -> Vec2:
60
61
  """Return a vector pointing to the left (x=-1, y=0).
61
62
 
62
63
  Returns:
@@ -65,7 +66,7 @@ class Vec2(Record):
65
66
  return cls(x=-1, y=0)
66
67
 
67
68
  @classmethod
68
- def right(cls) -> Self:
69
+ def right(cls) -> Vec2:
69
70
  """Return a vector pointing to the right (x=1, y=0).
70
71
 
71
72
  Returns:
@@ -74,7 +75,7 @@ class Vec2(Record):
74
75
  return cls(x=1, y=0)
75
76
 
76
77
  @classmethod
77
- def unit(cls, angle: Num) -> Self:
78
+ def unit(cls, angle: float) -> Vec2:
78
79
  """Return a unit vector (magnitude 1) at a given angle in radians.
79
80
 
80
81
  Args:
@@ -86,7 +87,7 @@ class Vec2(Record):
86
87
  return Vec2(x=cos(angle), y=sin(angle))
87
88
 
88
89
  @property
89
- def magnitude(self) -> Num:
90
+ def magnitude(self) -> float:
90
91
  """Calculate the magnitude (length) of the vector.
91
92
 
92
93
  Returns:
@@ -95,7 +96,7 @@ class Vec2(Record):
95
96
  return (self.x**2 + self.y**2) ** 0.5
96
97
 
97
98
  @property
98
- def angle(self) -> Num:
99
+ def angle(self) -> float:
99
100
  """Calculate the angle of the vector in radians from the positive x-axis.
100
101
 
101
102
  Returns:
@@ -103,7 +104,7 @@ class Vec2(Record):
103
104
  """
104
105
  return atan2(self.y, self.x)
105
106
 
106
- def dot(self, other: Self) -> Num:
107
+ def dot(self, other: Vec2) -> float:
107
108
  """Calculate the dot product of this vector with another vector.
108
109
 
109
110
  Args:
@@ -114,7 +115,7 @@ class Vec2(Record):
114
115
  """
115
116
  return self.x * other.x + self.y * other.y
116
117
 
117
- def rotate(self, angle: Num) -> Self:
118
+ def rotate(self, angle: float) -> Vec2:
118
119
  """Rotate the vector by a given angle in radians and return a new vector.
119
120
 
120
121
  Args:
@@ -128,7 +129,7 @@ class Vec2(Record):
128
129
  y=self.x * sin(angle) + self.y * cos(angle),
129
130
  )
130
131
 
131
- def rotate_about(self, angle: Num, pivot: Self) -> Self:
132
+ def rotate_about(self, angle: float, pivot: Vec2) -> Vec2:
132
133
  """Rotate the vector about a pivot by a given angle in radians and return a new vector.
133
134
 
134
135
  Args:
@@ -140,7 +141,7 @@ class Vec2(Record):
140
141
  """
141
142
  return (self - pivot).rotate(angle) + pivot
142
143
 
143
- def normalize(self) -> Self:
144
+ def normalize(self) -> Vec2:
144
145
  """Normalize the vector (set the magnitude to 1) and return a new vector.
145
146
 
146
147
  Returns:
@@ -149,7 +150,7 @@ class Vec2(Record):
149
150
  magnitude = self.magnitude
150
151
  return Vec2(x=self.x / magnitude, y=self.y / magnitude)
151
152
 
152
- def orthogonal(self) -> Self:
153
+ def orthogonal(self) -> Vec2:
153
154
  """Return a vector orthogonal to this vector.
154
155
 
155
156
  The orthogonal vector is rotated 90 degrees counter-clockwise from this vector.
@@ -168,7 +169,7 @@ class Vec2(Record):
168
169
  """
169
170
  return self.x, self.y
170
171
 
171
- def __add__(self, other: Self) -> Self:
172
+ def __add__(self, other: Vec2) -> Vec2:
172
173
  """Add this vector to another vector and return a new vector.
173
174
 
174
175
  Args:
@@ -179,7 +180,7 @@ class Vec2(Record):
179
180
  """
180
181
  return Vec2(x=self.x + other.x, y=self.y + other.y)
181
182
 
182
- def __sub__(self, other: Self) -> Self:
183
+ def __sub__(self, other: Vec2) -> Vec2:
183
184
  """Subtract another vector from this vector and return a new vector.
184
185
 
185
186
  Args:
@@ -190,7 +191,7 @@ class Vec2(Record):
190
191
  """
191
192
  return Vec2(x=self.x - other.x, y=self.y - other.y)
192
193
 
193
- def __mul__(self, other: Self | float) -> Self:
194
+ def __mul__(self, other: Vec2 | float) -> Vec2:
194
195
  """Multiply this vector by another vector or a scalar and return a new vector.
195
196
 
196
197
  Args:
@@ -214,7 +215,7 @@ class Vec2(Record):
214
215
  case _:
215
216
  return NotImplemented
216
217
 
217
- def __truediv__(self, other: Self | float) -> Self:
218
+ def __truediv__(self, other: Vec2 | float) -> Vec2:
218
219
  """Divide this vector by another vector or a scalar and return a new vector.
219
220
 
220
221
  Args:
@@ -228,8 +229,10 @@ class Vec2(Record):
228
229
  return Vec2(x=self.x / x, y=self.y / y)
229
230
  case Num(factor):
230
231
  return Vec2(x=self.x / factor, y=self.y / factor)
232
+ case _:
233
+ return NotImplemented
231
234
 
232
- def __neg__(self) -> Self:
235
+ def __neg__(self) -> Vec2:
233
236
  """Negate the vector (invert the direction) and return a new vector.
234
237
 
235
238
  Returns:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sonolus.py
3
- Version: 0.3.3
3
+ Version: 0.4.0
4
4
  Summary: Sonolus engine development in Python
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.12
@@ -0,0 +1,93 @@
1
+ sonolus/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ sonolus/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ sonolus/backend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ sonolus/backend/blocks.py,sha256=3peyb9eYBy0s53xNVJ1KmK4IgoyVkkwG-lqDQ_VZTHc,18531
5
+ sonolus/backend/excepthook.py,sha256=ezsTi8hPXSUhqZ7-H0rmkWcndBQcZFAShF543zzaEPM,1912
6
+ sonolus/backend/finalize.py,sha256=ivl32G7rDSVZl2EEI1HvOHpLdhhOh-ZjavwBZgPe9uA,5286
7
+ sonolus/backend/interpret.py,sha256=B0jqlLmEGoyO2mxpcvwRwV17Tq_gOE9wLNt26Q5QOfs,14306
8
+ sonolus/backend/ir.py,sha256=TCDLMvlX2S8emFDQwFVeD2OUC4fnhbrMObgYtoa_7PQ,2845
9
+ sonolus/backend/mode.py,sha256=NkcPZJm8dn83LX35uP24MtQOCnfRDFZ280dHeEEfauE,613
10
+ sonolus/backend/node.py,sha256=eEzPP14jzWJp2xrZCAaPlNtokxdoqg0bSM7xQiwx1j8,1254
11
+ sonolus/backend/ops.py,sha256=5weB_vIxbkwCSJuzYZyKUk7vVXsSIEDJYRlvE-2ke8A,10572
12
+ sonolus/backend/place.py,sha256=7qwV732hZ4WP-9GNN8FQSEKssPJZELip1wLXTWfop7Y,4717
13
+ sonolus/backend/utils.py,sha256=QM0VMYfDmkqRkaSq0y0DagKPTMbD-NTOnMKFNoQQLHk,2387
14
+ sonolus/backend/visitor.py,sha256=sxg64PLxakHaA7w6eGD5XMGBDXxJM5Hjp1ZE5-FZ1m0,60570
15
+ sonolus/backend/optimize/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ sonolus/backend/optimize/allocate.py,sha256=CuumoMphkpQlGRNeKLHT4FBGE0XVj5pwhfNdrqiLFSs,7535
17
+ sonolus/backend/optimize/constant_evaluation.py,sha256=OyjlgHIT6oPKCyBtNzEpo1nWYjr-_mwYUo8FrNV4eO4,21331
18
+ sonolus/backend/optimize/copy_coalesce.py,sha256=45YL7QmRLL-FiQX4sDs56o4hyP7lX8KIJ0lIbyVw8h8,4549
19
+ sonolus/backend/optimize/dead_code.py,sha256=ZRJ95zJ49R-wZTzJtcSSbl5LYKHWI-byHM3n6jOyAqc,8307
20
+ sonolus/backend/optimize/dominance.py,sha256=3jAgXqXTbuYLpXvIm8UB06NkIOLtaoVp7pBVPcLb5vY,3259
21
+ sonolus/backend/optimize/flow.py,sha256=asBUSWDPlAmlBiPg8a0Q4DJ2Uzg1v7pUnIKNcK-Q7Bo,6680
22
+ sonolus/backend/optimize/inlining.py,sha256=RL88GqWt7yfxHpJifNjeVjzVNjQJk8226l9ICehkGwM,10423
23
+ sonolus/backend/optimize/liveness.py,sha256=LKTLdQm4iPsAdAdvC3DRrrw_zwTFdFTFsMmwDylUAn0,7163
24
+ sonolus/backend/optimize/optimize.py,sha256=sY1GFLjAslVgMsLzocC3Ctk0R9SqwybWyqzFB6WMntI,1624
25
+ sonolus/backend/optimize/passes.py,sha256=YyFKy6qCwcR_Ua2_SXpcBODfvBbm_ygVYcqloOlfDZI,1911
26
+ sonolus/backend/optimize/simplify.py,sha256=RDNVTKfC7ByRyxY5z30_ShimOAKth_pKlVFV_36pDG4,14082
27
+ sonolus/backend/optimize/ssa.py,sha256=raQO0furQQRPYb8iIBKfNrJlj-_5wqtI4EWNfLZ8QFo,10834
28
+ sonolus/build/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
+ sonolus/build/cli.py,sha256=jzJVdPdEn0uaEbv5B7BuQZioytAeG9P2vDXwiRTXA8s,10113
30
+ sonolus/build/collection.py,sha256=kOVnpQC_KHAsyTM4nAplSh6QE16CgO-H6PP1GItWm78,12187
31
+ sonolus/build/compile.py,sha256=hF8CnaqMQqak4OyEQvxJLo_mpzZDQipMa14syZsWLEA,5976
32
+ sonolus/build/engine.py,sha256=zUl0KfRygqNhIM8BABNJkKG-0zXFwcYwck-5hJy59yk,13338
33
+ sonolus/build/level.py,sha256=yXsQtnabkJK0vuVmZ_Wr1jx37jFLgInCS7lTlXjkv9Q,706
34
+ sonolus/build/node.py,sha256=gnX71RYDUOK_gYMpinQi-bLWO4csqcfiG5gFmhxzSec,1330
35
+ sonolus/build/project.py,sha256=mv2OuzgIDG-E9G4SIRiUDL5XiPCd1i81wVl1p7itFHA,6329
36
+ sonolus/script/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
+ sonolus/script/archetype.py,sha256=vNNX6YGi_CUQcjf0xG1Rkpz9kUd_84hEPuY1Ew9uFxA,41666
38
+ sonolus/script/array.py,sha256=lnobVrrEOE6PgPasq3DovrshlDKPbX8kKUsGmJz2oK0,12360
39
+ sonolus/script/array_like.py,sha256=jFOfXkniTLrIK4ER6HO_tUyKn_TvwjyM4B3SDd9cUS8,9678
40
+ sonolus/script/bucket.py,sha256=5VU-Bh7qYifl6NcgZFCo7eAEgi3iGTX-PUTmXiPCJaQ,7535
41
+ sonolus/script/containers.py,sha256=O1Pjfpz9RmbdSTBi5yqzyoxfhnl_Zk0fiSTUfHBO0lE,18667
42
+ sonolus/script/debug.py,sha256=_Hg1cXQJ8fBXMiwhmoPb2X9CKcQ8QO26WNa59K518og,4305
43
+ sonolus/script/easing.py,sha256=7zaDKIfM_whUpb4FBz1DAF4NNG2vk_nDjl8kL2Y90aU,11396
44
+ sonolus/script/effect.py,sha256=pqfsOhmGVDMkifumkRr9rD2trWZU6Rw-_gTApNIaz7g,5854
45
+ sonolus/script/engine.py,sha256=etI9dJsQ7V9YZICVNZg54WqpLijPxG8eTPHiV-_EiG8,10687
46
+ sonolus/script/globals.py,sha256=FOv8uiLM5U6X-yMLCXukMvLgV3rs-xVJbobST_MhLcU,9782
47
+ sonolus/script/instruction.py,sha256=iBjY7nCNDT3w0SBJKlix3Z-85e7eE2qKeHp6C2Nq7KA,6753
48
+ sonolus/script/interval.py,sha256=dj6F2wn5uP6I6_mcZn-wIREgRUQbsLzhvhzB0oEyAdU,11290
49
+ sonolus/script/iterator.py,sha256=LqXi6062G-vLa3taxFz3IsWwFsFrOwfxx7_0aWDi4as,3070
50
+ sonolus/script/level.py,sha256=wR23xk-NOcW_JMRb3R12sqIXCLSZL-7cM3y7IpMF1J0,6333
51
+ sonolus/script/maybe.py,sha256=p2fGgdtNlnozkJ80pOLoo9-M0dp2iKRtLT5RXf-JF4U,4199
52
+ sonolus/script/metadata.py,sha256=ttRK27eojHf3So50KQJ-8yj3udZoN1bli5iD-knaeLw,753
53
+ sonolus/script/num.py,sha256=uGNBnpE3AAGA1yo0_SADZ57raWowpcsE0DEopgjpohI,16022
54
+ sonolus/script/options.py,sha256=KlOud4QOf_lW1o6avKXbkjcMCDPkhLcEwt5PW7ZCH3s,9435
55
+ sonolus/script/particle.py,sha256=XczhwTJvU3dMOXXTxJI_5Mskro2LgVlNgrCSwYreO0Q,8369
56
+ sonolus/script/pointer.py,sha256=FoOfyD93r0G5d_2BaKfeOT9SqkOP3hq6sqtOs_Rb0c8,1511
57
+ sonolus/script/printing.py,sha256=mNYu9QWiacBBGZrnePZQMVwbbguoelUps9GiOK_aVRU,2096
58
+ sonolus/script/project.py,sha256=IyWMM-Sf7-Kd0AHzlAUyJBKBWRRX2rOpjlN7b8UOTE8,3966
59
+ sonolus/script/quad.py,sha256=XoAjaUqR60zIrC_CwheZs7HwS-DRS58yUmlj9GIjX7k,11179
60
+ sonolus/script/record.py,sha256=JiRvI_uZjJ-DWzfbsOHDfrOUxO3ZlRPxJP90Hc0z9hM,12673
61
+ sonolus/script/runtime.py,sha256=rJZM_KbKmnwpjhDEpR0DrM6EMSEu46apIErWA_pfLJA,33321
62
+ sonolus/script/sprite.py,sha256=mMDTXckn58YR8mrx3fzdBaduQ8cn9YTtTVruXXK1ow0,16272
63
+ sonolus/script/stream.py,sha256=4b0AV5MRPo4wzTHmaN95jwODxPVt6WuN3QxmGccdwRU,24517
64
+ sonolus/script/text.py,sha256=wxujIgKYcCfl2AD2_Im8g3vh0lDEHYwTSRZg9wsBPEU,13402
65
+ sonolus/script/timing.py,sha256=ZR0ypV2PIoDCMHHGOMfCeezStCsBQdzomdqaz5VKex0,2981
66
+ sonolus/script/transform.py,sha256=w5mr7hTuNYU0eTAdnN_wTVibaQa0mZrkl-W-kgewJxQ,21345
67
+ sonolus/script/ui.py,sha256=DYPGWIjHj1IFPxW1zaEuIUQx0b32FJPXtiwCvrtJ6oo,7528
68
+ sonolus/script/values.py,sha256=6iJG6h4IDlbcK8FH4GENSHOQc7C_7fCGa34wM80qToA,1629
69
+ sonolus/script/vec.py,sha256=oVx5C5zGj8gX37F7y1FEJOrTYzb7EWfQWQuKU8KGLdc,7486
70
+ sonolus/script/internal/__init__.py,sha256=T6rzLoiOUaiSQtaHMZ88SNO-ijSjSSv33TKtUwu-Ms8,136
71
+ sonolus/script/internal/builtin_impls.py,sha256=vzyaSTsxoZoE6a-aBBHn4aIfjGxxYzojEnOog3-HETI,12686
72
+ sonolus/script/internal/callbacks.py,sha256=vWzJG8uiJoEtsNnbeZPqOHogCwoLpz2D1MnHY2wVV8s,2801
73
+ sonolus/script/internal/constant.py,sha256=3ycbGkDJVUwcrCZ96vLjAoAARgsvaqDM8rJ_YCrLrvo,4289
74
+ sonolus/script/internal/context.py,sha256=8wLclCnLyDJt7BGbSqMD6rngYt9jI2JYji6XV8cbCAw,16742
75
+ sonolus/script/internal/descriptor.py,sha256=XRFey-EjiAm_--KsNl-8N0Mi_iyQwlPh68gDp0pKf3E,392
76
+ sonolus/script/internal/dict_impl.py,sha256=alu_wKGSk1kZajNf64qbe7t71shEzD4N5xNIATH8Swo,1885
77
+ sonolus/script/internal/error.py,sha256=ZNnsvQVQAnFKzcvsm6-sste2lo-tP5pPI8sD7XlAZWc,490
78
+ sonolus/script/internal/generic.py,sha256=F0-cCiRNGTaUJvYlpmkiOsU3Xge_XjoBpBwBhH_qS_s,7577
79
+ sonolus/script/internal/impl.py,sha256=I3IlPZZZtXVJb044cpULg5FDYUjiLtAucnsA6w_0xUk,3233
80
+ sonolus/script/internal/introspection.py,sha256=MfdXo3GFHNZT2-vAKuvsE54V-5TOfbg4vU9dBI6sLqo,1032
81
+ sonolus/script/internal/math_impls.py,sha256=nHSLgA7Tcx7jY1p07mYBCeSRmVx713bwdNayCIcaXSE,2652
82
+ sonolus/script/internal/native.py,sha256=WrZ3sVYfrc9plFxJJSWCqwq3ymruw3WhET_UjmhKj38,1628
83
+ sonolus/script/internal/random.py,sha256=6Ku5edRcDUh7rtqEEYCJz0BQavw69RALsVHS25z50pI,1695
84
+ sonolus/script/internal/range.py,sha256=YeqB1TPh7JdvW6kDuA5tpQL5psVxYQjepBZs7RNcP5Y,3426
85
+ sonolus/script/internal/simulation_context.py,sha256=LGxLTvxbqBIhoe1R-SfwGajNIDwIJMVsHle0kvzd500,4818
86
+ sonolus/script/internal/transient.py,sha256=y2AWABqF1aoaP6H4_2u4MMpNioC4OsZQCtPyNI0txqo,1634
87
+ sonolus/script/internal/tuple_impl.py,sha256=DPNdmmRmupU8Ah4_XKq6-PdT336l4nt15_uCJKQGkkk,3587
88
+ sonolus/script/internal/value.py,sha256=OngrCdmY_h6mV2Zgwqhuo4eYFad0kTk6263UAxctZcY,6963
89
+ sonolus_py-0.4.0.dist-info/METADATA,sha256=5YcGXNkUzFc1F27UWp_AeCbWPjEuOLJviTkIoVgdTxw,302
90
+ sonolus_py-0.4.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
91
+ sonolus_py-0.4.0.dist-info/entry_points.txt,sha256=oTYspY_b7SA8TptEMTDxh4-Aj-ZVPnYC9f1lqH6s9G4,54
92
+ sonolus_py-0.4.0.dist-info/licenses/LICENSE,sha256=JEKpqVhQYfEc7zg3Mj462sKbKYmO1K7WmvX1qvg9IJk,1067
93
+ sonolus_py-0.4.0.dist-info/RECORD,,