mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-09 07:08:11 +08:00
Bezier-rs: Implement miter-limit (#1096)
* Implement miter-limit approximation * Refactor to use Join enum and address other comments * Rustdocs improvements * Tweaks --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
f49e62a51c
commit
d1630c73de
@@ -441,8 +441,8 @@ impl WasmSubpath {
|
||||
wrap_svg_tag(format!("{}{}", self.to_default_svg(), trimmed_subpath_svg))
|
||||
}
|
||||
|
||||
pub fn offset(&self, distance: f64, join: i32) -> String {
|
||||
let join = parse_join(join);
|
||||
pub fn offset(&self, distance: f64, join: i32, miter_limit: f64) -> String {
|
||||
let join = parse_join(join, miter_limit);
|
||||
let offset_subpath = self.0.offset(distance, join);
|
||||
|
||||
let mut offset_svg = String::new();
|
||||
@@ -451,8 +451,8 @@ impl WasmSubpath {
|
||||
wrap_svg_tag(format!("{}{offset_svg}", self.to_default_svg()))
|
||||
}
|
||||
|
||||
pub fn outline(&self, distance: f64, join: i32, cap: i32) -> String {
|
||||
let join = parse_join(join);
|
||||
pub fn outline(&self, distance: f64, join: i32, cap: i32, miter_limit: f64) -> String {
|
||||
let join = parse_join(join, miter_limit);
|
||||
let cap = parse_cap(cap);
|
||||
let (outline_piece1, outline_piece2) = self.0.outline(distance, join, cap);
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use bezier_rs::{Cap, Join};
|
||||
|
||||
pub fn parse_join(join: i32) -> Join {
|
||||
pub fn parse_join(join: i32, miter_limit: f64) -> Join {
|
||||
match join {
|
||||
0 => Join::Bevel,
|
||||
1 => Join::Miter,
|
||||
1 => Join::Miter(Some(miter_limit)),
|
||||
2 => Join::Round,
|
||||
_ => panic!("Unexpected Join value: '{}'", join),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user