add skew to transform tool

This commit is contained in:
Skyler Lehmkuhl
2025-11-19 10:59:18 -05:00
parent 258b131f2d
commit 0d8fa7ffbd
4 changed files with 388 additions and 5 deletions
@@ -90,6 +90,8 @@ impl Transform {
}
/// Convert to an affine transform matrix
/// Note: Skew is applied in local space. For proper centering, the shape's
/// bounding box center should be used (see renderer.rs for the full implementation).
pub fn to_affine(&self) -> kurbo::Affine {
use kurbo::Affine;
@@ -98,7 +100,7 @@ impl Transform {
let rotate = Affine::rotate(self.rotation.to_radians());
let scale = Affine::scale_non_uniform(self.scale_x, self.scale_y);
// Skew transforms
// Skew transforms (applied in local space)
let skew_x = if self.skew_x != 0.0 {
let tan_skew = self.skew_x.to_radians().tan();
Affine::new([1.0, 0.0, tan_skew, 1.0, 0.0, 0.0])