JavaScript
x
22
22
1
import turtle as t
2
from random import randint, random
3
def draw_star(points, size, col, x, y):
4
t.penup()
5
t.goto(x, y)
6
t.pendown()
7
angle = 180 - (180 / points)
8
t.color(col)
9
t.begin_fill()
10
for i in range(points):
11
t.forward(size)
12
t.right(angle)
13
t.end_fill()
14
# Main code
15
while True:
16
ranPts = randint(2, 5) * 2 + 1
17
ranSize = randint(10, 50)
18
ranCol = (random(), random(), random())
19
ranX = randint(-350, 300)
20
ranY = randint(-250, 250)
21
draw_star(ranPts, ranSize, ranCol, ranX, ranY)
22
Question: How could I know the maximum values of coordinates of my screen? So I can have a better idea on how to set the values of ranX and ranY?
Thanks.
Advertisement
Answer
I found out this is what I need: t.window_width()
and t.window_height()
.