Feb-03-2023, 07:36 PM
I am new to Python but have previous general programming experience. I have Python 3.7 installed on Windows 11 and using Pyscripter as a development tool, display device is 1600 x 900 pixels.
I want to develop simple examples of visualising cartesian based fractal functions that the mixed target audience can see how fractals develop and change some parameters – hence adopting Turtle rather than more technical packages.
I am trying to understand how Screensize(), Setup() and especially Setworldcoordinates() interact when using Turtle graphics.
The following code snippet and outputs illustrate my confusion:
I also understood that setworldcoordinates() acted on the screensize “canvas”. However, in the code above, increasing tu.screensize to (2000,20000) had no effect on the output but then changing tu.setup to (800,800) gave the following output, changing both values.
I want to develop simple examples of visualising cartesian based fractal functions that the mixed target audience can see how fractals develop and change some parameters – hence adopting Turtle rather than more technical packages.
I am trying to understand how Screensize(), Setup() and especially Setworldcoordinates() interact when using Turtle graphics.
The following code snippet and outputs illustrate my confusion:
1 2 3 4 5 6 7 8 |
import turtle as tu tu.setup( 400 , 400 ) tu.screensize( 800 , 800 , bg = 'lightblue' ) tu.setworldcoordinates( - 1 , - 1 , 5 , 5 ) # Custom coordinate system tu.goto( 0 , 0 ) print ( "screensize is " ,tu.screensize()) print ( "window size is " ,tu.window_width(), tu.window_height()) tu.mainloop() |
Output:*** Remote Interpreter Reinitialized ***
screensize is (380, 380)
window size is 400 400
Reading the Python documentation I understand the initial screensize() assignment has been reset by setworldcoordinates() but not sure where the (380, 380) is derived from rather than (400,300) default, and can this be changed?I also understood that setworldcoordinates() acted on the screensize “canvas”. However, in the code above, increasing tu.screensize to (2000,20000) had no effect on the output but then changing tu.setup to (800,800) gave the following output, changing both values.
1 2 3 4 5 6 7 8 |
import turtle as tu tu.setup( 800 , 800 ) tu.screensize( 2000 , 2000 , bg = 'lightblue' ) tu.setworldcoordinates( - 1 , - 1 , 5 , 5 ) # Custom coordinate system tu.goto( 0 , 0 ) print ( "screensize is " ,tu.screensize()) print ( "window size is " ,tu.window_width(), tu.window_height()) tu.mainloop() |
Output:*** Remote Interpreter Reinitialized ***
screensize is (780, 780)
window size is 800 800
Can anyone explain why changing setup() parameters appears to affect both screensize and window size when using setworldcoordinates.