Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt/tacanvas.py
diff options
context:
space:
mode:
Diffstat (limited to 'TurtleArt/tacanvas.py')
-rw-r--r--TurtleArt/tacanvas.py13
1 files changed, 2 insertions, 11 deletions
diff --git a/TurtleArt/tacanvas.py b/TurtleArt/tacanvas.py
index 5800f8f..72814a9 100644
--- a/TurtleArt/tacanvas.py
+++ b/TurtleArt/tacanvas.py
@@ -528,22 +528,13 @@ class TurtleGraphics:
def draw_pixbuf(self, pixbuf, a, b, x, y, w, h, path, share=True):
''' Draw a pixbuf '''
- ### These really only need to be calculated once
- ox, oy = self.turtle_to_screen_coordinates(-w / 2., h / 2.)
- r = sqrt(self.width * self.width + self.height * self.height) / 2
- a = atan(self.width / float(self.height))
- cx = ox - cos(a) * r
- cy = oy - sin(a) * r
- ###
# Build a gtk.gdk.CairoContext from a cairo.Context to access
# the set_source_pixbuf attribute.
cr = gtk.gdk.CairoContext(self.canvas)
cr.save()
+ cr.translate(x, y) # center the rotation on x, y
cr.rotate(self.heading * DEGTOR)
- # Fix me: offset of rotated image
- nx = cx + cos(a - self.heading * DEGTOR) * r
- ny = cy + sin(a - self.heading * DEGTOR) * r
- cr.translate(nx-x, ny-y)
+ cr.translate(-x, -y) # reset the position
cr.set_source_pixbuf(pixbuf, x, y)
cr.rectangle(x, y, w, h)
cr.fill()