From 279b60abc85574958c990569fb8737d2b9ac5140 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Tue, 28 Apr 2020 22:25:47 +0200 Subject: [PATCH] New generator: Console --- boxes/generators/console.py | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 boxes/generators/console.py diff --git a/boxes/generators/console.py b/boxes/generators/console.py new file mode 100644 index 0000000..c707e8f --- /dev/null +++ b/boxes/generators/console.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 +# Copyright (C) 2013-2016 Florian Festi +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from boxes import * + +class Console(Boxes): + """Console with slanted panel""" + + ui_group = "Box" + + def __init__(self): + Boxes.__init__(self) + + self.addSettingsArgs(edges.FingerJointSettings, surroundingspaces=.5) + self.addSettingsArgs(edges.StackableSettings) + + self.buildArgParser(x=100, y=100, h=100, hi=30) + self.argparser.add_argument( + "--angle", action="store", type=float, default=50, + help="angle of the front panel (90°=upright)") + + def render(self): + x, y, h, hi = self.x, self.y, self.h, self.hi + t = self.thickness + + panel = min((h-hi)/math.cos(math.radians(90-self.angle)), + y/math.cos(math.radians(self.angle))) + top = y - panel * math.cos(math.radians(self.angle)) + h = hi + panel * math.sin(math.radians(self.angle)) + + if top>0.1*t: + borders = [x, 90, hi, 90-self.angle, panel, self.angle, top, + 90, h, 90] + else: + borders = [x, 90, hi, 90-self.angle, panel, self.angle+90, h, 90] + + self.polygonWall(borders, move="right") + self.polygonWall(borders, move="right") + self.polygonWalls(borders, y)