Skip to content

Commit

Permalink
fix: negative dx/dy in feOffset (#2515)
Browse files Browse the repository at this point in the history
# Summary

While working on #2514 I've noticed that negative dx/dy were treated as
positive.

## Test Plan

Add FeOffset filter with negative dx/dy to an element. It should move
closer to upper left corner.

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| Android |    ✅      |
  • Loading branch information
jakex7 authored Oct 28, 2024
1 parent e6a27f8 commit eb4889c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion android/src/main/java/com/horcrux/svg/FeOffsetView.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ public Bitmap applyFilter(HashMap<String, Bitmap> resultsMap, Bitmap prevResult)
float dy = this.mDy != null ? (float) this.relativeOnHeight(this.mDy) : 0;
RectF frame = new RectF(0, 0, dx, dy);
this.getSvgView().getCtm().mapRect(frame);
dx = frame.left < 0 ? frame.left : frame.width();
dy = frame.top < 0 ? frame.top : frame.height();

canvas.drawBitmap(source, frame.width(), frame.height(), null);
canvas.drawBitmap(source, dx, dy, null);

return result;
}
Expand Down

0 comments on commit eb4889c

Please sign in to comment.