implement mint conversions (#352)
* Implement mint conversions Implement conversions for [mint](https://docs.rs/mint) (math interoperability standard types). - `impl {From, Into}<mint::Point2> for Pos2` - `impl {From, Into}<mint::Vector2> for Vec2` * Forward `mint` feature: egui -> epaint -> emath
This commit is contained in:
parent
2cb94b98ef
commit
87bc26fb5a
6 changed files with 47 additions and 1 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -823,6 +823,7 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
|
|||
name = "emath"
|
||||
version = "0.11.0"
|
||||
dependencies = [
|
||||
"mint",
|
||||
"serde",
|
||||
]
|
||||
|
||||
|
@ -1362,6 +1363,12 @@ dependencies = [
|
|||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mint"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "519df8d6856dcd4b40519947737b408f81be051fc032590659cae5d77d664185"
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "0.6.23"
|
||||
|
|
|
@ -37,5 +37,7 @@ persistence = ["serde", "epaint/persistence", "ron"]
|
|||
single_threaded = ["epaint/single_threaded"]
|
||||
multi_threaded = ["epaint/multi_threaded"]
|
||||
|
||||
mint = ["epaint/mint"]
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json = "1"
|
||||
serde_json = "1"
|
||||
|
|
|
@ -20,6 +20,7 @@ include = [
|
|||
[lib]
|
||||
|
||||
[dependencies]
|
||||
mint = { version = "0.5.6", optional = true }
|
||||
serde = { version = "1", features = ["derive"], optional = true }
|
||||
|
||||
[features]
|
||||
|
|
|
@ -84,6 +84,23 @@ impl From<&Pos2> for (f32, f32) {
|
|||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Mint compatibility and convenience conversions
|
||||
|
||||
#[cfg(feature = "mint")]
|
||||
impl From<mint::Point2<f32>> for Pos2 {
|
||||
fn from(v: mint::Point2<f32>) -> Self {
|
||||
Self::new(v.x, v.y)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "mint")]
|
||||
impl From<Pos2> for mint::Point2<f32> {
|
||||
fn from(v: Pos2) -> Self {
|
||||
Self { x: v.x, y: v.y }
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
impl Pos2 {
|
||||
|
|
|
@ -81,6 +81,23 @@ impl From<&Vec2> for (f32, f32) {
|
|||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Mint compatibility and convenience conversions
|
||||
|
||||
#[cfg(feature = "mint")]
|
||||
impl From<mint::Vector2<f32>> for Vec2 {
|
||||
fn from(v: mint::Vector2<f32>) -> Self {
|
||||
Self::new(v.x, v.y)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "mint")]
|
||||
impl From<Vec2> for mint::Vector2<f32> {
|
||||
fn from(v: Vec2) -> Self {
|
||||
Self { x: v.x, y: v.y }
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
impl Vec2 {
|
||||
|
|
|
@ -43,3 +43,5 @@ single_threaded = ["atomic_refcell"]
|
|||
|
||||
# Only needed if you plan to use the same fonts from multiple threads.
|
||||
multi_threaded = ["parking_lot"]
|
||||
|
||||
mint = ["emath/mint"]
|
||||
|
|
Loading…
Reference in a new issue