Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

Commit

Permalink
fix: handling of rounded rect
Browse files Browse the repository at this point in the history
  • Loading branch information
msand committed Sep 27, 2019
1 parent 70c54e6 commit c12d66e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
15 changes: 10 additions & 5 deletions android/src/main/java/com/horcrux/svg/RectView.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,19 @@ Path getPath(Canvas canvas, Paint paint) {
double y = relativeOnHeight(mY);
double w = relativeOnWidth(mW);
double h = relativeOnHeight(mH);
double rx = relativeOnWidth(mRx);
double ry = relativeOnHeight(mRy);

if (rx != 0 || ry != 0) {
if (rx == 0) {
if (mRx != null || mRy != null) {
double rx = 0d;
double ry = 0d;
if (mRx == null) {
ry = relativeOnHeight(mRy);
rx = ry;
} else if (ry == 0) {
} else if (mRy == null) {
rx = relativeOnWidth(mRx);
ry = rx;
} else {
rx = relativeOnWidth(mRx);
ry = relativeOnHeight(mRy);
}

if (rx > w / 2) {
Expand Down
15 changes: 10 additions & 5 deletions ios/Shapes/RNSVGRect.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,19 @@ - (CGPathRef)getPath:(CGContextRef)context
CGFloat y = [self relativeOnHeight:self.y];
CGFloat width = [self relativeOnWidth:self.rectwidth];
CGFloat height = [self relativeOnHeight:self.rectheight];
CGFloat rx = [self relativeOnWidth:self.rx];
CGFloat ry = [self relativeOnHeight:self.ry];

if (rx != 0 || ry != 0) {
if (rx == 0) {
if (self.rx != nil || self.ry != nil) {
CGFloat rx = 0;
CGFloat ry = 0;
if (self.rx == nil) {
ry = [self relativeOnHeight:self.ry];
rx = ry;
} else if (ry == 0) {
} else if (self.ry == nil) {
rx = [self relativeOnWidth:self.rx];
ry = rx;
} else {
rx = [self relativeOnWidth:self.rx];
ry = [self relativeOnHeight:self.ry];
}

if (rx > width / 2) {
Expand Down
2 changes: 0 additions & 2 deletions src/elements/Rect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ export default class Rect extends Shape<{
y: 0,
width: 0,
height: 0,
rx: 0,
ry: 0,
};

render() {
Expand Down

0 comments on commit c12d66e

Please sign in to comment.