Skip to content

Commit

Permalink
Add color selection to all holes
Browse files Browse the repository at this point in the history
All methods that uses the holeCol decorator now take a parameter color.
Added semantic symbols for colors.
  • Loading branch information
MrShark authored and florianfesti committed Jun 3, 2021
1 parent c86ae75 commit 9a46882
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
6 changes: 6 additions & 0 deletions boxes/Color.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ class Color:
GREEN = [ 0.0, 1.0, 0.0 ]
RED = [ 1.0, 0.0, 0.0 ]
WHITE = [ 1.0, 1.0, 1.0 ]

# TODO: Make this configurable
OUTER_CUT = BLACK
INNER_CUT = BLUE
ANNOTATIONS = RED
ETCHING = GREEN
7 changes: 6 additions & 1 deletion boxes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,14 @@ def holeCol(func):

@wraps(func)
def f(self, *args, **kw):
if "color" in kw:
color = kw.pop("color")
else:
color = Color.INNER_CUT

self.ctx.stroke()
with self.saved_context():
self.set_source_color(Color.BLUE)
self.set_source_color(color)
func(self, *args, **kw)
self.ctx.stroke()

Expand Down
5 changes: 2 additions & 3 deletions boxes/generators/drillbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,15 @@ def drillholes(self, description=False):
for k in range(self.holes):
self.hole(x + dx / 2, y + (k + 0.5) * iy, d + 0.05)
if description:
self.rectangularHole(x + dx / 2, y + dy / 2, dx - 2, dy - 2)
# TODO: make the "hole" green to indicate etching
self.rectangularHole(x + dx / 2, y + dy / 2, dx - 2, dy - 2, color=Color.ETCHING)
self.text(
"%.1f" % d,
x + 2,
y + 2,
270,
align="right",
fontsize=6,
color=Color.GREEN,
color=Color.ETCHING,
)
# TODO: make the fontsize dynamic to make the text fit in all cases
d += self.holeincrement
Expand Down
17 changes: 17 additions & 0 deletions documentation/src/usermanual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,20 @@ settings to the user. In the web interface they are folded up. In the
command line interfacce they are grouped together. Users should be
aware that not all settings are practical to change. For now Boxes.py
does not allow hiding some settings.

Colors
------
The generated files uses the following color conventions:

.. glossary::
Black
The outer edges of a part
Blue
Inner edges of a part
Red
Comments or help lines that are not ment to be cut or etched
Green
Etchings

Normaly you will cut things in the order: Green, Blue, Black. If other
colors are present, the meaning should hopefully be obvious.

0 comments on commit 9a46882

Please sign in to comment.