mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-19 10:58:04 +08:00
Bezier-rs: Add a pivot point to the 'rotate' function (#792)
* Add function to rotate around a point * Update svg * Improve rotation line-to-center styling * Add second angle of lines Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
committed by
Keavon Chambers
parent
9eb2b9f6a3
commit
a695584d36
@@ -90,6 +90,12 @@ impl Bezier {
|
||||
self.apply_transformation(&|point| rotation_matrix.mul_vec2(point))
|
||||
}
|
||||
|
||||
/// Returns a Bezier curve that results from rotating the curve around the provided point by the given angle (in radians).
|
||||
pub fn rotate_about_point(&self, angle: f64, pivot: DVec2) -> Bezier {
|
||||
let rotation_matrix = DMat2::from_angle(angle);
|
||||
self.apply_transformation(&|point| rotation_matrix.mul_vec2(point - pivot) + pivot)
|
||||
}
|
||||
|
||||
/// Returns a Bezier curve that results from translating the curve by the given `DVec2`.
|
||||
pub fn translate(&self, translation: DVec2) -> Bezier {
|
||||
self.apply_transformation(&|point| point + translation)
|
||||
|
||||
Reference in New Issue
Block a user