mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-29 23:08:12 +08:00
Implement Bezier scale and offset (#718)
* Implement scale and offset * Add tests for offset and reduce * Added scale to documentation page * address comments Co-authored-by: Hannah Li <hannahli2010@gmail.com> Co-authored-by: Thomas Cheng <Androxium@users.noreply.github.com> Co-authored-by: Rob Nadal <RobNadal@users.noreply.github.com>
This commit is contained in:
committed by
Keavon Chambers
co-authored by
Thomas Cheng
Rob Nadal
parent
19483a9a35
commit
30e5d3c8ec
@@ -128,6 +128,16 @@ impl WasmBezier {
|
||||
to_js_value(local_extrema)
|
||||
}
|
||||
|
||||
pub fn bounding_box(&self) -> JsValue {
|
||||
let bbox_points: [Point; 2] = self.0.bounding_box().map(|p| Point { x: p.x, y: p.y });
|
||||
to_js_value(bbox_points)
|
||||
}
|
||||
|
||||
pub fn inflections(&self) -> JsValue {
|
||||
let inflections = self.0.inflections();
|
||||
to_js_value(inflections)
|
||||
}
|
||||
|
||||
pub fn de_casteljau_points(&self, t: f64) -> JsValue {
|
||||
let hull = self
|
||||
.0
|
||||
@@ -152,13 +162,8 @@ impl WasmBezier {
|
||||
to_js_value(bezier_points)
|
||||
}
|
||||
|
||||
pub fn bounding_box(&self) -> JsValue {
|
||||
let bbox_points: [Point; 2] = self.0.bounding_box().map(|p| Point { x: p.x, y: p.y });
|
||||
to_js_value(bbox_points)
|
||||
}
|
||||
|
||||
pub fn inflections(&self) -> JsValue {
|
||||
let inflections = self.0.inflections();
|
||||
to_js_value(inflections)
|
||||
pub fn offset(&self, distance: f64) -> JsValue {
|
||||
let bezier_points: Vec<Vec<Point>> = self.0.offset(distance).into_iter().map(bezier_to_points).collect();
|
||||
to_js_value(bezier_points)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user