Skip to content

Instantly share code, notes, and snippets.

@wesen
Created August 21, 2020 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wesen/09414b7902249cb9d41931b7caf645d3 to your computer and use it in GitHub Desktop.
Save wesen/09414b7902249cb9d41931b7caf645d3 to your computer and use it in GitHub Desktop.
import drawSvg as draw
d = draw.Drawing(254, 203, origin=(-10, -10), displayInline=False)
# Draw a rectangle
rec_height = 120
rec_width = 232
stroke_width = 0.2
d.append(draw.Rectangle(0, 0, rec_width, rec_height,
stroke='black', stroke_width=stroke_width,
fill='white', fill_opacity=0))
width_knobs = 180.0
width_single_knob = width_knobs / 7.0
for y in range(0, 3):
for x in range(0, 8):
circle_x = (17 + x * width_single_knob)
circle_y = rec_height - (26 + 32 * y)
d.append(draw.Circle(circle_x, circle_y, 20 / 2.0,
stroke='black', stroke_width=stroke_width,
fill='white', fill_opacity=0))
# d.setRenderSize(200, 100)
# so that 1 px = 1 mm
pixel_scale = 3.77953
d.setPixelScale(pixel_scale) # -> 14 mm x 7 mm
d.saveSvg('D:\\tmp\\example.svg')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment