<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
To rotate an oval convert the oval to a polygon and rotate that. Polygons
are easy to rotate, but this has to be done to the points before calling
create_polygon().
<p>Referring to Tk documentation - The canvas does not support rotation.
<br>'Practical Programming in Tcl and Tk', 3rd edition, 2000, by Brent
B. Welsh, publisher Prentice Hall PTR
<p>This is a simple example.
<p>(There are better methods of creating the points for an oval. Try fast
generation of ellipsoids in 'Graphics Gems V', 1995, edited by Alan W Paeth,
publisher AP Professional)
<p><tt>#</tt>
<br><tt>#</tt>
<br><tt>import math</tt>
<br><tt>import Tkinter</tt>
<br><tt></tt> <tt></tt>
<p><tt>def poly_oval(x0,y0, x1,y1, steps=20, rotation=0):</tt>
<br><tt>    """return an oval as coordinates suitable for
create_polygon"""</tt><tt></tt>
<p><tt>    # x0,y0,x1,y1 are as create_oval</tt><tt></tt>
<p><tt>    # rotation is in degrees anti-clockwise, convert
to radians</tt>
<br><tt>    rotation = rotation * math.pi / 180.0</tt><tt></tt>
<p><tt>    # major and minor axes</tt>
<br><tt>    a = (x1 - x0) / 2.0</tt>
<br><tt>    b = (y1 - y0) / 2.0</tt><tt></tt>
<p><tt>    # center</tt>
<br><tt>    xc = x0 + a</tt>
<br><tt>    yc = y0 + b</tt><tt></tt>
<p><tt>    point_list = []</tt><tt></tt>
<p><tt>    # create the oval as a list of points</tt>
<br><tt>    for i in range(steps):</tt><tt></tt>
<p><tt>        # Calculate the angle
for this step</tt>
<br><tt>        # 360 degrees == 2 pi
radians</tt>
<br><tt>        theta = (math.pi * 2)
* (float(i) / steps)</tt><tt></tt>
<p><tt>        x1 = a * math.cos(theta)</tt>
<br><tt>        y1 = b * math.sin(theta)</tt><tt></tt>
<p><tt>        # rotate x, y</tt>
<br><tt>        x = (x1 * math.cos(rotation))
+ (y1 * math.sin(rotation))</tt>
<br><tt>        y = (y1 * math.cos(rotation))
- (x1 * math.sin(rotation))</tt><tt></tt>
<p><tt>        point_list.append(round(x
+ xc))</tt>
<br><tt>        point_list.append(round(y
+ yc))</tt><tt></tt>
<p><tt>    return point_list</tt>
<br><tt></tt> 
<br><tt></tt> <tt></tt>
<p><tt>import Tkinter</tt>
<br><tt>root = Tkinter.Tk()</tt>
<br><tt>canvas = Tkinter.Canvas(root, width=400, height=400)</tt><tt></tt>
<p><tt>dict = {}</tt>
<br><tt>dict['outline'] = 'black'</tt>
<br><tt>dict['fill']   = 'yellow'</tt>
<br><tt>dict['smooth'] = 'true'</tt><tt></tt>
<p><tt># use a polygon to draw an oval rotated 30 degrees anti-clockwise</tt>
<br><tt>apply(canvas.create_polygon, tuple(poly_oval(40,40, 200,300, rotation=30)),
dict)</tt><tt></tt>
<p><tt>canvas.pack()</tt>
<br><tt>root.mainloop()</tt><tt></tt>
<p>-- Stephen D Evans
<br> 
<p>Dethe Elza wrote:
<blockquote TYPE=CITE>I'm trying to create a complex cursor in Tkinter. 
I want to have an image
<br>which I can rotate, change the color of, and move about.  I can
build it as
<br>a vector image, but I use ovals.  I haven't found any way to rotate
images,
<br>vector drawings, or ovals in Tk.
<p>TIA
<p>--Dethe</blockquote>
</html>