Skip to content

Commit

Permalink
Refactored BezierCurve into a Matrix
Browse files Browse the repository at this point in the history
Making SmallVec obsolete
  • Loading branch information
gammelalf committed Sep 7, 2022
1 parent 8f8fbfd commit 3cf843d
Show file tree
Hide file tree
Showing 6 changed files with 630 additions and 789 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ default = []

[dependencies]
nalgebra = "0.31"
num = { version = "0.4" }
smallvec = { version = "1.8" }

[dev-dependencies]
once_cell = "1.11"
pprof = { version = "0.9", features = ["flamegraph", "protobuf-codec", "criterion"] }
criterion = { version = "0.3", features = ["html_reports"] }
dhat = { version = "0.3" }

[[bench]]
name = "flamegraph"
Expand Down
17 changes: 9 additions & 8 deletions examples/svg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use nbezier::bezier::BezierCurve;
use nalgebra::Vector2;
use smallvec::smallvec;
use nalgebra::{Matrix2xX, Vector2};
use nbezier::nbezier::BezierCurve;

#[path = "../src/svg.rs"]
mod svg;
Expand All @@ -11,14 +10,16 @@ fn main() {
view_box: (0.0, 0.0, 100.0, 100.0),
elements: Vec::with_capacity(0),
};
let curve = BezierCurve(smallvec![
let curve = BezierCurve(Matrix2xX::from_columns(&[
Vector2::new(50.0, 0.0),
Vector2::new(200.0, 33.0),
Vector2::new(0.0, 66.0),
Vector2::new(50.0, 100.0),
]);
let (upper, lower) = curve.split(0.7);
svg.debug_bezier(&upper, "blue");
svg.debug_bezier(&lower, "red");
]));

let [lower, upper] = curve.split(0.7);
svg.debug_bezier(&upper, "red");
svg.debug_bezier(&lower, "blue");

println!("{}", svg);
}
Loading

0 comments on commit 3cf843d

Please sign in to comment.