Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 0fc9846

Browse files
committed
Added code to sheck if the created circles, rectangles or lines have 0px size.
1 parent 48fa39f commit 0fc9846

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/tools/Ellipse.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@ module.exports = class Ellipse extends ToolWithStroke
2020
lc.drawShapeInProgress(@currentShape)
2121

2222
end: (x, y, lc) ->
23+
# If there is no height or width, dont save
24+
if @currentShape.height == 0 or @currentShape.width == 0
25+
return
2326
lc.saveShape(@currentShape)

src/tools/Line.coffee

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,9 @@ module.exports = class Line extends ToolWithStroke
2424
lc.drawShapeInProgress(@currentShape)
2525

2626
end: (x, y, lc) ->
27+
# If start == end, dont save
28+
sameX = @currentShape.x1 == @currentShape.x2
29+
sameY = @currentShape.y1 == @currentShape.y2
30+
if sameX and sameY
31+
return
2732
lc.saveShape(@currentShape)

src/tools/Rectangle.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ module.exports = class Rectangle extends ToolWithStroke
1919
lc.drawShapeInProgress(@currentShape)
2020

2121
end: (x, y, lc) ->
22+
# If there is no height or width, dont save
23+
if @currentShape.height == 0 or @currentShape.width == 0
24+
return
2225
lc.saveShape(@currentShape)

0 commit comments

Comments
 (0)