Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2011-11-02 13:44:33 (GMT)
committer Walter Bender <walter.bender@gmail.com>2011-11-02 13:44:33 (GMT)
commit0b7b4ac756437c3f5b2b5c624b97c6f79c021f0d (patch)
tree26bbcbec3308c45c214d9d1bd7533b55c60eb3b9 /TurtleArt
parent3b0e9d43a62792bb00f7f23bafe2e81c0f873484 (diff)
giving up on image rotation for the moment
Diffstat (limited to 'TurtleArt')
-rw-r--r--TurtleArt/tacanvas.py22
-rw-r--r--TurtleArt/talogo.py10
2 files changed, 24 insertions, 8 deletions
diff --git a/TurtleArt/tacanvas.py b/TurtleArt/tacanvas.py
index 4355007..96f77dd 100644
--- a/TurtleArt/tacanvas.py
+++ b/TurtleArt/tacanvas.py
@@ -21,7 +21,7 @@
#THE SOFTWARE.
import gtk
-from math import sin, cos, pi
+from math import sin, cos, atan, pi, sqrt
import pango
import cairo
import pangocairo
@@ -533,18 +533,27 @@ class TurtleGraphics:
def draw_pixbuf(self, pixbuf, a, b, x, y, w, h, path, share=True):
""" Draw a pixbuf """
- w *= self.tw.coord_scale
- h *= self.tw.coord_scale
-
+ '''
+ # Fix me: rotate image
+ r = sqrt(x*x + y*y)
+ if x != 0:
+ angle = atan(y/x) # initial angle relative to the origin
+ else:
+ angle = 0.
+ angle += self.heading * DEGTOR # add in heading
+ nx = cos(angle) * r
+ ny = sin(angle) * 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.rotate(self.heading * DEGTOR)
+ # cr.translate(-x, -y)
+ # cr.rotate(self.heading * DEGTOR)
+ # cr.translate(nx, ny)
cr.set_source_pixbuf(pixbuf, x, y)
# To do: reposition rectangle based on angle of rotation
cr.rectangle(x, y, w, h)
- cr.rotate(-self.heading * DEGTOR)
cr.fill()
cr.restore()
self.inval()
@@ -698,6 +707,7 @@ class TurtleGraphics:
def get_pixel(self):
""" Read the pixel at x, y """
+ # FIX ME: broken for Cairo
if self.tw.interactive_mode:
x, y = self.turtle_to_screen_coordinates(self.xcor, self.ycor)
return self.canvas.get_pixel((int(x), int(y)), 0,
diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py
index 12be92f..25ffceb 100644
--- a/TurtleArt/talogo.py
+++ b/TurtleArt/talogo.py
@@ -585,14 +585,20 @@ class LogoCode:
debug_output("Couldn't open filepath %s" % (self.filepath),
self.tw.running_sugar)
if pixbuf is not None:
+ x = self.tw.canvas.xcor
+ y = self.tw.canvas.ycor
+ w *= self.tw.coord_scale
+ h *= self.tw.coord_scale
if center:
self.tw.canvas.draw_pixbuf(pixbuf, 0, 0,
self.x2tx() - int(w / 2),
self.y2ty() - int(h / 2), w, h,
self.filepath)
else:
- self.tw.canvas.draw_pixbuf(pixbuf, 0, 0, self.x2tx(),
- self.y2ty(), w, h, self.filepath)
+ self.tw.canvas.draw_pixbuf(pixbuf, 0, 0,
+ self.x2tx(),
+ self.y2ty(),
+ w, h, self.filepath)
def insert_desc(self, mimetype=None, description=None):
""" Description text only (at current x, y) """