Module sketcher :: Class canvas
[hide private]
[frames] | no frames]

Class canvas

source code

                         object --+    
                                  |    
                          ode.World --+
                                      |
                 object --+           |
                          |           |
pygame.sprite.AbstractGroup --+       |
                              |       |
            pygame.sprite.Group --+   |
                                  |   |
        pygame.sprite.RenderUpdates --+
                                      |
                                     canvas

This is a container class for holding the objects printed to the 'canvas' area of the application. The position, physical properties (shapes), and orientation of each objects are held in this data structure for easy management and manipulation around the canvas through user-driven actions and the simulated actions of the virtual canvas environment. Parameter:

Nested Classes [hide private]
  sprite
Abstract object represented in an area of the canvas.
Instance Methods [hide private]
 
__init__(this, size=(640, 480), color=(255, 255, 255, 255), image=None, song=None)
Initialization procedure for defaulting the canvas' environment.
source code
 
set_bgcolor(this, color)
Sets the canvas' background color.
source code
 
set_bgimage(this, image, size)
Sets the canvas' background image.
source code
 
set_bgmusic(this, song)
Sets the background music.
source code
 
get_size(this)
Returns a 2-tuple value of the canvas' screen size, as a (width,height) pair.
source code
 
is_sprite(this, pos)
Tests whether an object is located at the current 'pos' location.
source code
 
get_sprite(this, pos)
Returns the sprite that is located at the 'pos' location.
source code
 
near_collision(this, contactgroup, geom1, geom2)
Invoked whenever two objectas are about to collide, then creates collision points where collision may occur.
source code
 
step(this, framerate)
Increments the world timestep, and detects near collisions.
source code
 
pause(this)
Pauses the simulation.
source code
 
play(this)
Plays the simulation
source code
 
add(this, image, topleft, vertices=None)
Adds a new object to the canvas' environment.
source code
 
sketch(this, image, topleft, vertices, world)
Creates a new object given it's image copy, vertices, position, and world.
source code

Inherited from ode.World: getAutoDisableAngularThreshold, getAutoDisableFlag, getAutoDisableLinearThreshold, getAutoDisableSteps, getAutoDisableTime, getCFM, getContactMaxCorrectingVel, getContactSurfaceLayer, getERP, getGravity, getQuickStepNumIterations, impulseToForce, quickStep, setAutoDisableAngularThreshold, setAutoDisableFlag, setAutoDisableLinearThreshold, setAutoDisableSteps, setAutoDisableTime, setCFM, setContactMaxCorrectingVel, setContactSurfaceLayer, setERP, setGravity, setQuickStepNumIterations

Inherited from pygame.sprite.RenderUpdates: draw

Inherited from pygame.sprite.AbstractGroup: __contains__, __iter__, __len__, __nonzero__, __repr__, add_internal, clear, copy, empty, has, has_internal, remove, remove_internal, sprites, update

Inherited from object: __delattr__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __setattr__, __str__

Static Methods [hide private]
a new object with type S, a subtype of T
__new__(this, size=(640, 480), color=(255, 255, 255, 255), image=None, song=None)
Polymorphs the __new__ method in the base class ode.World so that other supertypes can be fully initialized.
source code
Class Variables [hide private]

Inherited from pygame.sprite.AbstractGroup (private): _spritegroup

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__new__(this, size=(640, 480), color=(255, 255, 255, 255), image=None, song=None)
Static Method

source code 

Polymorphs the __new__ method in the base class ode.World so that other supertypes can be fully initialized. Because ode.World is already a defined type (not a class), and therefore is immutable, defining this function ensures that upon constructing objects of this subtype, the __new__ method invokation will be done at the subtype level without conflicting the __init__ requirements for initializing the other derived classes in its multi-inherited hierarchy. This is similar to the way in which a string, int, and other immutable types can be extended even though they are not directly treated as classes. Also, importantly, the parameters passed to this method must match exactly with the parameters passed to the __init__ method. Parameter:

  • size, the canvas' size.
  • color, the canvas' background color.
  • image, the canvas' background picture.
Returns: a new object with type S, a subtype of T
Overrides: object.__new__

__init__(this, size=(640, 480), color=(255, 255, 255, 255), image=None, song=None)
(Constructor)

source code 

Initialization procedure for defaulting the canvas' environment. Parameter:

  • size, the canvas' size.
  • color, the canvas' background color.
  • image, the canvas' background picture (passed as a string path to its location).
Overrides: object.__init__

set_bgcolor(this, color)

source code 

Sets the canvas' background color. Parameter:

  • color, the color to set the canvas' background to.

set_bgimage(this, image, size)

source code 

Sets the canvas' background image. Parameter:

  • image, a path to the picture to set the canvas' background to.

set_bgmusic(this, song)

source code 

Sets the background music. Parameter:

  • song, the path of the background music to be played.

is_sprite(this, pos)

source code 

Tests whether an object is located at the current 'pos' location. Parameter:

  • pos, the (x,y) position where the object is located.

get_sprite(this, pos)

source code 

Returns the sprite that is located at the 'pos' location. Normally used when user selects and object and wants to drag it from one area to another. Parameter:

  • pos, the (x,y) position where the object is located.

near_collision(this, contactgroup, geom1, geom2)

source code 

Invoked whenever two objectas are about to collide, then creates collision points where collision may occur. Parameter:

  • contactgroup, group for holding contact joints
  • geom1, one of the geometry objects involved in the collision.
  • geom2, one of the geometry objects involved in the collision.

step(this, framerate)

source code 

Increments the world timestep, and detects near collisions. Parameter:

  • framerate, the refresh rate for updating the application window.
Parameters:
  • stepsize - Time step
Overrides: ode.World.step

add(this, image, topleft, vertices=None)

source code 

Adds a new object to the canvas' environment. Once an object is added to the environment, it is capable of interacting with other objects within the environment, and with user-driven inputs. Parameter:

  • object, the object to be registered to the canvas' environment. The object should contain the basic configurations for representing its visual state as a surface; for the area and position it occupies; and for the vertices it is composed from.
Overrides: pygame.sprite.AbstractGroup.add

sketch(this, image, topleft, vertices, world)

source code 

Creates a new object given it's image copy, vertices, position, and world. Parameter:

  • image, a copy of the object.
  • topleft, position of the object.
  • vertices, points composing the object.
  • world, the canvas the object belongs to.