Image
- class Image(path, p1, *args)
An object representing a textured rectangle - an image
- Parameters
path – the filepath to the image
p1 – the image’s center
(x, y)
in world space*args – optional width and height or an optional top-right coordinate (p1 will be bottom-left).
- Raises
FileNotFoundError – image was not found
ValueError – unsupported image format
TypeError – arguments must be a filepath, a coordinate, and numbers
Examples
# Create an image at (0, 0) and load size from its file >>> Image("filepath.gif", (0, 0)) # Create an image at (0, 0) with size (100, 200) >>> Image("filepath.png", (0, 0), 100, 200) # Create an image from (0, 0) to (120, 20) >>> Image("filepath.jgp", (0, 0), (120, 20))
- set_transparency(*args: float) None
Sets the transparency of the object
- Parameters
*args (
float
) – a float or 4 floats corresponding to bottom-left, bottom-right, top-right, and top-left- Raises
TypeError – arguments must be floats
ValueError – transparency must be between 0 and 1
- Return type
None
- get_path() str
Returns: the filepath used by the image
- Return type
str