turtle.circle(r,360,150) 行是做什么的?我想不通
What does the line turtle.circle(r,360,150) do? I can't figure it out
所以我在网上找到了这段代码,因为我想制作自己的代码,所以我想通过查看所有不同行的作用来理解这个人在做什么,但我遇到了这条线,但我不知道它能做什么。我在网上找不到任何关于此的信息,如果我在单独的代码中尝试它,它就不起作用。这是来自游戏 connect 4 的一段代码,这是绘制圆圈的函数。我说的是
turtle.circle(r,360,150)
代码。它在这个小函数中:
def draw_circle(x,y,r,color): #draws a circle on x and y coordinates, with radius r and a color
turtle.up() #penup
turtle.goto(x,y-r) #turtle go to x and y-r coordinates so its a bit up
turtle.seth(0) #sets angle to east so ->
turtle.down() #pendown
turtle.fillcolor(color) #starts to fill in a color
turtle.begin_fill() #starts to fill the circle in the color
turtle.circle(r,360,150) #turtle draws a circle with radius r and
turtle.end_fill()
请原谅我对每一行的评论,我试图理解代码 :) 我认为 (r,360,150) 正在绘制一个半径为 r 且坐标为 360 和 150 的圆,但正如我之前所说,我在一个单独的文件中试过,它只是在 0,0 上画了一个圆圈。有人可以解释一下吗?
请务必在提问前阅读一些文档。如果你有时不这样做,Whosebug 社区会很生气))
来自python 3.10.4 documentation:
turtle.circle(radius, extent=None, steps=None)
Parameters:
- radius – a number
- extent – a number (or None)
- steps – an integer (or None)
Draw a circle with given radius. The center is radius units left of the turtle; extent – an angle – determines which part of the circle is drawn. If extent is not given, draw the entire circle. If extent is not a full circle, one endpoint of the arc is the current pen position. Draw the arc in counterclockwise direction if radius is positive, otherwise in clockwise direction. Finally the direction of the turtle is changed by the amount of extent.
As the circle is approximated by an inscribed regular polygon, steps determines the number of steps to use. If not given, it will be calculated automatically. May be used to draw regular polygons.
所以我在网上找到了这段代码,因为我想制作自己的代码,所以我想通过查看所有不同行的作用来理解这个人在做什么,但我遇到了这条线,但我不知道它能做什么。我在网上找不到任何关于此的信息,如果我在单独的代码中尝试它,它就不起作用。这是来自游戏 connect 4 的一段代码,这是绘制圆圈的函数。我说的是
turtle.circle(r,360,150)
代码。它在这个小函数中:
def draw_circle(x,y,r,color): #draws a circle on x and y coordinates, with radius r and a color
turtle.up() #penup
turtle.goto(x,y-r) #turtle go to x and y-r coordinates so its a bit up
turtle.seth(0) #sets angle to east so ->
turtle.down() #pendown
turtle.fillcolor(color) #starts to fill in a color
turtle.begin_fill() #starts to fill the circle in the color
turtle.circle(r,360,150) #turtle draws a circle with radius r and
turtle.end_fill()
请原谅我对每一行的评论,我试图理解代码 :) 我认为 (r,360,150) 正在绘制一个半径为 r 且坐标为 360 和 150 的圆,但正如我之前所说,我在一个单独的文件中试过,它只是在 0,0 上画了一个圆圈。有人可以解释一下吗?
请务必在提问前阅读一些文档。如果你有时不这样做,Whosebug 社区会很生气))
来自python 3.10.4 documentation:
turtle.circle(radius, extent=None, steps=None)
Parameters:
- radius – a number
- extent – a number (or None)
- steps – an integer (or None)
Draw a circle with given radius. The center is radius units left of the turtle; extent – an angle – determines which part of the circle is drawn. If extent is not given, draw the entire circle. If extent is not a full circle, one endpoint of the arc is the current pen position. Draw the arc in counterclockwise direction if radius is positive, otherwise in clockwise direction. Finally the direction of the turtle is changed by the amount of extent.
As the circle is approximated by an inscribed regular polygon, steps determines the number of steps to use. If not given, it will be calculated automatically. May be used to draw regular polygons.