Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-40283: Clarify turtle.circle() documentation#20928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
mikeweilgart wants to merge3 commits intopython:main
base:main
Choose a base branch
Loading
frommikeweilgart:patch-1

Conversation

@mikeweilgart
Copy link

@mikeweilgartmikeweilgart commentedJun 17, 2020
edited by bedevere-bot
Loading

Make it clear what effect the radius and extent arguments have
on the direction of the circle/arc to be drawn (the referenced bug).

Clarify the rest of the explanation also, as this module is meant for complete beginners.

https://bugs.python.org/issue40283

lebalz reacted with hooray emoji
Make it clear what effect the radius and extent arguments haveon the direction of the circle/arc to be drawn (the referenced bug).Clarify the rest of the explanation as this module is meant for complete beginners.
@the-knights-who-say-ni

This comment was marked as outdated.

@mikeweilgart

This comment was marked as resolved.

@bedevere-app

This comment has been minimized.

@ezio-melotti

This comment was marked as resolved.

If extent is given, do not draw the whole circle, but only an
arc of the circle extent degrees wide starting from the current
position. If extent is negative, draw the arc while moving
backwards around the circle from the current position. In either
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think here it would help talking about clockwise and counter-clockwise instead of using "backwards".

willingc reacted with thumbs up emoji
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The trick is that either radius or extent, or both, may be negative. Any time either is switched from negative to positive or back, the resulting direction of drawing (clockwise or counter-clockwise) will be switched also.

The circle or arc drawn is not a true geometric curve (impossible
on a computer screen composed of pixels), but rather is composed
of many very short straight steps. The number of steps to use is
calculated automatically to give the appearance of a true curve.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

In order to keep the docstring more concise, I would merge this paragraph with the next and remove the part about why the circle is created by steps. Saying that it's done in steps, that the number is calculated automatically if not specified, and that this can be used to draw polygons it's enough IMHO.

willingc reacted with thumbs up emoji
>>> turtle.circle(-50, 60) # 60 degree arc with radius 50 drawn clockwise
>>> turtle.circle(80, steps=6) # regular hexagon
Unusual cases:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not sure it's worth separating these examples from the ones above.

willingc reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I like these examples. I agree that they should not be separated from above.

mikeweilgart and ezio-melotti reacted with thumbs up emoji
@bedevere-app

This comment has been minimized.

Copy link
Contributor

@willingcwillingc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks for the PR@mikeweilgart. I think you have raised some good points for clarification. Since this is a docstring, I think we should lean to being precise with descriptions.

Arguments:
radius -- a number
extent (optional) -- a number
radius -- a number (distance)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
radius--anumber (distance)
radius--anumber (distancefromcircle'scentertoitscircumference)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

  1. Circumference is itself a distance; it doesn't properly mean "edge of the circle." I think "distance from circle's center to its edge" is a decent idea, except:
  2. The "circle" method only sometimes draws a circle.

I'll consider how to improve the whole explanation though.

willingc reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Perhaps simply "distance from center to boundary".

Please do remember that this is a docstring not a tutorial.

center is radius units to the left of the turtle. If radius is
negative, the center is to the right.
If extent is given, do not draw the whole circle, but only an
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
Ifextentisgiven,donotdrawthewholecircle,butonlyan
If*extent*isgiven,drawanarconthecircle'scircumferencefromthecurrentpositiontoanendingpositionusingacentralangleof*extent*degrees.

negative, the center is to the right.
If extent is given, do not draw the whole circle, but only an
arc of the circle extent degrees wide starting from the current
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
arc of the circle extent degrees wide starting from the current

If extent is given, do not draw the whole circle, but only an
arc of the circle extent degrees wide starting from the current
position. If extent is negative, draw the arc while moving
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
position.Ifextentisnegative,drawthearcwhilemoving
If*extent*isnegative,drawthearcwhilemoving

extent (optional) -- a number (angle, in degrees)
steps (optional) -- an integer
With one argument, draw a circle with the given radius. The
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
Withoneargument,drawacirclewiththegivenradius.The
Drawacirclewiththegivenradius.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Except that if there is more than one argument, a circle is NOT drawn. It may be a portion of a circle, or a portion of a polygon. Try running any proposed documentation past a bright seven-year-old and you'll see some of the rationale for the wording choices I made. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Perhaps:
Draw a circle with the given radius when passed the default argument radius.
When additional arguments are given, a circle, arc, polygon, or portion of a polygon may be drawn.

>>> turtle.circle(50)
>>> turtle.circle(120, 180) # semicircle
Examples (for a Turtle instance named turtle):
>>> turtle.circle(50) # full circle of radius 50 drawn counter-clockwise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
>>>turtle.circle(50)#fullcircleof radius 50drawn counter-clockwise
>>>turtle.circle(50)# circle drawn counter-clockwise with radius 50

mikeweilgart reacted with thumbs up emoji
>>> turtle.circle(120, 180) # semicircle
Examples (for a Turtle instance named turtle):
>>> turtle.circle(50) # full circle of radius 50 drawn counter-clockwise
>>> turtle.circle(-75) # full circle of radius 75 drawn clockwise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
>>>turtle.circle(-75)#fullcircleof radius 75 drawn clockwise
>>>turtle.circle(-75)# circledrawn clockwise with radius 75

mikeweilgart reacted with thumbs up emoji
>>> turtle.circle(50) # full circle of radius 50 drawn counter-clockwise
>>> turtle.circle(-75) # full circle of radius 75 drawn clockwise
>>> turtle.circle(-50, 60) # 60 degree arc with radius 50 drawn clockwise
>>> turtle.circle(80, steps=6) # regular hexagon
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
>>>turtle.circle(80,steps=6)#regularhexagon
>>>turtle.circle(50,steps=6)# hexagon composed of 6 points on the circle's circumference

Examples (for a Turtle instance named turtle):
>>> turtle.circle(50) # full circle of radius 50 drawn counter-clockwise
>>> turtle.circle(-75) # full circle of radius 75 drawn clockwise
>>> turtle.circle(-50, 60) # 60 degree arc with radius 50 drawn clockwise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
>>>turtle.circle(-50,60)# 60 degree arc with radius 50drawn clockwise
>>>turtle.circle(-50,60)# 60 degree arcdrawn clockwisewith radius 50

>>> turtle.circle(-50, 60) # 60 degree arc with radius 50 drawn clockwise
>>> turtle.circle(80, steps=6) # regular hexagon
Unusual cases:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I like these examples. I agree that they should not be separated from above.

mikeweilgart and ezio-melotti reacted with thumbs up emoji
@adorilson

This comment was marked as resolved.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@willingcwillingcwillingc left review comments

@ezio-melottiezio-melottiezio-melotti left review comments

Assignees

No one assigned

Projects

Status: No status

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@mikeweilgart@the-knights-who-say-ni@ezio-melotti@adorilson@willingc@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp