Closed BTWS2 closed 2 years ago
I fixed most of your examples by centring lines on the pixels and allowing small changes in the colour values.
However, polygon_circle()
still doesn't match. That's because you draw the left edge twice, and that matters when the line isn't along the pixel grid. The antialiasing will shade the neighbouring pixels darker when you repeatedly draw the same line. To avoid that, you have to only draw that edge once:
import math
import turtle
def polygon_circle(): # todo: isn't accepted because of the left edge.
a = math.sqrt(100 ** 2 - 50 ** 2)
r = 100 / (2 * math.sin(math.pi / 3))
turtle.up()
turtle.goto(50, -a)
turtle.down()
turtle.bgcolor('ivory')
turtle.fillcolor('yellow')
turtle.begin_fill()
turtle.circle(r, 360, 3)
turtle.end_fill()
polygon_circle()
If we want to avoid being so sensitive, we'd either have to figure out how to turn off antialiasing (I couldn't find an easy way), or use a more sophisticated comparison that looks at neighbouring pixels. We could experiment with that after we get the basics working, and I'll be interested to hear what students get stuck on.
What I did
I tried as many ways as possible to draw a triangle. These solutions are ok.
These are not.
What happened
Some solutions aren't accepted.
What I wanted to happen
All solutions should be accepted.
My environment
Describe the versions of everything you were using: