Skip to content

Commit

Permalink
Fix radius limit
Browse files Browse the repository at this point in the history
  • Loading branch information
deadlink committed Apr 18, 2024
1 parent 2cf5634 commit 7c97006
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/core/layers/rectangle.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class RectangleLayer extends AbstractLayer {
w: {
getValue: () => this.size.x,
setValue: (v: number) => {
this.size.x = Math.max(v, 1);
this.size.x = Math.max(v, this.radius * 2 + 2);
this.updateBounds();
this.draw();
},
Expand All @@ -52,7 +52,7 @@ export class RectangleLayer extends AbstractLayer {
h: {
getValue: () => this.size.y,
setValue: (v: number) => {
this.size.y = Math.max(v, 1);
this.size.y = Math.max(v, this.radius * 2 + 2);
this.updateBounds();
this.draw();
},
Expand All @@ -61,7 +61,10 @@ export class RectangleLayer extends AbstractLayer {
radius: {
getValue: () => this.radius,
setValue: (v: number) => {
this.radius = Math.max(0, Math.min(v, Math.round(this.size.x / 2), Math.round(this.size.y / 2)));
this.radius = Math.max(
0,
Math.min(v, Math.round(this.size.x / 2 - 1), Math.round(this.size.y / 2 - 1))
);
this.draw();
},
type: TModifierType.number
Expand Down Expand Up @@ -121,7 +124,7 @@ export class RectangleLayer extends AbstractLayer {
this.size = this.editState.size
.clone()
.subtract(offset)
.max(new Point(this.radius * 2));
.max(new Point(this.radius * 2 + 2));
}
},
{
Expand All @@ -138,7 +141,7 @@ export class RectangleLayer extends AbstractLayer {
this.size = this.editState.size
.clone()
.add(offset.x, -offset.y)
.max(new Point(this.radius * 2));
.max(new Point(this.radius * 2 + 2));
}
},
{
Expand All @@ -150,7 +153,7 @@ export class RectangleLayer extends AbstractLayer {
this.size = this.editState.size
.clone()
.add(offset)
.max(new Point(this.radius * 2));
.max(new Point(this.radius * 2 + 2));
}
}
];
Expand Down

0 comments on commit 7c97006

Please sign in to comment.