| 3 | from pyray import * |
| 4 | |
| 5 | class Vector2Ex(list): |
| 6 | def __init__(self, x, y): |
| 7 | super(Vector2Ex, self).__init__([x, y]) |
| 8 | |
| 9 | @property |
| 10 | def x(self): |
| 11 | return self[0] |
| 12 | |
| 13 | @x.setter |
| 14 | def x(self, value): |
| 15 | self[0]= value |
| 16 | |
| 17 | @property |
| 18 | def y(self): |
| 19 | return self[1] |
| 20 | |
| 21 | @y.setter |
| 22 | def y(self, value): |
| 23 | self[1]= value |
| 24 | |
| 25 | @staticmethod |
| 26 | def to_Vec2(v: Vector2): |
| 27 | """ |
| 28 | Cast Vector2 to Vec2. |
| 29 | """ |
| 30 | return Vector2Ex(v.x, v.y) |
| 31 | |
| 32 | def __repr__(self) -> str: |
| 33 | return f"{self.x}, {self.y}" |
| 34 | |
| 35 | def __eq__(self, other): |
| 36 | if isinstance(other, Vector2Ex): |
| 37 | return self.x == other.x and self.y == other.y |
| 38 | return False |
| 39 | |
| 40 | def __add__(self, other): |
| 41 | if isinstance(other, Vector2Ex): |
| 42 | return Vector2Ex(self.x + other.x, self.y + other.y) |
| 43 | return Vector2Ex(self.x + other, self.y + other) |
| 44 | |
| 45 | def __iadd__(self, other): |
| 46 | if isinstance(other, Vector2Ex): |
| 47 | self.x += other.x |
| 48 | self.y += other.y |
| 49 | else: |
| 50 | res = vector2_add_value(self, other) |
| 51 | self.x = res.x |
| 52 | self.y = res.y |
| 53 | return self |
| 54 | |
| 55 | def __radd__(self, other): |
| 56 | return self + other |
| 57 | |
| 58 | def __sub__(self, other): |
| 59 | if isinstance(other, Vector2Ex): |
| 60 | return Vector2Ex(self.x - other.x, self.y - other.y) |
| 61 | return Vector2Ex(self.x - other, self.y - other) |
| 62 |
no outgoing calls
no test coverage detected