Skip to content

Commit

Permalink
Add self._config["canvas"]["fill_drawing"]
Browse files Browse the repository at this point in the history
  • Loading branch information
wkentaro committed May 16, 2023
1 parent 8613cfc commit 43b7188
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion labelme/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,8 @@ def __init__(
checkable=True,
enabled=True,
)
fill_drawing.trigger()
if self._config["canvas"]["fill_drawing"]:
fill_drawing.trigger()

# Lavel list context menu.
labelMenu = QtWidgets.QMenu()
Expand Down
3 changes: 2 additions & 1 deletion labelme/config/default_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ label_colors: null
shape:
# drawing
line_color: [0, 255, 0, 128]
fill_color: [0, 255, 0, 0] # transparent
fill_color: [0, 255, 0, 64]
vertex_fill_color: [0, 255, 0, 255]
# selecting / hovering
select_line_color: [255, 255, 255, 255]
Expand Down Expand Up @@ -62,6 +62,7 @@ fit_to_content:
# canvas
epsilon: 10.0
canvas:
fill_drawing: false
# None: do nothing
# close: close polygon
double_click: close
Expand Down
7 changes: 7 additions & 0 deletions labelme/widgets/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import labelme.ai
from labelme import QT5
from labelme.logger import logger
from labelme.shape import Shape
import labelme.utils

Expand Down Expand Up @@ -735,6 +736,12 @@ def paintEvent(self, event):
and len(self.current.points) >= 2
):
drawing_shape = self.current.copy()
if drawing_shape.fill_color.getRgb()[3] == 0:
logger.warning(
"fill_drawing=true, but fill_color is transparent,"
" so forcing to be opaque."
)
drawing_shape.fill_color.setAlpha(64)
drawing_shape.addPoint(self.line[1])
drawing_shape.fill = True
drawing_shape.paint(p)
Expand Down

0 comments on commit 43b7188

Please sign in to comment.