PaintStorage: Add support for hexagonal hole patterns

This commit is contained in:
Florian Festi 2018-10-29 18:16:16 +01:00
parent 36077e6cb0
commit fe89528e05
1 changed files with 11 additions and 1 deletions

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from boxes import Boxes, edges from boxes import Boxes, edges, boolarg
class PaintStorage(Boxes): class PaintStorage(Boxes):
"""Stackable paint storage""" """Stackable paint storage"""
@ -39,9 +39,19 @@ class PaintStorage(Boxes):
self.argparser.add_argument( self.argparser.add_argument(
"--minspace", action="store", type=int, default=10, "--minspace", action="store", type=int, default=10,
help="Minimum space between the paintcans") help="Minimum space between the paintcans")
self.argparser.add_argument(
"--hexpattern", action="store", type=boolarg, default=False,
help="Use hexagonal arrangement for the holes instead of orthogonal")
def paintholes(self): def paintholes(self):
"Place holes for the paintcans evenly" "Place holes for the paintcans evenly"
if self.hexpattern:
self.moveTo(self.minspace/2, self.minspace/2)
self.hexHolesRectangle(self.y - 1*self.minspace,
self.x - 1*self.minspace,
(self.candiameter/2, self.minspace, 'circle'))
return
n_x = int(self.x / (self.candiameter+self.minspace)) n_x = int(self.x / (self.candiameter+self.minspace))
n_y = int(self.y / (self.candiameter+self.minspace)) n_y = int(self.y / (self.candiameter+self.minspace))
spacing_x = (self.x - n_x*self.candiameter)/n_x spacing_x = (self.x - n_x*self.candiameter)/n_x