| |
- calc_line(p0, p1)
- use Bresenham's algorithm to calculate a set of closed points forming a line
Returns an array whose elements are the points of the line.
Original calc_line code retrieved from:
http://en.literateprograms.org/Bresenham's_line_algorithm_(Python)?oldid=16281
- calculate_bezier(p, steps=30)
- calculate a bezier curve from 4 control points
Returns a list of the resulting points.
The function uses the forward differencing algorithm described here:
http://www.niksula.cs.hut.fi/~hkankaan/Homepages/bezierfast.html
This code taken from www.pygame.org/wiki/BezierCurve.
- ccw_corners(r)
- return a tuple containing the corners of rect r in counter-clockwise
order starting with topleft
- cw_corners(r)
- return a tuple containing the corners of rect r in clockwise order
starting with topleft
- distance(a, b)
- Calculate the distance between points a and b. Returns distance as a float.
The a argument is a sequence representing one end point (x1,y1).
The b argument is a sequence representing the other end point (x2,y2).
- draw_text(image, text, pos=(0, 0), font='default', fg=(254, 254, 254), bg=(-1, -1, -1), rect_attr=('left', 'top'))
- Render text on the image in the named font.
Text is rendered at pos in foreground color fg. Width and height of
the rendered text is returned. rect_attr are the position attributes
of the resulting rect to set equal to pos.
- fill_gradient(surface, color, gradient, rect=None, vertical=True, forward=True)
- fill a surface with a gradient pattern
Parameters:
surface -> drawing surface
color -> starting color
gradient -> final color
rect -> area to fill; default is surface's rect
vertical -> True=vertical; False=horizontal
forward -> True=forward; False=reverse
Pygame recipe: http://www.pygame.org/wiki/GradientCode
- get_font(name='default')
- Return the named pygame.font.
The named font is looked up in cached fonts. The font named 'default'
is always available. See make_font() for adding custom fonts to the
cache.
- get_font_names()
- Return a list of existing font names.
- get_main_dir()
- Intelligently find the directory the executable is in - needed for py2exe
compatibility
- import_module(fullname)
- Dynamically imports a module by name
fullname is a string in any of these syntaxes:
1. A file name in the Python path, with or without .py extension.
2. Relative or absolute path and file, with or without .py extension. If
path contains os.pathsep, the Python path is not used to locate the file.
A relative path is relative to the current working directory.
- init_joystick(joy_id=-1)
- Initialize joysticks. This must be called before PyGame will
start sending joystick events. If joy_id is -1 all joysticks
will be intialized. The initialized joysticks are returned as a
dict keyed by joystick id.
- load_image(name, colorkey=None, alpha=False)
- load an image into memory
- make_font(name, file_name, font_size, bold=False, italic=False)
- Create a pygame.font.Font from a file. Return the font object.
An instance of pygame.font.Font is created and stored in a cache for
retrieval by get_font(). Initially there is one font named 'default',
which may be replaced by a custom font via this function if desired.
Arguments mirror those of pygame.font.SysFont().
- make_sysfont(name, font_name, font_size, bold=False, italic=False)
- Create a pygame.font.Font from system fonts. Return the font object.
An instance of pygame.font.Font is created and stored in a cache for
retrieval by get_font(). Initially there is one font named 'default',
which may be replaced by a custom font via this function if desired.
Arguments mirror those of pygame.font.SysFont().
- plot_curve(p)
- plot a curved path along one or more sets of control points
p is a one-dimensional array of points in multiples of four: i.e.
four points per curve.
steps is the number of points desired. steps is weighted by the sum
distance of each four points in order to yield approximately
equidistant points.
This code derived from www.pygame.org/wiki/BezierCurve.
- rot_center(image, angle)
- rotate an image while keeping its center and size
- sign(n)
- return the sign of number n
- split_thousands(s, sep=',')
- insert a comma every thousands place
- wait_event(type_=5)
|