Renderable
Renderable serves as the base class for any object with a width and height (most notably excluding lines and dots). The Renderable class does extend the Object class which tracks location and updates.
Last updated
Was this helpful?
Renderable serves as the base class for any object with a width and height (most notably excluding lines and dots). The Renderable class does extend the Object class which tracks location and updates.
Last updated
Was this helpful?
Quick Reference can help with simple issues or give you a basic understanding of the methods available, but it can never replace full documentation which is available .
We can initialize the default 3 shapes by calling their respective constructors:
The constructor has more arguments that are optional:
There are a few different Renderables that can be created:
Moving any Renderable is alike to moving a Location:
We can also make a Renderable move forward at its current heading/angle via:
You can also retrieve the Location with:
You can get the Location of the center of any Renderable:
You can also use this method to move the Renderable to place its center in a certain location:
You can get or modify the rotation of a Renderable like so:
You can also just make a Renderable look at a Location or Renderable:
You can also check the angle of the Renderable against any Object or Location:
You can retrieve or modify the size of the Renderable like so:
All Renderables have a default Color of black; the color can be retrieved or set via:
Renderables also have an optional border that is set to Color.NONE by default. You can set or retrieve the border like so:
You can get or set the border_width
seperately with:
Fill exists (as seen above) to create Framed Renderables with ease. Fill can be toggled without calling the border()
method like so:
You can make any Object in pyDraw invisible with:
You can move objects to the front or back of layers with:
You can get the distance between a Renderable and another Renderable, or Location like so:
A transform is a data structure that represents the width, height, and rotation. You can copy the transform of a Renderable and set it to another transform:
You should only set the transform to other transforms retrieved from Renderables, however, it is possible to create one yourself:
You can also clone a Renderable by calling the aptly named:
For those who want to perform more advanced mathematics with their shapes, you can retrieve a (copy) list of vertices:
You can get the location and dimensions of a bounding box calculated by pyDraw around any Renderable:
You can check if a point is contained in any Renderable like so:
Or you can check if two Renderables are overlapping:
Although Text is classified as a Renderable, it is not directly resizable and has specific methods unique to Text: .
Note that these methods utilize the Renderables .
Note: This calculates the center by default (except for CustomPolygons), but you can get the of the shape by setting centroid=True
in the method arguments.