From 9a46882c8fb647a86b51d9f93135a6b661960190 Mon Sep 17 00:00:00 2001 From: jens persson Date: Tue, 1 Jun 2021 21:59:21 +0200 Subject: [PATCH] Add color selection to all holes All methods that uses the holeCol decorator now take a parameter color. Added semantic symbols for colors. --- boxes/Color.py | 6 ++++++ boxes/__init__.py | 7 ++++++- boxes/generators/drillbox.py | 5 ++--- documentation/src/usermanual.rst | 17 +++++++++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/boxes/Color.py b/boxes/Color.py index 1655e81..d16940a 100644 --- a/boxes/Color.py +++ b/boxes/Color.py @@ -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 diff --git a/boxes/__init__.py b/boxes/__init__.py index 541136a..1d1b527 100755 --- a/boxes/__init__.py +++ b/boxes/__init__.py @@ -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() diff --git a/boxes/generators/drillbox.py b/boxes/generators/drillbox.py index b1d1fde..f6244c0 100644 --- a/boxes/generators/drillbox.py +++ b/boxes/generators/drillbox.py @@ -66,8 +66,7 @@ class DrillBox(Boxes): 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, @@ -75,7 +74,7 @@ class DrillBox(Boxes): 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 diff --git a/documentation/src/usermanual.rst b/documentation/src/usermanual.rst index 1d2b389..f202ef7 100644 --- a/documentation/src/usermanual.rst +++ b/documentation/src/usermanual.rst @@ -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. \ No newline at end of file