diff --git a/libs/pyglet_rs/README.md b/libs/pyglet_rs/README.md index d4dff19..5ed334f 100644 --- a/libs/pyglet_rs/README.md +++ b/libs/pyglet_rs/README.md @@ -38,11 +38,21 @@ cd src ## roadmap -- [ ] `pyglet.sprite.Sprite` patch (doing) +- [ ] `pyglet.sprite.Sprite` patch - [ ] `pyglet.math.Vec2` patch (doing) + - [ ] main Calculate protocol + - [ ] other protocols - [ ] `pyglet.math.Vec3` patch (doing) + - [ ] main Calculate protocol + - [ ] other protocols - [ ] `pyglet.math.Vec4` patch (doing) + - [ ] main Calculate protocol + - [ ] other protocols - [ ] `pyglet.math.Mat3(tuple)` patch (doing) + - [ ] main Calculate protocol + - [ ] other protocols - [ ] `pyglet.math.Mat4(tuple)` patch (doing) + - [ ] main Calculate protocol + - [ ] other protocols diff --git a/libs/pyglet_rs/src/src/pymath.rs b/libs/pyglet_rs/src/src/pymath.rs index b4ea9d9..d7e4211 100644 --- a/libs/pyglet_rs/src/src/pymath.rs +++ b/libs/pyglet_rs/src/src/pymath.rs @@ -98,6 +98,28 @@ pub mod python_class { fn __repr__(&self) -> String { return format!("Vector2_rs({}, {})", self.data.x, self.data.y); } + + // gettter and setter + + #[getter] + fn get_x(&self) -> f64 { + return self.data.x; + } + + #[getter] + fn get_y(&self) -> f64 { + return self.data.y; + } + + #[setter] + fn set_x(&mut self, x: f64) { + self.data.x = x; + } + + #[setter] + fn set_y(&mut self, y: f64) { + self.data.y = y; + } } #[pymethods] @@ -145,6 +167,38 @@ pub mod python_class { self.data.x, self.data.y, self.data.z ); } + + // getter and setter + + #[getter] + fn get_x(&self) -> f64 { + return self.data.x; + } + + #[getter] + fn get_y(&self) -> f64 { + return self.data.y; + } + + #[getter] + fn get_z(&self) -> f64 { + return self.data.z; + } + + #[setter] + fn set_x(&mut self, x: f64) { + self.data.x = x; + } + + #[setter] + fn set_y(&mut self, y: f64) { + self.data.y = y; + } + + #[setter] + fn set_z(&mut self, z: f64) { + self.data.z = z; + } } #[pymethods]