summaryrefslogtreecommitdiff
path: root/gerber
diff options
context:
space:
mode:
authorHamilton Kibbe <hamilton.kibbe@gmail.com>2015-02-15 13:29:50 -0500
committerHamilton Kibbe <hamilton.kibbe@gmail.com>2015-02-15 13:29:50 -0500
commitd63bf0d68ae100c0413c7619f96d5d1c65da6c4e (patch)
tree5ea6e1233cd975017c4400f024e5b63efaaab04c /gerber
parentbfe14841604b6be403e7123e8b6667b1f0aff6f6 (diff)
downloadgerbonara-d63bf0d68ae100c0413c7619f96d5d1c65da6c4e.tar.gz
gerbonara-d63bf0d68ae100c0413c7619f96d5d1c65da6c4e.tar.bz2
gerbonara-d63bf0d68ae100c0413c7619f96d5d1c65da6c4e.zip
Fix cairo image size
Diffstat (limited to 'gerber')
-rw-r--r--gerber/render/cairo_backend.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/gerber/render/cairo_backend.py b/gerber/render/cairo_backend.py
index 18d1ceb..f79dfbe 100644
--- a/gerber/render/cairo_backend.py
+++ b/gerber/render/cairo_backend.py
@@ -44,7 +44,14 @@ class GerberCairoContext(GerberContext):
def set_bounds(self, bounds):
if not self.background:
xbounds, ybounds = bounds
- self.ctx.rectangle(SCALE * xbounds[0], SCALE * ybounds[0], SCALE * (xbounds[1]- xbounds[0]), SCALE * (ybounds[1] - ybounds[0]))
+ width = SCALE * (xbounds[1] - xbounds[0])
+ height = SCALE * (ybounds[1] - ybounds[0])
+ self.surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, int(width), int(height))
+ self.ctx = cairo.Context(self.surface)
+ self.ctx.translate(0, height)
+ self.scale = (SCALE,SCALE)
+ self.ctx.scale(1, -1)
+ self.ctx.rectangle(SCALE * xbounds[0], SCALE * ybounds[0], width, height)
self.ctx.set_source_rgb(0,0,0)
self.ctx.fill()
self.background = True