Bläddra i källkod

Update tuckbox with flap that closes properly

Weiyi Lou 3 år sedan
förälder
incheckning
77f7d47a92
1 ändrade filer med 45 tillägg och 29 borttagningar
  1. 45 29
      box_generator/box_generator_extension.py

+ 45 - 29
box_generator/box_generator_extension.py

@@ -94,32 +94,34 @@ class BoxGenerator(Extension):
         width_mm = float(self.widthInput.text())
         height_mm = float(self.heightInput.text())
         # Assume input is in mm.
-        pts_per_mm = 300 / 25.4
-        length = length_mm * pts_per_mm
-        height = height_mm * pts_per_mm
-        width = width_mm * pts_per_mm
+        mm = 300 / 25.4
+        length = length_mm * mm
+        height = height_mm * mm
+        width = width_mm * mm
 
-        # Create outline using SVG.
+        # Create outline using SVG (starts from top left corner).
         if self.boxTypeInput.currentIndex() == 0: # Tuckbox
-            total_length = length * 2 +  height * 3
-            total_width = width +  height * 3
-            leeway = pts_per_mm / 2 # Make certain flaps shorter by 0.5mm to account for paper thickness.
-            
+
             stringy = f"""<svg style="stroke:black; fill:none; stroke-width:1">
                 <path d="
-                m {pts_per_mm+height*1.66}
+                m {1*mm+height*1.66}
                 h {length-height*2*0.66}
-                a {height*0.66} {height*0.66} 0 0 1 {height*0.66} {height*0.66}
-                v {height}
+                a {height*0.7} {height*0.7} 0 0 1 {height*0.66 - 0.7*mm} {height*0.66 - 0.25*mm}
+                h -{4*mm}
+                v {0.5*mm}
+                h {4.7*mm}
+                v {height - 0.25*mm}
                 l {height*0.1} -{height}
                 h {height*0.4}
-                a {height*0.5} {height} 0 0 1 {height*0.5} {height}
-                h {length+height-leeway}
-                v {width}
-                h -{height-leeway}
-                v {height-leeway}
+                a {height*0.5} {height} 0 0 1 {height*0.5-0.25*mm} {height-3.5*mm}
+                h {0.5*mm}
+                v {3.5*mm}
+                h {length+height-0.5*mm}
+                v {width-0.25*mm}
+                h -{height-0.25*mm}
+                v {height-0.25*mm}
                 h -{length}
-                v -{height-leeway}
+                v -{height-0.5*mm}
                 l -{height*0.1} {height}
                 h -{height*0.8}
                 l -{height*0.1} -{height}
@@ -130,24 +132,38 @@ class BoxGenerator(Extension):
                 h -{height*0.8}
                 l -{height*0.1} -{height}
                 v -{width}
-                a {height*0.5} {height} 0 0 1 {height*0.5} -{height}
+                h -{0.25*mm}
+                v -{3.5*mm}
+                h {0.5*mm}
+                a {height*0.5} {height} 0 0 1 {height*0.5-0.25*mm} -{height-3.5*mm}
                 h {height*0.4}
                 l {height*0.1} {height}
-                v -{height}
-                a {height*0.66} {height*0.66} 0 0 1 {height*0.66} -{height*0.66}
+                v -{height - 0.25*mm}
+                h {4.7*mm}
+                v -{0.5*mm}
+                h -{4*mm}
+                a {height*0.7} {height*0.7} 0 0 1 {height*0.66 - 0.7*mm} -{height*0.66 - 0.25*mm}
                 z
                 "></path>
                 <path d="
-                M {pts_per_mm+height} {height*0.66}
-                h -{pts_per_mm}
-                M {pts_per_mm+height+length} {height*0.66}
-                h {pts_per_mm}
+                M {1*mm+height} {height*0.66 + 0.25*mm}
+                h -{1*mm}
+                M {1*mm+height+length} {height*0.66 + 0.25*mm}
+                h {1*mm}
                 M 0 {height*1.66}
-                h {pts_per_mm}
+                h {1*mm}
                 M 0 {height*1.66+width}
-                h {pts_per_mm}
-                M {pts_per_mm+height*2+length*2} {height*1.66}
-                v -{pts_per_mm}
+                h {1*mm}
+                M {1*mm+height*2+length*2} {height*1.66}
+                v -{1*mm}
+                M {1*mm+height*2+length*2} {height*1.66+width}
+                h {1*mm}
+                M {1*mm} {height*1.66 - 3.5*mm}
+                v -{1*mm}
+                M {1*mm+height*2+length} {height*1.66 - 3.5*mm}
+                v -{1*mm}
+                M {1*mm+height*2+length} {height*1.66}
+                h {0.25*mm}
                 "></path>
                 </svg>"""