Use mm as size and remove white background
This commit is contained in:
parent
8de9c304d6
commit
5d3edc1b6c
28
boxes.py
28
boxes.py
|
@ -471,17 +471,18 @@ class Boxes:
|
||||||
self.addPart(NutHole(self, None))
|
self.addPart(NutHole(self, None))
|
||||||
|
|
||||||
def _init_surface(self, width, height):
|
def _init_surface(self, width, height):
|
||||||
mm2pt = 90 / 25.4 / 1.25
|
#mm2pt = 90 / 25.4 / 1.25
|
||||||
width *= mm2pt
|
mm2pt = 1
|
||||||
height *= 3.543307
|
#width *= mm2pt
|
||||||
|
#height *= mm2pt #3.543307
|
||||||
self.surface = cairo.SVGSurface(self.output, width, height)
|
self.surface = cairo.SVGSurface(self.output, width, height)
|
||||||
self.ctx = ctx = cairo.Context(self.surface)
|
self.ctx = ctx = cairo.Context(self.surface)
|
||||||
ctx.translate(0, height)
|
ctx.translate(0, height)
|
||||||
ctx.scale(mm2pt, -mm2pt)
|
ctx.scale(mm2pt, -mm2pt)
|
||||||
|
|
||||||
ctx.set_source_rgb(1.0, 1.0, 1.0)
|
#ctx.set_source_rgb(1.0, 1.0, 1.0)
|
||||||
ctx.rectangle(0, 0, width, height)
|
#ctx.rectangle(0, 0, width, height)
|
||||||
ctx.fill()
|
#ctx.fill()
|
||||||
|
|
||||||
ctx.set_source_rgb(0.0, 0.0, 0.0)
|
ctx.set_source_rgb(0.0, 0.0, 0.0)
|
||||||
ctx.set_line_width(2*self.burn)
|
ctx.set_line_width(2*self.burn)
|
||||||
|
@ -521,6 +522,21 @@ class Boxes:
|
||||||
self.surface.flush()
|
self.surface.flush()
|
||||||
self.surface.finish()
|
self.surface.finish()
|
||||||
|
|
||||||
|
f = open(self.output, "r+")
|
||||||
|
s = f.read(1024)
|
||||||
|
pos = s.find('pt"')
|
||||||
|
if pos > 0:
|
||||||
|
f.seek(pos)
|
||||||
|
f.write("mm")
|
||||||
|
else:
|
||||||
|
print "Could not replace pt with mm"
|
||||||
|
pos = s.find('pt"', pos+3)
|
||||||
|
if pos > 0:
|
||||||
|
f.seek(pos)
|
||||||
|
f.write("mm")
|
||||||
|
else:
|
||||||
|
print "Could not replace pt with mm"
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
### Turtle graphics commands
|
### Turtle graphics commands
|
||||||
############################################################
|
############################################################
|
||||||
|
|
Loading…
Reference in New Issue