|
@@ -318,15 +318,6 @@ impl ObjectModifier {
|
|
|
|
|
|
/// Returns origin, width, and height of bounding box after applying scale, skew, and offset corrections
|
|
|
pub fn corrected(&self, pt1: Point, pt2: Point) -> (Point, f64, f64) {
|
|
|
- debug!(
|
|
|
- "Skew degree from X axis: {:.2}",
|
|
|
- self.modifiers.x_skew.asin().to_degrees()
|
|
|
- );
|
|
|
- debug!(
|
|
|
- "Skew degree from Y axis: {:.2}",
|
|
|
- self.modifiers.y_skew.asin().to_degrees()
|
|
|
- );
|
|
|
-
|
|
|
// Calculate 4 points of drawn rectangle
|
|
|
let corners: Vec<Point> = vec![
|
|
|
Point {
|
|
@@ -359,9 +350,20 @@ impl ObjectModifier {
|
|
|
// Apply skew, then scale and translation
|
|
|
let corners: Vec<Point> = corners
|
|
|
.iter()
|
|
|
- .map(|pt| Point {
|
|
|
- x: pt.x + pt.y * self.modifiers.x_skew.asin().tan(),
|
|
|
- y: pt.y + pt.x * self.modifiers.y_skew.asin().tan(),
|
|
|
+ .map(|pt| {
|
|
|
+ // TODO: WTF is this and why is it necessary?
|
|
|
+ // Seems to be correct as far as calculation of correct origin..
|
|
|
+ if self.modifiers.x_skew == 0.0 || self.modifiers.y_skew == 0.0 {
|
|
|
+ Point {
|
|
|
+ x: pt.x + pt.y * self.modifiers.x_skew,
|
|
|
+ y: pt.y + pt.x * self.modifiers.y_skew,
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Point {
|
|
|
+ x: pt.x + pt.y * self.modifiers.x_skew.asin().tan(),
|
|
|
+ y: pt.y + pt.x * self.modifiers.y_skew.asin().tan(),
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
.inspect(|pt| debug!("pt: {pt}"))
|
|
|
.map(|pt| pt * self.scale() + self.translation())
|