still in dev pyglet_rs
This commit is contained in:
parent
1e4fcb48e9
commit
2abd346059
@ -14,10 +14,35 @@ if TYPE_CHECKING:
|
|||||||
def get_version_str() -> str: ...
|
def get_version_str() -> str: ...
|
||||||
|
|
||||||
|
|
||||||
class Sprite_rs(EventDispatcher):
|
class Sprite_rs(EventDispatcher): ...
|
||||||
...
|
|
||||||
|
class Vector2_rs: ...
|
||||||
|
class Vector3_rs: ...
|
||||||
|
class Vector4_rs: ...
|
||||||
|
|
||||||
|
class Matrix3_rs: ...
|
||||||
|
class Matrix4_rs: ...
|
||||||
|
|
||||||
|
|
||||||
def patch_sprite():
|
def patch_sprite():
|
||||||
from pyglet import sprite
|
from pyglet import sprite
|
||||||
sprite.Sprite = Sprite_rs
|
sprite.Sprite = Sprite_rs
|
||||||
|
|
||||||
|
|
||||||
|
def patch_vector():
|
||||||
|
from pyglet import math
|
||||||
|
math.Vector2 = Vector2_rs
|
||||||
|
math.Vector3 = Vector3_rs
|
||||||
|
math.Vector4 = Vector4_rs
|
||||||
|
|
||||||
|
|
||||||
|
def patch_matrix():
|
||||||
|
from pyglet import math
|
||||||
|
math.Matrix3 = Matrix3_rs
|
||||||
|
math.Matrix4 = Matrix4_rs
|
||||||
|
|
||||||
|
|
||||||
|
def patch_all():
|
||||||
|
patch_sprite()
|
||||||
|
patch_vector()
|
||||||
|
patch_matrix()
|
||||||
|
@ -22,5 +22,7 @@ fn get_version_str() -> String {
|
|||||||
fn module_init(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
|
fn module_init(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
|
||||||
m.add_function(wrap_pyfunction!(get_version_str, m)?)?;
|
m.add_function(wrap_pyfunction!(get_version_str, m)?)?;
|
||||||
m.add_class::<sprite::Sprite>()?;
|
m.add_class::<sprite::Sprite>()?;
|
||||||
|
// vector
|
||||||
|
m.add_class::<pymath::python_class::PyVector2>()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -12,27 +12,27 @@ pub mod python_class {
|
|||||||
use crate::math::matrix::{Matrix3, Matrix4};
|
use crate::math::matrix::{Matrix3, Matrix4};
|
||||||
use crate::math::vector::{Vector2, Vector3, Vector4, VectorTrait};
|
use crate::math::vector::{Vector2, Vector3, Vector4, VectorTrait};
|
||||||
|
|
||||||
#[pyclass(name = "Vector2")]
|
#[pyclass(name = "Vector2_rs")]
|
||||||
pub struct PyVector2 {
|
pub struct PyVector2 {
|
||||||
pub data: Vector2,
|
pub data: Vector2,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pyclass(name = "Vector3")]
|
#[pyclass(name = "Vector3_rs")]
|
||||||
pub struct PyVector3 {
|
pub struct PyVector3 {
|
||||||
pub data: Vector3,
|
pub data: Vector3,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pyclass(name = "Vector4")]
|
#[pyclass(name = "Vector4_rs")]
|
||||||
pub struct PyVector4 {
|
pub struct PyVector4 {
|
||||||
pub data: Vector4,
|
pub data: Vector4,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pyclass(name = "Matrix3")]
|
#[pyclass(name = "Matrix3_rs")]
|
||||||
pub struct PyMatrix3 {
|
pub struct PyMatrix3 {
|
||||||
pub data: Matrix3,
|
pub data: Matrix3,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pyclass(name = "Matrix4")]
|
#[pyclass(name = "Matrix4_rs")]
|
||||||
pub struct PyMatrix4 {
|
pub struct PyMatrix4 {
|
||||||
pub data: Matrix4,
|
pub data: Matrix4,
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
use pyo3::intern;
|
use pyo3::intern;
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
use pyo3::types::PyDict;
|
// use pyo3::types::PyDict;
|
||||||
|
|
||||||
/// Instance of an on-screen image
|
/// Instance of an on-screen image
|
||||||
/// See the module documentation for usage.
|
/// See the module documentation for usage.
|
||||||
|
Loading…
Reference in New Issue
Block a user