Skip to content

Commit

Permalink
Translate before rotating
Browse files Browse the repository at this point in the history
  • Loading branch information
danielperano committed Mar 30, 2024
1 parent 037eb4d commit e41652d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Obsidian/src/main/java/myworld/obsidian/display/Renderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,6 @@ public void render(Canvas canvas, Bounds2D componentBounds, String styleDebugNam
).makeConcat(transform);
}

if (rotation != null) {
transform = Matrix33.makeRotate(-rotation.angle(),
new Point(componentBounds.left() + componentBounds.width() / 2f,
componentBounds.top() + componentBounds.height() / 2f))
.makeConcat(transform);
}

if (position != null) {
transform = Matrix33.makeTranslate(
// The shift by 0.5f aligns pixels so that they make a crisp line rather than a blurred one
Expand All @@ -157,6 +150,13 @@ public void render(Canvas canvas, Bounds2D componentBounds, String styleDebugNam
.makeConcat(transform);
}

if (rotation != null) {
transform = Matrix33.makeRotate(-rotation.angle(),
new Point(componentBounds.left() + componentBounds.width() / 2f,
componentBounds.top() + componentBounds.height() / 2f))
.makeConcat(transform);
}

if (geometry instanceof Path p) {
Path renderPath = new Path();

Expand Down

0 comments on commit e41652d

Please sign in to comment.