turtle.setworldcoordinates() function in Python
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
This function is used to set up a user-defined coordinate system. This performs a reset. If mode ‘world’ is already active, all drawings are redrawn according to the new coordinates.
Note: In user-defined coordinate systems angles may appear distorted.
Syntax : turtle.setworldcoordinates(llx, lly, urx, ury)
- llx: a number, x-coordinate of lower left corner of canvas
- lly: a number, y-coordinate of lower left corner of canvas
- urx: a number, x-coordinate of upper right corner of canvas
- ury: a number, y-coordinate of upper right corner of canvas
Below is the implementation of the above method with some examples :
Example 1 :
In the above two examples, the code are the same and only the difference of world coordinates differ the output as shown below :
Example 3 :
Here, we can see that the all previous drawing is set to new world coordinates ( drawing enlarges ).