dudraw.py
The dudraw module defines functions that allow the user to create a drawing. A drawing appears on the canvas. The canvas appears in the window. As a convenience, the module also imports the commonly used Color objects defined in the color module.
Function | annulus |
Draw an annulus centered at (x, y) with outer radius r1, and inner radius r2. |
Function | arc |
Draw an arc portion between angle1 and angle2, of the circumference of a circle centered at (x, y) with a radius r. |
Function | circle |
Draw on the background canvas a circle of radius r centered on (x, y). |
Function | clear |
Clear the background canvas to color c, where c is an object of class Color. c defaults to dudraw.WHITE. |
Function | clear |
Clear the background canvas to color c, where c is an object of class Color. c defaults to dudraw.WHITE. |
Function | ellipse |
Draw on the background canvas an ellipse centered at (x, y) with a width of 2.0 * half_width, and a height of 2.0 * half_height. |
Function | elliptical |
Draw an arc portion between angle1 and angle2, of the circumference of an ellipse centered at (x, y) with a width of half_width, and a height of 2.0 * half_height. |
Function | elliptical |
Draw a sector portion between angle1 and angle2, of the interior of an ellipse centered at (x, y) with a width of half_width, and a height of 2.0 * half_height. |
Function | filled |
Draw a filled annulus centered at (x, y) with outer radius r1, and inner radius r2. |
Function | filled |
Draw on the background canvas a filled circle of radius r centered on (x, y). |
Function | filled |
Draw on the background canvas a filled ellipse centered at (x, y) with a width of 2.0 * half_width, and a height of 2.0 * half_height. |
Function | filled |
Draw a filled sector portion between angle1 and angle2, of the interior of an ellipse centered at (x, y) with a width of half_width, and a height of 2.0 * half_height. |
Function | filled |
Draw on the background canvas a filled polygon with coordinates (x[i], y[i]). |
Function | filled |
Draw a filled quadrilateral on the canvas with corners at (x0, y0), (x1, y1), (x2, y2), and (x3, y3). |
Function | filled |
Draw on the background canvas a rectangle of width (2 * halfWidth and height (2 * halfHeight) centered at point (x, y). |
Function | filled |
Draw a filled sector portion between angle1 and angle2, of the interior of a circle centered at (x, y) with a radius r. |
Function | filled |
Draw on the background canvas a filled square whose sides are of length 2r, centered on (x, y). |
Function | filled |
Draw a filled triangle on the canvas with corners at (x0, y0), (x1, y1), and (x2, y2). |
Function | get |
Return the height of the current canvas |
Function | get |
Return the width of the current canvas |
Function | get |
Returns the value of _penColor as an object of class Color. |
Function | get |
Return the color of the pixel at the given user coordinates |
Function | has |
Return True if the queue of keys the user typed is not empty. Otherwise return False. |
Function | line |
Draw on the background canvas a line from (x0, y0) to (x1, y1). |
Function | mouse |
Return True if the mouse has been left-clicked since the last time mousePressed was called, and False otherwise. |
Function | mouse |
Return the x coordinate in user space of the location at which the mouse was most recently left-clicked. If a left-click hasn't happened yet, raise an exception, since mouseX() shouldn't be called until mousePressed() returns True. |
Function | mouse |
Return the y coordinate in user space of the location at which the mouse was most recently left-clicked. If a left-click hasn't happened yet, raise an exception, since mouseY() shouldn't be called until mousePressed() returns True. |
Function | next |
Remove the first key from the queue of keys that the the user typed, and return that key. |
Function | picture |
Draw pic on the background canvas centered at (x, y). pic is an object of class picture.Picture. x and y default to the midpoint of the background canvas. |
Function | point |
Draw on the background canvas a point at (x, y). |
Function | polygon |
Draw on the background canvas a polygon with coordinates (x[i], y[i]). |
Function | polyline |
Draw on the background canvas a polyline with coordinates (x[i], y[i]). |
Function | quadrilateral |
Draw a quadrilateral on the canvas with corners at (x0, y0), (x1, y1), (x2, y2), and (x3, y3). |
Function | rectangle |
Draw on the background canvas a rectangle of width (2 * halfWidth and height (2 * halfHeight) centered at point (x, y). |
Function | save |
Save the window canvas to file f. |
Function | sector |
Draw a sector portion between angle1 and angle2, of the interior of a circle centered at (x, y) with a radius r. |
Function | set |
Set the size of the canvas to w pixels wide and h pixels high. Calling this function is optional. If you call it, you must do so before calling any drawing function. |
Function | set |
Set the font family to f (e.g. 'Helvetica' or 'Courier'). |
Function | set |
Set the font size to s (e.g. 12 or 16). |
Function | set |
Set the pen color to c, where c is an object of class Color. c defaults to dudraw.BLACK. |
Function | set |
Set the pen color to c, where c is an object of class Color. c defaults to dudraw.BLACK. |
Function | set |
Set the pen radius to r, thus affecting the subsequent drawing of points and lines. If r is 0.0, then points will be drawn with the minimum possible radius and lines with the minimum possible width. |
Function | set |
Undocumented |
Function | set |
Set the x-scale of the canvas such that the minimum x value is min and the maximum x value is max. |
Function | set |
Set the y-scale of the canvas such that the minimum y value is min and the maximum y value is max. |
Function | show |
Copy the background canvas to the window canvas, and then wait for msec milliseconds. msec defaults to infinity. |
Function | square |
Draw on the background canvas a square whose sides are of length 2r, centered on (x, y). |
Function | text |
Draw string s on the background canvas centered at (x, y). |
Function | triangle |
Draw a triangle on the canvas with corners at (x0, y0), (x1, y1), and (x2, y2). |
Function | _ccw |
Undocumented |
Function | _check |
Check if any new event has occured (such as a key typed or button pressed). If a key has been typed, then put that key in a queue. |
Function | _factor |
Undocumented |
Function | _factor |
Undocumented |
Function | _intersect |
Undocumented |
Function | _line |
Undocumented |
Function | _main |
Dispatch to a function that does regression testing, or to a dialog-box-handling function. |
Function | _make |
Undocumented |
Function | _pen |
Undocumented |
Function | _pixel |
Draw on the background canvas a pixel at (x, y). |
Function | _pygame |
Convert c, an object of type Color, to an equivalent object of type pygame.Color. Return the result. |
Function | _regression |
Perform regression testing. |
Function | _scale |
Undocumented |
Function | _scale |
Undocumented |
Function | _scale |
Undocumented |
Function | _show |
Copy the background canvas to the window canvas. |
Function | _show |
Copy the background canvas to the window canvas. Then wait forever, that is, until the user closes the dudraw window. |
Function | _thick |
Draw on the background canvas a line from (x0, y0) to (x1, y1). Draw the line with a pen whose radius is r. |
Function | _user |
Undocumented |
Function | _user |
Undocumented |
Constant | _BORDER |
Undocumented |
Constant | _DEFAULT |
Undocumented |
Constant | _DEFAULT |
Undocumented |
Constant | _DEFAULT |
Undocumented |
Constant | _DEFAULT |
Undocumented |
Constant | _DEFAULT |
Undocumented |
Constant | _DEFAULT |
Undocumented |
Constant | _DEFAULT |
Undocumented |
Constant | _DEFAULT |
Undocumented |
Variable | _canvas |
Undocumented |
Variable | _canvas |
Undocumented |
Variable | _keys |
Undocumented |
Variable | _mouse |
Undocumented |
Variable | _mouse |
Undocumented |
Variable | _pen |
Undocumented |
Variable | _window |
Undocumented |
Variable | _xmax |
Undocumented |
Variable | _xmin |
Undocumented |
Variable | _ymax |
Undocumented |
Variable | _ymin |
Undocumented |
Draw an annulus centered at (x, y) with outer radius r1, and inner radius r2.
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
r1:float | Undocumented |
r2:float | Undocumented |
Draw an arc portion between angle1 and angle2, of the circumference of a circle centered at (x, y) with a radius r.
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
r:float | Undocumented |
angle1:float | Undocumented |
angle2:float | Undocumented |
Draw on the background canvas a circle of radius r centered on (x, y).
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
r:float | Undocumented |
Clear the background canvas to color c, where c is an object of class Color. c defaults to dudraw.WHITE.
Parameters | |
c:Color | Undocumented |
Clear the background canvas to color c, where c is an object of class Color. c defaults to dudraw.WHITE.
Parameters | |
r:float | Undocumented |
g:float | Undocumented |
b:float | Undocumented |
Draw on the background canvas an ellipse centered at (x, y) with a width of 2.0 * half_width, and a height of 2.0 * half_height.
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
halffloat | Undocumented |
halffloat | Undocumented |
Draw an arc portion between angle1 and angle2, of the circumference of an ellipse centered at (x, y) with a width of half_width, and a height of 2.0 * half_height.
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
halffloat | Undocumented |
halffloat | Undocumented |
angle1:float | Undocumented |
angle2:float | Undocumented |
Draw a sector portion between angle1 and angle2, of the interior of an ellipse centered at (x, y) with a width of half_width, and a height of 2.0 * half_height.
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
halffloat | Undocumented |
halffloat | Undocumented |
angle1:float | Undocumented |
angle2:float | Undocumented |
Draw a filled annulus centered at (x, y) with outer radius r1, and inner radius r2.
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
r1:float | Undocumented |
r2:float | Undocumented |
Draw on the background canvas a filled circle of radius r centered on (x, y).
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
r:float | Undocumented |
Draw on the background canvas a filled ellipse centered at (x, y) with a width of 2.0 * half_width, and a height of 2.0 * half_height.
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
halffloat | Undocumented |
halffloat | Undocumented |
Draw a filled sector portion between angle1 and angle2, of the interior of an ellipse centered at (x, y) with a width of half_width, and a height of 2.0 * half_height.
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
halffloat | Undocumented |
halffloat | Undocumented |
angle1:float | Undocumented |
angle2:float | Undocumented |
Draw on the background canvas a filled polygon with coordinates (x[i], y[i]).
Parameters | |
x:Sequence[ | Undocumented |
y:Sequence[ | Undocumented |
Draw a filled quadrilateral on the canvas with corners at (x0, y0), (x1, y1), (x2, y2), and (x3, y3).
Parameters | |
x0:float | Undocumented |
y0:float | Undocumented |
x1:float | Undocumented |
y1:float | Undocumented |
x2:float | Undocumented |
y2:float | Undocumented |
x3:float | Undocumented |
y3:float | Undocumented |
Draw on the background canvas a rectangle of width (2 * halfWidth and height (2 * halfHeight) centered at point (x, y).
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
halffloat | Undocumented |
halffloat | Undocumented |
Draw a filled sector portion between angle1 and angle2, of the interior of a circle centered at (x, y) with a radius r.
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
r:float | Undocumented |
angle1:float | Undocumented |
angle2:float | Undocumented |
Draw on the background canvas a filled square whose sides are of length 2r, centered on (x, y).
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
r:float | Undocumented |
Draw a filled triangle on the canvas with corners at (x0, y0), (x1, y1), and (x2, y2).
Parameters | |
x0:float | Undocumented |
y0:float | Undocumented |
x1:float | Undocumented |
y1:float | Undocumented |
x2:float | Undocumented |
y2:float | Undocumented |
Return the color of the pixel at the given user coordinates
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
Returns | |
pygame.Color | Undocumented |
Return True if the queue of keys the user typed is not empty. Otherwise return False.
Returns | |
bool | Undocumented |
Draw on the background canvas a line from (x0, y0) to (x1, y1).
Parameters | |
x0:float | Undocumented |
y0:float | Undocumented |
x1:float | Undocumented |
y1:float | Undocumented |
Return True if the mouse has been left-clicked since the last time mousePressed was called, and False otherwise.
Returns | |
bool | Undocumented |
Return the x coordinate in user space of the location at which the mouse was most recently left-clicked. If a left-click hasn't happened yet, raise an exception, since mouseX() shouldn't be called until mousePressed() returns True.
Returns | |
float | Undocumented |
Return the y coordinate in user space of the location at which the mouse was most recently left-clicked. If a left-click hasn't happened yet, raise an exception, since mouseY() shouldn't be called until mousePressed() returns True.
Returns | |
float | Undocumented |
Remove the first key from the queue of keys that the the user typed, and return that key.
Returns | |
str | Undocumented |
Draw pic on the background canvas centered at (x, y). pic is an object of class picture.Picture. x and y default to the midpoint of the background canvas.
Parameters | |
picstr | Undocumented |
x:float | Undocumented |
y:float | Undocumented |
Draw on the background canvas a point at (x, y).
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
Draw on the background canvas a polygon with coordinates (x[i], y[i]).
Parameters | |
x:Sequence[ | Undocumented |
y:Sequence[ | Undocumented |
Draw on the background canvas a polyline with coordinates (x[i], y[i]).
Parameters | |
x:Sequence[ | Undocumented |
y:Sequence[ | Undocumented |
Draw a quadrilateral on the canvas with corners at (x0, y0), (x1, y1), (x2, y2), and (x3, y3).
Parameters | |
x0:float | Undocumented |
y0:float | Undocumented |
x1:float | Undocumented |
y1:float | Undocumented |
x2:float | Undocumented |
y2:float | Undocumented |
x3:float | Undocumented |
y3:float | Undocumented |
Draw on the background canvas a rectangle of width (2 * halfWidth and height (2 * halfHeight) centered at point (x, y).
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
halffloat | Undocumented |
halffloat | Undocumented |
Draw a sector portion between angle1 and angle2, of the interior of a circle centered at (x, y) with a radius r.
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
r:float | Undocumented |
angle1:float | Undocumented |
angle2:float | Undocumented |
Set the size of the canvas to w pixels wide and h pixels high. Calling this function is optional. If you call it, you must do so before calling any drawing function.
Parameters | |
w:float | Undocumented |
h:float | Undocumented |
Set the pen color to c, where c is an object of class Color. c defaults to dudraw.BLACK.
Parameters | |
c:Color | Undocumented |
Set the pen color to c, where c is an object of class Color. c defaults to dudraw.BLACK.
Parameters | |
r:int | Undocumented |
g:int | Undocumented |
b:int | Undocumented |
Set the pen radius to r, thus affecting the subsequent drawing of points and lines. If r is 0.0, then points will be drawn with the minimum possible radius and lines with the minimum possible width.
Parameters | |
w:float | Undocumented |
Set the x-scale of the canvas such that the minimum x value is min and the maximum x value is max.
Parameters | |
min:float | Undocumented |
max:float | Undocumented |
Set the y-scale of the canvas such that the minimum y value is min and the maximum y value is max.
Parameters | |
min:float | Undocumented |
max:float | Undocumented |
Copy the background canvas to the window canvas, and then wait for msec milliseconds. msec defaults to infinity.
Parameters | |
msec:float | Undocumented |
Draw on the background canvas a square whose sides are of length 2r, centered on (x, y).
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
r:float | Undocumented |
Draw string s on the background canvas centered at (x, y).
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
s:str | Undocumented |
Draw a triangle on the canvas with corners at (x0, y0), (x1, y1), and (x2, y2).
Parameters | |
x0:float | Undocumented |
y0:float | Undocumented |
x1:float | Undocumented |
y1:float | Undocumented |
x2:float | Undocumented |
y2:float | Undocumented |
Check if any new event has occured (such as a key typed or button pressed). If a key has been typed, then put that key in a queue.
Dispatch to a function that does regression testing, or to a dialog-box-handling function.
Draw on the background canvas a pixel at (x, y).
Parameters | |
x:float | Undocumented |
y:float | Undocumented |
Convert c, an object of type Color, to an equivalent object of type pygame.Color. Return the result.
Parameters | |
c:Color | Undocumented |
Returns | |
pygame.Color | Undocumented |
Undocumented
Parameters | |
p:Sequence[ | Undocumented |
Returns | |
Sequence[ | Undocumented |
Copy the background canvas to the window canvas. Then wait forever, that is, until the user closes the dudraw window.