mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +00:00
add copy_*_
This commit is contained in:
parent
a0a5753283
commit
b9d29dd4da
@ -20,7 +20,12 @@ class vec2(_StructLike['vec2']):
|
|||||||
def __init__(self, x: float, y: float) -> None: ...
|
def __init__(self, x: float, y: float) -> None: ...
|
||||||
def __add__(self, other: vec2) -> vec2: ...
|
def __add__(self, other: vec2) -> vec2: ...
|
||||||
def __sub__(self, other: vec2) -> vec2: ...
|
def __sub__(self, other: vec2) -> vec2: ...
|
||||||
|
|
||||||
|
@overload
|
||||||
def __mul__(self, other: float) -> vec2: ...
|
def __mul__(self, other: float) -> vec2: ...
|
||||||
|
@overload
|
||||||
|
def __mul__(self, other: vec2) -> vec2: ...
|
||||||
|
|
||||||
def __rmul__(self, other: float) -> vec2: ...
|
def __rmul__(self, other: float) -> vec2: ...
|
||||||
def __truediv__(self, other: float) -> vec2: ...
|
def __truediv__(self, other: float) -> vec2: ...
|
||||||
def dot(self, other: vec2) -> float: ...
|
def dot(self, other: vec2) -> float: ...
|
||||||
@ -56,7 +61,12 @@ class vec3(_StructLike['vec3']):
|
|||||||
def __init__(self, x: float, y: float, z: float) -> None: ...
|
def __init__(self, x: float, y: float, z: float) -> None: ...
|
||||||
def __add__(self, other: vec3) -> vec3: ...
|
def __add__(self, other: vec3) -> vec3: ...
|
||||||
def __sub__(self, other: vec3) -> vec3: ...
|
def __sub__(self, other: vec3) -> vec3: ...
|
||||||
|
|
||||||
|
@overload
|
||||||
def __mul__(self, other: float) -> vec3: ...
|
def __mul__(self, other: float) -> vec3: ...
|
||||||
|
@overload
|
||||||
|
def __mul__(self, other: vec3) -> vec3: ...
|
||||||
|
|
||||||
def __rmul__(self, other: float) -> vec3: ...
|
def __rmul__(self, other: float) -> vec3: ...
|
||||||
def __truediv__(self, other: float) -> vec3: ...
|
def __truediv__(self, other: float) -> vec3: ...
|
||||||
def dot(self, other: vec3) -> float: ...
|
def dot(self, other: vec3) -> float: ...
|
||||||
@ -77,7 +87,12 @@ class vec4(_StructLike['vec4']):
|
|||||||
def __init__(self, x: float, y: float, z: float, w: float) -> None: ...
|
def __init__(self, x: float, y: float, z: float, w: float) -> None: ...
|
||||||
def __add__(self, other: vec4) -> vec4: ...
|
def __add__(self, other: vec4) -> vec4: ...
|
||||||
def __sub__(self, other: vec4) -> vec4: ...
|
def __sub__(self, other: vec4) -> vec4: ...
|
||||||
|
|
||||||
|
@overload
|
||||||
def __mul__(self, other: float) -> vec4: ...
|
def __mul__(self, other: float) -> vec4: ...
|
||||||
|
@overload
|
||||||
|
def __mul__(self, other: vec4) -> vec4: ...
|
||||||
|
|
||||||
def __rmul__(self, other: float) -> vec4: ...
|
def __rmul__(self, other: float) -> vec4: ...
|
||||||
def __truediv__(self, other: float) -> vec4: ...
|
def __truediv__(self, other: float) -> vec4: ...
|
||||||
def dot(self, other: vec4) -> float: ...
|
def dot(self, other: vec4) -> float: ...
|
||||||
@ -140,7 +155,11 @@ class mat3x3(_StructLike['mat3x3']):
|
|||||||
# affine transformations
|
# affine transformations
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def trs(t: vec2, r: float, s: vec2) -> mat3x3: ...
|
def trs(t: vec2, r: float, s: vec2) -> mat3x3: ...
|
||||||
|
|
||||||
def copy_trs_(self, t: vec2, r: float, s: vec2) -> None: ...
|
def copy_trs_(self, t: vec2, r: float, s: vec2) -> None: ...
|
||||||
|
def copy_t_(self, t: vec2) -> None: ...
|
||||||
|
def copy_r_(self, r: float) -> None: ...
|
||||||
|
def copy_s_(self, s: vec2) -> None: ...
|
||||||
|
|
||||||
def _t(self) -> vec2: ...
|
def _t(self) -> vec2: ...
|
||||||
def _r(self) -> float: ...
|
def _r(self) -> float: ...
|
||||||
|
@ -143,7 +143,11 @@ class mat3x3(_StructLike['mat3x3']):
|
|||||||
# affine transformations
|
# affine transformations
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def trs(t: vec2, r: float, s: vec2) -> mat3x3: ...
|
def trs(t: vec2, r: float, s: vec2) -> mat3x3: ...
|
||||||
|
|
||||||
def copy_trs_(self, t: vec2, r: float, s: vec2) -> None: ...
|
def copy_trs_(self, t: vec2, r: float, s: vec2) -> None: ...
|
||||||
|
def copy_t_(self, t: vec2) -> None: ...
|
||||||
|
def copy_r_(self, r: float) -> None: ...
|
||||||
|
def copy_s_(self, s: vec2) -> None: ...
|
||||||
|
|
||||||
def _t(self) -> vec2: ...
|
def _t(self) -> vec2: ...
|
||||||
def _r(self) -> float: ...
|
def _r(self) -> float: ...
|
||||||
|
@ -456,6 +456,27 @@ static Vec2 SmoothDamp(Vec2 current, Vec2 target, PyVec2& currentVelocity, float
|
|||||||
return vm->None;
|
return vm->None;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
vm->bind(type, "copy_t_(self, t: vec2)", [](VM* vm, ArgsView args){
|
||||||
|
PyMat3x3& self = _CAST(PyMat3x3&, args[0]);
|
||||||
|
Vec2 t = CAST(Vec2, args[1]);
|
||||||
|
self = Mat3x3::trs(t, self._r(), self._s());
|
||||||
|
return vm->None;
|
||||||
|
});
|
||||||
|
|
||||||
|
vm->bind(type, "copy_r_(self, r: float)", [](VM* vm, ArgsView args){
|
||||||
|
PyMat3x3& self = _CAST(PyMat3x3&, args[0]);
|
||||||
|
f64 r = CAST_F(args[1]);
|
||||||
|
self = Mat3x3::trs(self._t(), r, self._s());
|
||||||
|
return vm->None;
|
||||||
|
});
|
||||||
|
|
||||||
|
vm->bind(type, "copy_s_(self, s: vec2)", [](VM* vm, ArgsView args){
|
||||||
|
PyMat3x3& self = _CAST(PyMat3x3&, args[0]);
|
||||||
|
Vec2 s = CAST(Vec2, args[1]);
|
||||||
|
self = Mat3x3::trs(self._t(), self._r(), s);
|
||||||
|
return vm->None;
|
||||||
|
});
|
||||||
|
|
||||||
vm->bind_method<0>(type, "is_affine", [](VM* vm, ArgsView args){
|
vm->bind_method<0>(type, "is_affine", [](VM* vm, ArgsView args){
|
||||||
PyMat3x3& self = _CAST(PyMat3x3&, args[0]);
|
PyMat3x3& self = _CAST(PyMat3x3&, args[0]);
|
||||||
return VAR(self.is_affine());
|
return VAR(self.is_affine());
|
||||||
|
@ -392,6 +392,11 @@ assert mat_to_str_list(mat3x3.trs(test_vec2_copy, radian, test_vec2_2_copy)) ==
|
|||||||
a = mat3x3.zeros()
|
a = mat3x3.zeros()
|
||||||
a.copy_trs_(test_vec2_copy, radian, test_vec2_2_copy)
|
a.copy_trs_(test_vec2_copy, radian, test_vec2_2_copy)
|
||||||
assert a == mat3x3.trs(test_vec2_copy, radian, test_vec2_2_copy)
|
assert a == mat3x3.trs(test_vec2_copy, radian, test_vec2_2_copy)
|
||||||
|
b = mat3x3.identity()
|
||||||
|
b.copy_t_(test_vec2_copy)
|
||||||
|
b.copy_r_(radian)
|
||||||
|
b.copy_s_(test_vec2_2_copy)
|
||||||
|
assert a == b
|
||||||
|
|
||||||
# test is_affine
|
# test is_affine
|
||||||
def mat_is_affine(mat_list):
|
def mat_is_affine(mat_list):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user