mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-09 20:31:29 +11:00
Add kurbo conversions
Adds kurbo as an optional dependency and implements conversions to/from the common types. This also removes the direct pinot dependency and changes moscato (temporarily) to a git based dep to allow iteration on the underlying glyph loading code without PR churn here.
This commit is contained in:
parent
f5a721d92b
commit
94f7b51bc5
26
Cargo.lock
generated
26
Cargo.lock
generated
|
@ -42,6 +42,12 @@ version = "0.5.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "arrayvec"
|
||||||
|
version = "0.7.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ash"
|
name = "ash"
|
||||||
version = "0.33.3+1.2.191"
|
version = "0.33.3+1.2.191"
|
||||||
|
@ -596,7 +602,16 @@ version = "0.7.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "16cb54cd28cb3d2e964d9444ca185676a94fd9b7cce5f02b22c717947ed8e9a2"
|
checksum = "16cb54cd28cb3d2e964d9444ca185676a94fd9b7cce5f02b22c717947ed8e9a2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec 0.5.2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "kurbo"
|
||||||
|
version = "0.8.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7a53776d271cfb873b17c618af0298445c88afc52837f3e948fa3fafd131f449"
|
||||||
|
dependencies = [
|
||||||
|
"arrayvec 0.7.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -755,8 +770,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "moscato"
|
name = "moscato"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/dfrg/pinot#59db153ff83420449a909dfaace18466bddbf814"
|
||||||
checksum = "8372f6cdc8b2c431750a9c4edbc8d9c511ef1a68472aaa02500493414a407c64"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"pinot",
|
"pinot",
|
||||||
]
|
]
|
||||||
|
@ -954,7 +968,7 @@ version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f00543608fb5ee6063f5ff1259246ae23073c1a5e413e643d0469da3d4b7b4de"
|
checksum = "f00543608fb5ee6063f5ff1259246ae23073c1a5e413e643d0469da3d4b7b4de"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"kurbo",
|
"kurbo 0.7.1",
|
||||||
"unic-bidi",
|
"unic-bidi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1012,7 +1026,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"clap",
|
"clap",
|
||||||
"kurbo",
|
"kurbo 0.7.1",
|
||||||
"piet-gpu",
|
"piet-gpu",
|
||||||
"piet-gpu-hal",
|
"piet-gpu-hal",
|
||||||
"rand",
|
"rand",
|
||||||
|
@ -1031,8 +1045,8 @@ name = "piet-scene"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
"kurbo 0.8.3",
|
||||||
"moscato",
|
"moscato",
|
||||||
"pinot",
|
|
||||||
"smallvec",
|
"smallvec",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -7,5 +7,5 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bytemuck = { version = "1.7.2", features = ["derive"] }
|
bytemuck = { version = "1.7.2", features = ["derive"] }
|
||||||
smallvec = "1.8.0"
|
smallvec = "1.8.0"
|
||||||
pinot = "0.1.5"
|
moscato = { git = "https://github.com/dfrg/pinot" }
|
||||||
moscato = "0.1.2"
|
kurbo = { version = "0.8.3", optional = true }
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
//
|
//
|
||||||
// Also licensed under MIT license, at your choice.
|
// Also licensed under MIT license, at your choice.
|
||||||
|
|
||||||
pub use pinot;
|
pub use moscato::pinot;
|
||||||
|
|
||||||
use crate::brush::{Brush, Color};
|
use crate::brush::{Brush, Color};
|
||||||
use crate::geometry::Affine;
|
use crate::geometry::Affine;
|
||||||
|
|
|
@ -20,3 +20,96 @@ pub mod glyph;
|
||||||
pub mod path;
|
pub mod path;
|
||||||
pub mod resource;
|
pub mod resource;
|
||||||
pub mod scene;
|
pub mod scene;
|
||||||
|
|
||||||
|
/// Implement conversions to and from Kurbo types when the `kurbo` feature is
|
||||||
|
/// enabled.
|
||||||
|
#[cfg(feature = "kurbo")]
|
||||||
|
mod kurbo_conv {
|
||||||
|
use super::geometry::{Affine, Point, Rect};
|
||||||
|
use super::path::Element;
|
||||||
|
|
||||||
|
impl From<kurbo::Point> for Point {
|
||||||
|
fn from(p: kurbo::Point) -> Self {
|
||||||
|
Self::new(p.x as f32, p.y as f32)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Point> for kurbo::Point {
|
||||||
|
fn from(p: Point) -> kurbo::Point {
|
||||||
|
Self::new(p.x as f64, p.y as f64)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<kurbo::Affine> for Affine {
|
||||||
|
fn from(a: kurbo::Affine) -> Self {
|
||||||
|
let c = a.as_coeffs();
|
||||||
|
Self {
|
||||||
|
xx: c[0] as f32,
|
||||||
|
yx: c[1] as f32,
|
||||||
|
xy: c[2] as f32,
|
||||||
|
yy: c[3] as f32,
|
||||||
|
dx: c[4] as f32,
|
||||||
|
dy: c[5] as f32,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Affine> for kurbo::Affine {
|
||||||
|
fn from(a: Affine) -> Self {
|
||||||
|
Self::new([
|
||||||
|
a.xx as f64,
|
||||||
|
a.yx as f64,
|
||||||
|
a.yx as f64,
|
||||||
|
a.yy as f64,
|
||||||
|
a.dx as f64,
|
||||||
|
a.dy as f64,
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<kurbo::Rect> for Rect {
|
||||||
|
fn from(r: kurbo::Rect) -> Self {
|
||||||
|
Self {
|
||||||
|
min: Point::new(r.x0 as f32, r.y0 as f32),
|
||||||
|
max: Point::new(r.x1 as f32, r.y1 as f32),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Rect> for kurbo::Rect {
|
||||||
|
fn from(r: Rect) -> Self {
|
||||||
|
Self {
|
||||||
|
x0: r.min.x as f64,
|
||||||
|
y0: r.min.y as f64,
|
||||||
|
x1: r.max.x as f64,
|
||||||
|
y1: r.max.y as f64,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<kurbo::PathEl> for Element {
|
||||||
|
fn from(e: kurbo::PathEl) -> Self {
|
||||||
|
use kurbo::PathEl::*;
|
||||||
|
match e {
|
||||||
|
MoveTo(p0) => Self::MoveTo(p0.into()),
|
||||||
|
LineTo(p0) => Self::LineTo(p0.into()),
|
||||||
|
QuadTo(p0, p1) => Self::QuadTo(p0.into(), p1.into()),
|
||||||
|
CurveTo(p0, p1, p2) => Self::CurveTo(p0.into(), p1.into(), p2.into()),
|
||||||
|
ClosePath => Self::Close,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Element> for kurbo::PathEl {
|
||||||
|
fn from(e: Element) -> Self {
|
||||||
|
use Element::*;
|
||||||
|
match e {
|
||||||
|
MoveTo(p0) => Self::MoveTo(p0.into()),
|
||||||
|
LineTo(p0) => Self::LineTo(p0.into()),
|
||||||
|
QuadTo(p0, p1) => Self::QuadTo(p0.into(), p1.into()),
|
||||||
|
CurveTo(p0, p1, p2) => Self::CurveTo(p0.into(), p1.into(), p2.into()),
|
||||||
|
Close => Self::ClosePath,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue