Browse Source

Draw bottom / top

main
Matthias Neeracher 7 months ago
parent
commit
1159f28855
1 changed files with 20 additions and 6 deletions
  1. +20
    -6
      battery-case-generator.py

+ 20
- 6
battery-case-generator.py View File

@@ -38,8 +38,8 @@ else:

GRID = args.hole+args.padding
RADIUS = args.hole/2
DIMX = 2*(args.dimension+2)*GRID
DIMY = (args.dimension+2)*GRID
DIMX = 2*(args.dimension+1)*GRID
DIMY = 2*(args.dimension+1)*GRID
PI3 = math.pi/3

def draw_grid(cx, cy):
@@ -73,13 +73,27 @@ def draw_plane(cx, cy, interior=False):
turtle.forward(leg)
turtle.right(60)
else:
num_fingers = int(radius/args.horizontal_finger/2)
leg = (radius-(2*num_fingers-1)*args.horizontal_finger-args.kerf)/2
for side in range(6):
turtle.forward(radius)
turtle.forward(leg)
for finger in range(num_fingers):
turtle.right(90)
turtle.forward(args.thickness)
turtle.left(90)
turtle.forward(args.horizontal_finger+args.kerf)
turtle.left(90)
turtle.forward(args.thickness)
turtle.right(90)
turtle.forward(leg if finger == num_fingers-1 else args.horizontal_finger-args.kerf)
turtle.right(60)
print('<path d="%s" fill="none" stroke="black"/>' % turtle.to_s())

print('<svg viewBox="0 0 %.2f %.2f" width="%.2fmm" height="%.2fmm" stroke-width="0.1" xmlns="http://www.w3.org/2000/svg">' % (DIMX, DIMY, DIMX, DIMY))
draw_grid(GRID*(0.5*args.dimension+1), GRID*(0.5*args.dimension+1))
draw_plane(GRID*(0.5*args.dimension+1), GRID*(0.5*args.dimension+1), True)
draw_plane(GRID*(1.5*args.dimension+3), GRID*(0.5*args.dimension+1))
draw_grid(GRID*(0.5*args.dimension+0.5), GRID*(0.5*args.dimension+1))
draw_grid(GRID*(1.5*args.dimension+1.5), GRID*(0.5*args.dimension+1))
draw_plane(GRID*(0.5*args.dimension+0.5), GRID*(0.5*args.dimension+1), True)
draw_plane(GRID*(1.5*args.dimension+1.5), GRID*(0.5*args.dimension+1), True)
draw_plane(GRID*(0.5*args.dimension+0.5), GRID*(1.5*args.dimension+1))
draw_plane(GRID*(1.5*args.dimension+1.5), GRID*(1.5*args.dimension+1))
print('</svg>')

Loading…
Cancel
Save