module documentation

dudraw.py

The dudraw module defines functions that allow the user to create a simple 2-dimensional 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 canvas a circle of radius r centered on (x, y).
Function clear Clear the canvas to color c, where c is an object of class Color. c defaults to dudraw.WHITE.
Function clear_rgb Clear the canvas to color defined by r, g, and b. Defaults to white (255, 255, 255).
Function ellipse Draw on the 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_arc 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_sector 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_annulus Draw a filled annulus centered at (x, y) with outer radius r1, and inner radius r2.
Function filled_circle Draw on the canvas a filled circle of radius r centered on (x, y).
Function filled_ellipse Draw on the 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_elliptical_sector 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_polygon Draw on the canvas a filled polygon with coordinates (x[i], y[i]).
Function filled_quadrilateral Draw a filled quadrilateral on the canvas with corners at (x0, y0), (x1, y1), (x2, y2), and (x3, y3).
Function filled_rectangle Draw on the canvas a rectangle of width (2 * halfWidth and height (2 * halfHeight) centered at point (x, y).
Function filled_sector 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_square Draw on the canvas a filled square whose sides are of length 2r, centered on (x, y).
Function filled_triangle Draw a filled triangle on the canvas with corners at (x0, y0), (x1, y1), and (x2, y2).
Function get_canvas_height Return the height of the current canvas.
Function get_canvas_width Return the width of the current canvas.
Function get_pen_color Return the pen color as an object of class Color.
Function get_pixel_color Return the color of the pixel at the given user coordinates.
Function has_next_key_typed Return True if the user has pressed a key since the last call, otherwise False.
Function keys_pressed Return the set of keys that are currently being held down by the user.
Function keys_released Return the set of keys that the user has released since the last time this function was called.
Function keys_typed Return the set of keys that the user has typed since the last time this function was called.
Function line Draw on the canvas a line from (x0, y0) to (x1, y1).
Function mouse_clicked Return True if the left mouse button has been pressed since the last check, and False otherwise.
Function mouse_dragged Return True if the mouse is being click-and-dragged on the canvas, and False otherwise.
Function mouse_is_pressed Return True if the left mouse button is currently being held down, and False otherwise.
Function mouse_released Return True if the left mouse button has been released since the last check, and False otherwise.
Function mouse_x Return the x coordinate in user space of the mouse cursor.
Function mouse_y Return the y coordinate in user space of the mouse cursor.
Function next_key Return a string representing a key that was typed since the last time this function, or the keys_typed() function was called.
Function next_key_typed Return a string representing a key that was typed since the last time this function, or the keys_typed() function was called.
Function picture Draw pic on the canvas centered at (x, y).
Function point Draw on the canvas a point at coordinates (x, y).
Function polygon Draw on the canvas a polygon with coordinates (x[i], y[i]).
Function polyline Draw on the 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 canvas a rectangle of width (2 * halfWidth and height (2 * halfHeight) centered at point (x, y).
Function save Save the window canvas as a .jpg to filepath specified.
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_canvas_size Set the size of the canvas to w pixels wide and h pixels high.
Function set_font_family Set the font family to f (e.g. 'Helvetica' or 'Courier').
Function set_font_size Set the font size to s (e.g. 12, 14, 16..etc).
Function set_pen_color Set the pen color to c, where c is an object of class Color. c defaults to dudraw.BLACK.
Function set_pen_color_rgb Set the pen color using red, green, and blue values. Defaults to black.
Function set_pen_width Set the pen width/radius to w
Function set_scale Set the x-scale and y-scale of the canvas to the same range for both directions.
Function set_x_scale Set the x-scale of the canvas such that the minimum y value is min and the maximum y value is max.
Function set_y_scale 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 canvas to the window canvas, and then wait for msec milliseconds. msec defaults to 0.0.
Function square Draw on the canvas a square whose sides are of length 2r, centered on (x, y).
Function text Draw a line of string on the 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_for_events 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_x Undocumented
Function _factor_y Undocumented
Function _intersect Undocumented
Function _line_width_pixels Undocumented
Function _main Dispatch to a function that does regression testing, or to a dialog-box-handling function.
Function _make_sure_window_created Undocumented
Function _pen_width_pixels Undocumented
Function _pixel Draw on the canvas a pixel at (x, y).
Function _pygame_color Convert c, an object of type Color, to an equivalent object of type pygame.Color. Return the result.
Function _regression_test Perform regression testing.
Function _scale_point Undocumented
Function _scale_x Undocumented
Function _scale_y Undocumented
Function _show Copy the canvas to the window canvas.
Function _show_and_wait_forever Copy the canvas to the window canvas. Then wait forever, that is, until the user closes the dudraw window.
Function _user_x Undocumented
Function _user_y Undocumented
Constant _BORDER Undocumented
Constant _DEFAULT_CANVAS_SIZE Undocumented
Constant _DEFAULT_FONT_FAMILY Undocumented
Constant _DEFAULT_FONT_SIZE Undocumented
Constant _DEFAULT_PEN_WIDTH Undocumented
Constant _DEFAULT_XMAX Undocumented
Constant _DEFAULT_XMIN Undocumented
Constant _DEFAULT_YMAX Undocumented
Constant _DEFAULT_YMIN Undocumented
Variable _canvas_height Undocumented
Variable _canvas_width Undocumented
Variable _keys_pressed Undocumented
Variable _keys_released Undocumented
Variable _keys_typed Undocumented
Variable _mouse_clicked Undocumented
Variable _mouse_dragged Undocumented
Variable _mouse_is_pressed Undocumented
Variable _mouse_pos Undocumented
Variable _mouse_released Undocumented
Variable _pen_width Undocumented
Variable _window_created Undocumented
Variable _xmax Undocumented
Variable _xmin Undocumented
Variable _ymax Undocumented
Variable _ymin Undocumented
def annulus(x, y, r1, r2):

Draw an annulus centered at (x, y) with outer radius r1, and inner radius r2.

An annulus is a ring shape region between two circles centered at the same point but the outer circle r1 has larger radius than the inner circle r2

Parameters
x:floatx-coordinate of the center of the two circles
y:floatx-coordinate of the center of the two circles
r1:floatradius of of the outer circle (larger radius)
r2:floatradius of of the inner circle (smaller radius)
def arc(x, y, r, angle1, angle2):

Draw an arc portion between angle1 and angle2, of the circumference of a circle centered at (x, y) with a radius r.

An arc is a contiguous portion of a circle between angle1 and angle2. Note that the line of arc starts at angle1 and goes to angle2 in counter clock-wise direction.

Parameters
x:floatx-coordinate of the center of the circle
y:floaty-coordinate of the center of the circle
r:floatthe radius of the circle
angle1:floatthe starting angle of the arc
angle2:floatthe ending angle of the arc
def circle(x, y, r):

Draw on the canvas a circle of radius r centered on (x, y).

Parameters
x:floatx-coordinate of the center of the circle
y:floaty-coordinate of the center of the circle
r:floatradius of the circle
def clear(c=WHITE):

Clear the canvas to color c, where c is an object of class Color. c defaults to dudraw.WHITE.

Parameters
c:Colorthe color to be used to clear the background, defaults to white
def clear_rgb(r=255, g=255, b=255):

Clear the canvas to color defined by r, g, and b. Defaults to white (255, 255, 255).

Parameters
r:floatred color value. 0 for minimum red and 255 for maximum red, defaults to 255
g:floatgreen color value. 0 for minimum red and 255 for maximum green, defaults to 255
b:floatblue color value. 0 for minimum red and 255 for maximum blue, defaults to 255
def ellipse(x, y, half_width, half_height):

Draw on the 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:floatx-coordinate of the center of the ellipse
y:floaty-coordinate of the center of the ellipse
half_width:floathalf the width of the ellipse. Width is the maximum horizontal distance between two points on the surface of the ellipse
half_height:floathalf the height of the ellipse. Height is the maximum vertical distance between two points on the surface of the ellipse
def elliptical_arc(x, y, half_width, half_height, angle1, angle2):

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.

An arc is a contiguous portion of the ellipse between angle1 and angle2. Note that the line of arc starts at angle1 and goes to angle2 in counter clock-wise direction.

Parameters
x:floatx-coordinate of the center of the ellipse
y:floaty-coordinate of the center of the ellipse
half_width:floathalf the width of the ellipse. Width is the maximum horizontal distance between two points on the surface of the ellipse
half_height:floathalf the height of the ellipse. Height is the maximum vertical distance between two points on the surface of the ellipse
angle1:floatthe starting angle of the arc
angle2:floatthe ending angle of the arc
def elliptical_sector(x, y, half_width, half_height, angle1, angle2):

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.

This is like a slice of an elliptical shaped pizza. Note that the line of the arc of the sector starts at angle1 and goes to angle2 in counter clock-wise direction.

Parameters
x:floatx-coordinate of the center of the ellipse
y:floaty-coordinate of the center of the ellipse
half_width:floathalf the width of the ellipse. Width is the maximum horizontal distance between two points on the surface of the ellipse
half_height:floathalf the height of the ellipse. Height is the maximum vertical distance between two points on the surface of the ellipse
angle1:floatthe starting angle of the arc
angle2:floatthe ending angle of the arc
def filled_annulus(x, y, r1, r2):

Draw a filled annulus centered at (x, y) with outer radius r1, and inner radius r2.

An annulus is a ring shape region between two circles centered at the same point but the outer circle r1 has larger radius than the inner circle r2

Parameters
x:floatx-coordinate of the center of the two circles
y:floatx-coordinate of the center of the two circles
r1:floatradius of of the outer circle (larger radius)
r2:floatradius of of the inner circle (smaller radius)
def filled_circle(x, y, r):

Draw on the canvas a filled circle of radius r centered on (x, y).

Parameters
x:floatx-coordinate of the center of the circle
y:floaty-coordinate of the center of the circle
r:floatradius of the circle
def filled_ellipse(x, y, half_width, half_height):

Draw on the 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:floatx-coordinate of the center of the ellipse
y:floaty-coordinate of the center of the ellipse
half_width:floathalf the width of the ellipse. Width is the maximum horizontal distance between two points on the surface of the ellipse
half_height:floathalf the height of the ellipse. Height is the maximum vertical distance between two points on the surface of the ellipse
def filled_elliptical_sector(x, y, half_width, half_height, angle1, angle2):

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.

This is like a slice of an elliptical shaped pizza. Note that the line of the arc of the sector starts at angle1 and goes to angle2 in counter clock-wise direction.

Parameters
x:floatx-coordinate of the center of the ellipse
y:floaty-coordinate of the center of the ellipse
half_width:floathalf the width of the ellipse. Width is the maximum horizontal distance between two points on the surface of the ellipse
half_height:floathalf the height of the ellipse. Height is the maximum vertical distance between two points on the surface of the ellipse
angle1:floatthe starting angle of the arc
angle2:floatthe ending angle of the arc
def filled_polygon(x, y):

Draw on the canvas a filled polygon with coordinates (x[i], y[i]).

The lists x and y must contain the same number of values. The two lists correspond to x-coordinates and y-coordinates of points (x[0], y[0]), (x[1], y[1]), (x[2], y[2]),..., (x[-1], y[-1]) on the polygon. Each point on the polygon connects to the point that follows it so (x_0, x_0) connects to (x[1], y[1]) with a straight line, then (x[1], y[1]) connects to (x[2], y[2]) and so on until (x[-1], y[-1]) connects to (x[0], y[0]).

Parameters
x:Sequence[float]a list of x-coordinates of the points on the polygon
y:Sequence[float]a list of y-coordinates of the points on the polygon
def filled_quadrilateral(x0, y0, x1, y1, x2, y2, x3, y3):

Draw a filled quadrilateral on the canvas with corners at (x0, y0), (x1, y1), (x2, y2), and (x3, y3).

Parameters
x0:floatx-coordinate of the first point of the quadrilateral
y0:floaty-coordinate of the first point of the quadrilateral
x1:floatx-coordinate of the second point of the quadrilateral
y1:floaty-coordinate of the second point of the quadrilateral
x2:floatx-coordinate of the third point of the quadrilateral
y2:floaty-coordinate of the third point of the quadrilateral
x3:floatx-coordinate of the fourth point of the quadrilateral
y3:floaty-coordinate of the fourth point of the quadrilateral
def filled_rectangle(x, y, half_width, half_height):

Draw on the canvas a rectangle of width (2 * halfWidth and height (2 * halfHeight) centered at point (x, y).

Parameters
x:floatx-coordinate of the center of the rectangle
y:floaty-coordinate of the center of the rectangle
half_width:floathalf the width of the rectangle
half_height:floathalf the height of the rectangle
def filled_sector(x, y, r, angle1, angle2):

Draw a filled sector portion between angle1 and angle2, of the interior of a circle centered at (x, y) with a radius r.

This is like a slice of circle shaped pizza. Note that the line of the arc of the sector starts at angle1 and goes to angle2 in counter clock-wise direction.

Parameters
x:floatx-coordinate of the center of the circle
y:floaty-coordinate of the center of the circle
r:floatthe radius of the circle
angle1:floatthe starting angle of the arc
angle2:floatthe ending angle of the arc
def filled_square(x, y, r):

Draw on the canvas a filled square whose sides are of length 2r, centered on (x, y).

Parameters
x:floatx-coordinate of the center of the square
y:floaty-coordinate of the center of the square
r:floathalf the width of the square
def filled_triangle(x0, y0, x1, y1, x2, y2):

Draw a filled triangle on the canvas with corners at (x0, y0), (x1, y1), and (x2, y2).

Parameters
x0:floatx-coordinate of the first point of the triangle
y0:floaty-coordinate of the first point of the triangle
x1:floatx-coordinate of the second point of the triangle
y1:floaty-coordinate of the second point of the triangle
x2:floatx-coordinate of the third point of the triangle
y2:floaty-coordinate of the third point of the triangle
def get_canvas_height():

Return the height of the current canvas.

Returns
floatthe canvas height in pixels
def get_canvas_width():

Return the width of the current canvas.

Returns
floatthe canvas width in pixels
def get_pen_color():

Return the pen color as an object of class Color.

Returns
the current value of pen color. This is an object of class Color
def get_pixel_color(x, y):

Return the color of the pixel at the given user coordinates.

Parameters
x:floatthe x-coordinate of the pixel
y:floatthe y-coordinate of the pixel
Returns
Colorthe color of the pixel at (x, y)
def has_next_key_typed():

Return True if the user has pressed a key since the last call, otherwise False.

Returns
boola boolen representing whether a key has been pressed
def keys_pressed():

Return the set of keys that are currently being held down by the user.

Returns
set[str]a set of strings representing the keys being held
def keys_released():

Return the set of keys that the user has released since the last time this function was called.

Returns
set[str]a set of strings representing the keys released
def keys_typed():

Return the set of keys that the user has typed since the last time this function was called.

Returns
set[str]a set of strings representing the keys typed
def line(x0, y0, x1, y1):

Draw on the canvas a line from (x0, y0) to (x1, y1).

The placement of the line on the canvas will depend on the values of (x1, y1), (x2, y2) as well as the x-scale and y-scale. Note that if the coordinates are outside the range of min and max x-scale or y-scale then the point won't appear on the canvas

Parameters
x0:floatx-coordinate of the first point of the line segment
y0:floaty-coordinate of the first point of the line segment
x1:floatx-coordinate of the second point of the line segment
y1:floaty-coordinate of the second point of the line segment
def mouse_clicked():

Return True if the left mouse button has been pressed since the last check, and False otherwise.

Returns
boolTrue if the left mouse button has been pressed since last check; False otherwise
def mouse_dragged():

Return True if the mouse is being click-and-dragged on the canvas, and False otherwise.

Returns
boolTrue if the mouse has moved while held; False otherwise
def mouse_is_pressed():

Return True if the left mouse button is currently being held down, and False otherwise.

Returns
boolTrue if the left mouse button is pressed; False otherwise
def mouse_released():

Return True if the left mouse button has been released since the last check, and False otherwise.

Returns
boolTrue if the left mouse button has been released since last check; False otherwise
def mouse_x():

Return the x coordinate in user space of the mouse cursor.

Returns
floatthe x-coordinate of the location of the mouse
def mouse_y():

Return the y coordinate in user space of the mouse cursor.

Returns
floatthe y-coordinate of the location of the mouse
def next_key():

Return a string representing a key that was typed since the last time this function, or the keys_typed() function was called.

Returns
stra strings representing the key typed
def next_key_typed():

Return a string representing a key that was typed since the last time this function, or the keys_typed() function was called.

Returns
stra strings representing the key typed
def picture(filepath, x=None, y=None):

Draw pic on the canvas centered at (x, y).

The file can be of type .jpg, .png, .gif or .bmp. Filepath is specified as a string, and (x, y) defaults to the midpoint of the canvas.

Parameters
filepath:stra string representing the path of the image file
x:floatx-coordinate of the center of the image, defaults to x-coordinate of the center of the canvas
y:floaty-coordinate of the center of the image, defaults to y-coordinate of the center of the canvas
def point(x, y):

Draw on the canvas a point at coordinates (x, y).

The placement of the point on the canvas will depend on the values of (x, y) as well as the x-scale and y-scale. Note that if the coordinates are outside the range of min and max x-scale or y-scale then the point won't appear on the canvas

Parameters
x:floatthe x-coordinate of the point
y:floatthe y-coordinate of the point
def polygon(x, y):

Draw on the canvas a polygon with coordinates (x[i], y[i]).

The lists x and y must contain the same number of values. The two lists correspond to x-coordinates and y-coordinates of points (x[0], y[0]), (x[1], y[1]), (x[2], y[2]),..., (x[-1], y[-1]) on the polygon. Each point on the polygon connects to the point that follows it so (x_0, x_0) connects to (x[1], y[1]) with a straight line, then (x[1], y[1]) connects to (x[2], y[2]) and so on until (x[-1], y[-1]) connects to (x[0], y[0]).

Parameters
x:Sequence[float]a list of x-coordinates of the points on the polygon
y:Sequence[float]a list of y-coordinates of the points on the polygon
def polyline(x, y):

Draw on the canvas a polyline with coordinates (x[i], y[i]).

The lists x and y must contain the same number of values. The two lists correspond to x-coordinates and y-coordinates of points (x[0], y[0]), (x[1], y[1]), (x[2], y[2]),..., (x[-1], y[-1]) on the polyline. Each point on the polyline connects to the point that follows it so (x_0, x_0) connects to (x[1], y[1]) with a straight line, then (x[1], y[1]) connects to (x[2], y[2]) and so on.

Parameters
x:Sequence[float]a list of x-coordinates of the points on the polyline
y:Sequence[float]a list of y-coordinates of the points on the polyline
def quadrilateral(x0, y0, x1, y1, x2, y2, x3, y3):

Draw a quadrilateral on the canvas with corners at (x0, y0), (x1, y1), (x2, y2), and (x3, y3).

Parameters
x0:floatx-coordinate of the first point of the quadrilateral
y0:floaty-coordinate of the first point of the quadrilateral
x1:floatx-coordinate of the second point of the quadrilateral
y1:floaty-coordinate of the second point of the quadrilateral
x2:floatx-coordinate of the third point of the quadrilateral
y2:floaty-coordinate of the third point of the quadrilateral
x3:floatx-coordinate of the fourth point of the quadrilateral
y3:floaty-coordinate of the fourth point of the quadrilateral
def rectangle(x, y, half_width, half_height):

Draw on the canvas a rectangle of width (2 * halfWidth and height (2 * halfHeight) centered at point (x, y).

Parameters
x:floatx-coordinate of the center of the rectangle
y:floaty-coordinate of the center of the rectangle
half_width:floathalf the width of the rectangle
half_height:floathalf the height of the rectangle
def save(filepath):

Save the window canvas as a .jpg to filepath specified.

Parameters
filepath:strthe path of a folder to which the image will be saved
def sector(x, y, r, angle1, angle2):

Draw a sector portion between angle1 and angle2, of the interior of a circle centered at (x, y) with a radius r.

This is like a slice of circle shaped pizza. Note that the line of the arc of the sector starts at angle1 and goes to angle2 in counter clock-wise direction.

Parameters
x:floatx-coordinate of the center of the circle
y:floaty-coordinate of the center of the circle
r:floatthe radius of the circle
angle1:floatthe starting angle of the arc
angle2:floatthe ending angle of the arc
def set_canvas_size(w=_DEFAULT_CANVAS_SIZE, h=_DEFAULT_CANVAS_SIZE):

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:floatwidth of canvas in pixels, defaults to 512
h:floatheight of canvas in pixels, defaults to 512
Raises
Exceptionerror if the dudraw window was already created
Exceptionerror if width or height values are non-positive
def set_font_family(f=_DEFAULT_FONT_FAMILY):

Set the font family to f (e.g. 'Helvetica' or 'Courier').

This changes the font used to draw text on the canvas.

Parameters
f:strthe new font used for text on canvas, defaults to "Helvetica" if no font is specified
def set_font_size(s=_DEFAULT_FONT_SIZE):

Set the font size to s (e.g. 12, 14, 16..etc).

the value of the font size is measured in point. A point is equivalent to about 1.33 pixels

Parameters
s:intnew font size in point, defaults to 12 if no value is specified
def set_pen_color(c=_DEFAULT_PEN_COLOR):

Set the pen color to c, where c is an object of class Color. c defaults to dudraw.BLACK.

Parameters
c:Colorthe new pen color, defaults to black if no value is passed
def set_pen_color_rgb(r=255, g=255, b=255):

Set the pen color using red, green, and blue values. Defaults to black.

Parameters
r:intred color value. 0 for minimum red and 255 for maximum red, defaults to 255
g:intgreen color value. 0 for minimum red and 255 for maximum green, defaults to 255
b:intblue color value. 0 for minimum red and 255 for maximum blue, defaults to 255
def set_pen_width(w=_DEFAULT_PEN_WIDTH):

Set the pen width/radius to w

This affects the subsequent drawing of points and lines. If w is 0.0, then points will be drawn with the minimum possible width and lines with the minimum possible width.

Parameters
w:floatnew value for the pen radius in pixels. This value must be non-negative, defaults to 0.0
Raises
Exceptionerror thrown if the value of w is negative
def set_scale(min, max):

Set the x-scale and y-scale of the canvas to the same range for both directions.

The value of max must be greater than the value of min

Parameters
min:floatthe minimum value of the x-scale and y-scale, defaults to 0.0 if no value is passed
max:floatthe maximum value of the x-scale and y-scale, defaults to 1.0 if no value is passed
Raises
Exceptionerror if the min value is greater or equal to the max value
def set_x_scale(min=_DEFAULT_XMIN, max=_DEFAULT_XMAX):

Set the x-scale of the canvas such that the minimum y value is min and the maximum y value is max.

The value of max must be greater than the value of min

Parameters
min:floatthe minimum value of the x-scale, defaults to 0.0 if no value is passed
max:floatthe maximum value of the x-scale, defaults to 1.0 if no value is passed
Raises
Exceptionerror if the min value is greater or equal to the max value
def set_y_scale(min=_DEFAULT_YMIN, max=_DEFAULT_YMAX):

Set the y-scale of the canvas such that the minimum y value is min and the maximum y value is max.

The value of max must be greater than the value of min

Parameters
min:floatthe minimum value of the y-scale, defaults to 0.0 if no value is passed
max:floatthe maximum value of the y-scale, defaults to 1.0 if no value is passed
Raises
Exceptionerror if the min value is greater or equal to the max value
def show(msec=0.0):

Copy the canvas to the window canvas, and then wait for msec milliseconds. msec defaults to 0.0.

Note that everything we draw is on the canvas so won't show on the screen until we call show

Parameters
msec:floatamount of milliseconds to wait after show, defaults to 0.0
def square(x, y, r):

Draw on the canvas a square whose sides are of length 2r, centered on (x, y).

Parameters
x:floatx-coordinate of the center of the square
y:floaty-coordinate of the center of the square
r:floathalf the width of the square
def text(x, y, s):

Draw a line of string on the canvas centered at (x, y).

The string will appear on a single line. Note that (x, y) is the center of the rectangle that bounds the string. The string uses the current font and font size. Font and font size can be modified using the methods: set_font_family and set_font_size

Parameters
x:floatx-coordinate of the center of the text
y:floaty-coordinate of the center of the text
s:strthe string that will be draw on the canvas
def triangle(x0, y0, x1, y1, x2, y2):

Draw a triangle on the canvas with corners at (x0, y0), (x1, y1), and (x2, y2).

Parameters
x0:floatx-coordinate of the first point of the triangle
y0:floaty-coordinate of the first point of the triangle
x1:floatx-coordinate of the second point of the triangle
y1:floaty-coordinate of the second point of the triangle
x2:floatx-coordinate of the third point of the triangle
y2:floaty-coordinate of the third point of the triangle
def _ccw(a, b, c):

Undocumented

def _check_for_events():

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.

def _factor_x(w):

Undocumented

Parameters
w:floatUndocumented
Returns
floatUndocumented
def _factor_y(h):

Undocumented

Parameters
h:floatUndocumented
Returns
floatUndocumented
def _intersect(a, b, c, d):

Undocumented

def _line_width_pixels():

Undocumented

Returns
floatUndocumented
def _main():

Dispatch to a function that does regression testing, or to a dialog-box-handling function.

def _make_sure_window_created():

Undocumented

def _pen_width_pixels():

Undocumented

Returns
floatUndocumented
def _pixel(x, y):

Draw on the canvas a pixel at (x, y).

Parameters
x:floatUndocumented
y:floatUndocumented
def _pygame_color(c):

Convert c, an object of type Color, to an equivalent object of type pygame.Color. Return the result.

Parameters
c:ColorUndocumented
Returns
pygame.ColorUndocumented
def _regression_test():

Perform regression testing.

def _scale_point(p):

Undocumented

Parameters
p:Sequence[float]Undocumented
Returns
Sequence[float]Undocumented
def _scale_x(x):

Undocumented

Parameters
x:floatUndocumented
Returns
floatUndocumented
def _scale_y(y):

Undocumented

Parameters
y:floatUndocumented
Returns
floatUndocumented
def _show():

Copy the canvas to the window canvas.

def _show_and_wait_forever():

Copy the canvas to the window canvas. Then wait forever, that is, until the user closes the dudraw window.

def _user_x(x):

Undocumented

Parameters
x:floatUndocumented
Returns
floatUndocumented
def _user_y(y):

Undocumented

Parameters
y:floatUndocumented
Returns
floatUndocumented
_BORDER: float =

Undocumented

Value
0.0
_DEFAULT_CANVAS_SIZE: int =

Undocumented

Value
512
_DEFAULT_FONT_FAMILY: str =

Undocumented

Value
'Helvetica'
_DEFAULT_FONT_SIZE: int =

Undocumented

Value
12
_DEFAULT_PEN_WIDTH: float =

Undocumented

Value
0.0
_DEFAULT_XMAX: float =

Undocumented

Value
1.0
_DEFAULT_XMIN: float =

Undocumented

Value
0.0
_DEFAULT_YMAX: float =

Undocumented

Value
1.0
_DEFAULT_YMIN: float =

Undocumented

Value
0.0
_canvas_height =

Undocumented

_canvas_width =

Undocumented

_keys_pressed: set =

Undocumented

_keys_released: set =

Undocumented

_keys_typed: set =

Undocumented

_mouse_clicked: bool =

Undocumented

_mouse_dragged: bool =

Undocumented

_mouse_is_pressed: bool =

Undocumented

_mouse_pos: tuple[float, ...] =

Undocumented

_mouse_released: bool =

Undocumented

_pen_width =

Undocumented

_window_created: bool =

Undocumented

_xmax =

Undocumented

_xmin =

Undocumented

_ymax =

Undocumented

_ymin =

Undocumented