def redCircles():
win = GraphWin("Patch2" ,100,100)
for x in (10, 30, 50, 70, 90):
for y in (10, 30, 50, 70, 90):
c = Circle(Point(x,y), 10)
c.setFill("red")
c.draw(win)
これは私のコードで、出力は次のようになります。
def redCircles():
win = GraphWin("Patch2" ,100,100)
for x in (10, 30, 50, 70, 90):
for y in (10, 30, 50, 70, 90):
c = Circle(Point(x,y), 10)
c.setFill("red")
c.draw(win)
これは私のコードで、出力は次のようになります。
これをテストしたところ、うまくいきました。
from graphics import *
def redCircles():
win = GraphWin("Patch2" ,100,100)
for x in (10, 30, 50, 70, 90):
for y in (10, 30, 50, 70, 90):
c = Circle(Point(x,y), 10)
d = Circle(Point(x,y), 10)
if x in (30, 70):
r = Rectangle(Point(x - 10, y), Point(x + 10, y + 10))
else:
r = Rectangle(Point(x - 10, y- 10), Point(x, y + 10))
c.setFill("red")
d.setOutline("red")
r.setFill("white")
r.setOutline('white')
c.draw(win)
r.draw(win)
d.draw(win)
if __name__=='__main__':
redCircles()
塗りつぶされた円を描画し、次にそれらの半分以上に長方形を描画し、アウトラインを元に戻すために輪郭を描いた円を描画しています。if は、現在の列をチェックします。