Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rsheeter committed Jan 24, 2023
1 parent 489cca2 commit 53f1f7f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions shape-brokkr/src/reuse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,27 @@ fn vectors(path: &BezPath) -> Vec<Vec2> {
vecs
}

/// Build a version of shape that will compare == to other shapes even if offset, scaled, rotated, etc.
///
/// Intended use is to normalize multiple shapes to identify opportunity for reuse.
/// <https://github.com/googlefonts/picosvg/blob/69cbfec486eca35a46187405abc39f608d3b2963/src/picosvg/svg_reuse.py#L240>
///
/// At time of writing does *not* produce the same result for equivalent shapes with different point order
/// or drawing commands.
pub fn normalize(path: &BezPath) -> Result<BezPath, Error> {
// Always start at 0,0
let path = move_to_origin(path)?;

// Switch to vectors, which are intrinsically relative
let path = vectors(&path);

// TODO: Normalize first activity to [1 0]; eliminates rotation and uniform scaling

// TODO: Normalize first y activity to 1.0; eliminates mirroring and non-uniform scaling

todo!()
}

#[cfg(test)]
mod tests {
use kurbo::{BezPath, Vec2};
Expand Down

0 comments on commit 53f1f7f

Please sign in to comment.