2016-07-11 23:01:57 +02:00
|
|
|
#!/usr/bin/env python3
|
2014-03-16 18:26:12 +01:00
|
|
|
# Copyright (C) 2013-2014 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 <http://www.gnu.org/licenses/>.
|
2014-03-15 15:10:44 +01:00
|
|
|
|
|
|
|
from boxes import *
|
|
|
|
import math
|
|
|
|
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2014-03-15 15:10:44 +01:00
|
|
|
class Folder(Boxes):
|
2016-03-15 21:29:03 +01:00
|
|
|
"""Book cover with flex for the spine"""
|
2014-03-15 15:10:44 +01:00
|
|
|
|
2016-03-03 13:27:22 +01:00
|
|
|
def __init__(self):
|
|
|
|
Boxes.__init__(self)
|
2016-11-01 14:03:07 +01:00
|
|
|
self.addSettingsArgs(edges.FingerJointSettings)
|
2016-03-03 13:27:22 +01:00
|
|
|
self.buildArgParser("x", "y", "h")
|
|
|
|
self.argparser.add_argument(
|
2016-03-08 22:27:55 +01:00
|
|
|
"--r", action="store", type=float, default=10.0,
|
2016-03-03 13:27:22 +01:00
|
|
|
help="radius of the corners")
|
|
|
|
self.argparser.set_defaults(h=20)
|
2014-03-15 15:10:44 +01:00
|
|
|
|
|
|
|
def render(self):
|
|
|
|
x, y, r, h = self.x, self.y, self.r, self.h
|
|
|
|
c2 = math.pi * h
|
2016-06-07 20:20:35 +02:00
|
|
|
self.open()
|
2016-08-17 15:07:41 +02:00
|
|
|
self.moveTo(r + self.thickness, self.thickness)
|
|
|
|
self.edge(x - r)
|
2016-04-02 20:52:27 +02:00
|
|
|
self.edges["X"](c2, y)
|
2016-08-17 15:07:41 +02:00
|
|
|
self.edge(x - r)
|
2014-03-15 15:10:44 +01:00
|
|
|
self.corner(90, r)
|
2016-08-17 15:07:41 +02:00
|
|
|
self.edge(y - 2 * r)
|
2014-03-15 15:10:44 +01:00
|
|
|
self.corner(90, r)
|
2016-08-17 15:07:41 +02:00
|
|
|
self.edge(2 * x - 2 * r + c2)
|
2014-03-15 15:10:44 +01:00
|
|
|
self.corner(90, r)
|
2016-08-17 15:07:41 +02:00
|
|
|
self.edge(y - 2 * r)
|
2014-03-15 15:10:44 +01:00
|
|
|
self.corner(90, r)
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2014-03-21 21:08:54 +01:00
|
|
|
self.close()
|
2014-03-15 15:10:44 +01:00
|
|
|
|
2016-03-23 22:05:06 +01:00
|
|
|
|
|
|
|
def main():
|
2016-03-03 13:27:22 +01:00
|
|
|
f = Folder()
|
|
|
|
f.parseArgs()
|
|
|
|
f.render()
|
2016-03-23 22:05:06 +01:00
|
|
|
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-03-23 22:05:06 +01:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|