Package pygsear :: Module Drawable :: Class EuclidTurtle
[show private | hide private]
[frames | no frames]

Class EuclidTurtle

object --+                    
         |                    
    Sprite --+                
             |                
      Drawable --+            
                 |            
        MultiImage --+        
                     |        
          RotatedImage --+    
                         |    
                    Turtle --+
                             |
                            EuclidTurtle


Turtle with altered co-ordinate system.

Instead of (0, 0) being the upper left corner of the screen, the origin is the center of the screen. The EuclidTurtle also uses a different scale: each unit is by default 30 pixels.
Method Summary
  __init__(self, w, position, deg, color, filename, colorkey, convert)
  cCircle(self, radius, color, width)
Quick drawing circle, centered on current position.
  circle(self, radius, clockwise, color, width)
Quick drawing circle.
  cRectangle(self, side_length, side_width, width, color, bgColor)
Quick drawing routine for rectangles.
  cSquare(self, side_length, width, color, bgColor)
Quick drawing routine for squares.
  drawEuclidCoords(self)
Draw the cartesian (x, y) coordinate system.
  euclid_scale(self, dist)
Scale a distance to a real screen distance.
  euclid_translate(self, position)
Convert to real screen coordinates.
  euclid_unscale(self, dist)
Scale a distance from a real screen distance.
  euclid_untranslate(self, position)
Convert from real screen coordinates.
  euclidean(self, drawCoords)
Set up the coordinate system.
  forward(self, dist)
Move the turtle forward a distance
  line(self, p1, p2)
Draw a line which includes these 2 points.
  line_point_slope(self, p, m)
Draw a line through a point with a slope.
  lineSegment(self, p1, p2)
Draw a line segment between 2 points.
  lineTo(self, position)
Move turtle to position, drawing a line
  moveTo(self, position)
Move turtle to position, without drawing a line
  rectangle(self, side_length, side_width, clockwise, width, color, bgColor)
Quick drawing routine for rectangles.
  reset(self)
Clear the screen to LBLUE, and return Penguin to home
  square(self, side_length, clockwise, width, color, bgColor)
Quick drawing square.
  where(self)
Briefly show the current position of the turtle.
    Inherited from Turtle
  backward(self, dist)
Move the turtle backward distance.
  begin(self, interactive)
Start a new layer for drawing.
  begin_fill(self)
Start saving points for filling a polygon later
  blink(self, times, delay)
Flash the turtle on and off.
  clear(self, surface)
erase sprite image to background, returning affected rect
  clearScreen(self)
Clear the screen to background color.
  commit(self)
Copy drawing layer to base window.
  commit_fill(self, color)
Fill the polygon of saved points
  draw(self, surface)
draw image, returning affected rect
  get_deg(self)
return current turtle direction.
  grow(self, dx, dy)
Resize the window (larger)
  hide(self)
Set the penguin icon invisible
  home(self)
Move back to the home position
  left(self, d)
Turn left (counter-clockwise) a number of degrees
  nudge_color(self, red, blue, green)
Change the pen color by given amounts.
  penDown(self)
Put pen down, ready to draw
  penUp(self)
Pull pen up.
  refresh(self)
Update the display.
  right(self, d)
Turn right (clockwise) a number of degrees
  rollback(self)
Throw out drawing layer.
  rollback_fill(self)
Throw out list of saved points
  save(self, filename)
Save background (the picture) as filename
  set_background(self, color)
Set the background color
  set_color(self, color, r, g, b)
Set the color for drawing.
  set_fontSize(self, fontSize)
Set default font size for write and where
  set_home(self, pos)
Set the Penguin's home position
  set_visible(self, vis)
Set the penguin icon visible
  set_width(self, width)
Set line width for drawing.
  show(self)
Set the penguin icon visible
  shrink(self, dx, dy)
Resize the window (smaller)
  turnTo(self, deg)
Set turtle's direction to deg (degrees).
  update(self, dirty)
Update the display
  wait(self)
Read pygame events until mouse click or any key press.
  write(self, text, fontSize, color, bgColor)
Draw text from current position, and at current angle.
    Inherited from RotatedImage
  flip(self, key)
Switch images for the sprite
  get_rotation(self)
return angle of rotation
  move(self)
set position to next position on path
  rotate(self, rad)
rotate to the left by radians
  rotate_left(self)
set rotation rate to +2
  rotate_right(self)
set rotation rate to -2
  rotate_stop(self)
set rotation rate to 0
  rotate_towards(self, point)
turn as quickly as possible towards a point
  set_closest(self)
flip to the image for the current direction
  set_image(self, key)
Change which image is being shown.
  set_rotation(self, direction)
set angle of rotation
  set_rotationRate(self, rate)
set rate of rotation in radians / second
    Inherited from MultiImage
  addImage(self, filename, image, colorkey, convert)
add image to list of available images
  removeImage(self, key)
remove image by name
  stretch(self, dx, dy, size, keepAspectRatio)
Change the size of sprite's image, and rect.
    Inherited from Drawable
bool can_see(self, target, blocking_rects_list)
Performs a los (line of sight) check from the center of the source to the center of the target.
  center(self, x, y, dx, dy)
Align the Drawable in its layer
bool collide(self, other)
return True if this sprite and other sprite overlap.
Drawable or False collidelist(self, lothers)
return True if this sprite and any in list of others collide.
List collidelistall(self, lothers)
return True if this sprite and any in list of others collide.
  direction(self, point)
return the direction from the sprite to a point
  distance(self, point)
return the distance from the sprite to a point
  get_position(self)
return a copy of the sprite's position
  get_size(self)
return size of sprite's rect.
  nudge(self, dx, dy)
Move sprite.
  onscreen(self, slack, **kw)
return True if image is on the screen or layer.
  pause(self)
stop moving along Path
  runPath(self, frames)
call move() continuously
  set_crect(self, crect)
set the collision pygame.Rect used for collision checking.
  set_path(self, path)
set which path to follow
  set_position(self, location, *args)
Move sprite to location.
  set_positionRandom(self, slack)
Move sprite to a random location on screen
  set_size(self, size)
Set size of sprite's rect.
  solid(self, other, move_both)
move sprite so that it does not overlap with other sprite
  uclear(self, surface)
clear sprite and update display
  udraw(self, surface)
Draw image and update display.
  unpause(self)
start moving along Path
  _set_position(self, location)
Move sprite to location.
    Inherited from Sprite
  __repr__(self)
  add(self, *groups)
add(group or list of of groups, ...) add a sprite to container
  add_internal(self, group)
  alive(self)
alive() -> bool check to see if the sprite is in any groups
  groups(self)
groups() -> list of groups list used sprite containers
  kill(self)
kill() remove this sprite from all groups
  remove(self, *groups)
remove(group or list of groups, ...) remove a sprite from container
  remove_internal(self, group)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)
    Inherited from type
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T

Class Variable Summary
    Inherited from Turtle
tuple BGCOLOR = (0, 0, 0)
tuple COLOR = (255, 255, 255)
    Inherited from MultiImage
NoneType filenames = None                                                                  

Method Details

cCircle(self, radius, color=None, width=None)

Quick drawing circle, centered on current position.

Does not move the turtle (ie, the turtle will be returned to its present location before returning)

"Quick drawing" means that this function draws the circle by calling pygame.draw.circle and not by simulating the drawing of a circle with a number of line segments and turns, which would be much slower.
Parameters:
radius - Radius of circle to draw. The center will be the current location.
color - Color to use for drawing circle, or the string 'random' to choose a random color. Does not affect the turtle's pen color (ie, the pen color will be restored before returning)
width - Thickness of line to use when drawing, or Zero (0) to fill with color.
Overrides:
pygsear.Drawable.Turtle.cCircle (inherited documentation)

circle(self, radius, clockwise=1, color=None, width=None)

Quick drawing circle. Starting from current position and rotation.

"Quick drawing" means that this function draws the circle by calling pygame.draw.circle and not by simulating the drawing of a circle with a number of line segments and turns, which would be much slower.
Parameters:
radius - Radius of circle to draw. The center will be 90 degrees from the current direction.
clockwise - Draw the circle turning clockwise from the current position, or if False, turn counter-clockwise.
color - Color to use for drawing circle, or the string 'random' to choose a random color. Does not affect the turtle's pen color (ie, the pen color will be restored before returning)
width - Thickness of line to use when drawing, or Zero (0) to fill with color.
Overrides:
pygsear.Drawable.Turtle.circle (inherited documentation)

cRectangle(self, side_length=20, side_width=10, width=None, color=None, bgColor=(0, 51, 0, 0))

Quick drawing routine for rectangles.

Rectangle is centered on current position.
Parameters:
side_length - length of 1st and 3rd sides drawn
side_width - length of 2nd and last sides drawn
width - thickness of outline of rectangle width 0 means rectangle should be filled with color
color - RGB tuple, color of rectangle
bgColor - background color. Note that rectangle is not constrained to align horizontally or verically.
Overrides:
pygsear.Drawable.Turtle.cRectangle (inherited documentation)

cSquare(self, side_length=2, width=None, color=None, bgColor=(0, 51, 0, 0))

Quick drawing routine for squares.

Square is centered on current position.
Parameters:
side_length - length of all sides drawn
width - thickness of outline of square width 0 means square should be filled with color
color - RGB tuple, color of square
bgColor - background color. Note that square is not constrained to align horizontally or verically.
Overrides:
pygsear.Drawable.Turtle.cSquare (inherited documentation)

drawEuclidCoords(self)

Draw the cartesian (x, y) coordinate system.

euclid_scale(self, dist)

Scale a distance to a real screen distance.

euclid_translate(self, position)

Convert to real screen coordinates.

euclid_unscale(self, dist)

Scale a distance from a real screen distance.

euclid_untranslate(self, position)

Convert from real screen coordinates.

euclidean(self, drawCoords=1)

Set up the coordinate system.

forward(self, dist)

Move the turtle forward a distance
Parameters:
dist - Number of pixels to move.
Overrides:
pygsear.Drawable.Turtle.forward (inherited documentation)

line(self, p1, p2)

Draw a line which includes these 2 points.

Unlike Turtle.line this will draw as much of the line as will fit on the screen, not just a line segment connecting the two points.

This function ignores the state of the pen.
Parameters:
p1 - One point on the line.
p2 - Second point on the line.
Overrides:
pygsear.Drawable.Turtle.line

line_point_slope(self, p, m)

Draw a line through a point with a slope.

This function ignores the state of the pen.
Parameters:
p - One point on the line.
m - Slope of the line.

lineSegment(self, p1, p2)

Draw a line segment between 2 points.

This function ignores the state of the pen.
Parameters:
p1 - One endpoint of line segment.
p2 - Second endpoint of line segment.

lineTo(self, position)

Move turtle to position, drawing a line

Note that this ignores the state of the pen (up or down) and always draws a line in the current pen color.
Parameters:
position - Point (x, y) to draw the line to.
Overrides:
pygsear.Drawable.Turtle.lineTo (inherited documentation)

moveTo(self, position)

Move turtle to position, without drawing a line
Parameters:
position - Point (x, y) to move to
Overrides:
pygsear.Drawable.Turtle.moveTo (inherited documentation)

rectangle(self, side_length=20, side_width=10, clockwise=1, width=None, color=None, bgColor=(0, 51, 0, 0))

Quick drawing routine for rectangles.
Parameters:
side_length - length of 1st and 3rd sides drawn
side_width - length of 2nd and last sides drawn
clockwise - all turns will be 90 degrees right clockwise 0 means all turns will be 90 degrees left
width - thickness of outline of rectangle width 0 means rectangle should be filled with color
color - RGB tuple, color of rectangle
bgColor - background color. Note that rectangle is not constrained to align horizontally or verically.
Overrides:
pygsear.Drawable.Turtle.rectangle (inherited documentation)

reset(self)

Clear the screen to LBLUE, and return Penguin to home

also reset pen color to WHITE, and turn back to 90 deg (standing straight up)
Overrides:
pygsear.Drawable.Turtle.reset (inherited documentation)

square(self, side_length=20, clockwise=1, width=None, color=None, bgColor=(0, 51, 0, 0))

Quick drawing square.
Parameters:
side_length - length of all sides drawn
clockwise - all turns will be 90 degrees right clockwise 0 means all turns will be 90 degrees left
width - thickness of outline of square width 0 means square should be filled with color
color - RGB tuple, color of square
bgColor - background color. Note that square is not constrained to align horizontally or verically.
Overrides:
pygsear.Drawable.Turtle.square (inherited documentation)

where(self)

Briefly show the current position of the turtle.
Overrides:
pygsear.Drawable.Turtle.where (inherited documentation)

Generated by Epydoc 2.0 on Sat Dec 9 14:11:20 2006 http://epydoc.sf.net