눈사람
# exercise_4.py
# This program draws a winter scene with a Christmas treee and a snowman
# by: Scott Gordon
from graphics import *
# Create main window
def main():
win = GraphWin("Snowman", 800, 600)
win.setCoords(-8, -8, 6, 6)
win.setBackground("grey")
center = Point(0, 0)
# Draw horizon line and color upper half blue and bottom half white
horizon = Line(Point(-8, 0), Point(8, 0))
horizon.setWidth(2)
horizon.draw(win)
sky = Rectangle(Point(-8, 0), Point(8, 6))
sky.setFill("blue")
sky.draw(win)
# Add triangle for tree and color green
tree_top = Polygon(Point(-3, 4), Point(-5, -4), Point(-1, -4))
tree_top.setFill("green")
tree_top.draw(win)
# Add rectangle for tree bottom and color brown
tree_bottom = Rectangle(Point(-2.5, -4), Point(-3.5, -5))
tree_bottom.setFill("brown")
tree_bottom.draw(win)
# Stack 3 circles each smaller than the next moving up the y coord
snowman_bottom = Circle(Point(2, -4), 2)
snowman_bottom.setFill("White")
snowman_bottom.draw(win)
snowman_mid = Circle(Point(2, -2), 1.5)
snowman_mid.setFill("White")
snowman_mid.draw(win)
snowman_top = Circle(Point(2, -.5), 1)
snowman_top.setFill("White")
snowman_top.draw(win)
# Draw snowman's face on the top circle
snowman_eye1 = Circle(Point(2.25, -.75), .10)
snowman_eye1.setFill("Black")
snowman_eye1.draw(win)
snowman_eye2 = snowman_eye1.clone()
snowman_eye2.move(-.75, 0)
snowman_eye2.draw(win)
snowman_nose = Polygon(Point(1.75, -1.0), Point(2.0, -1.25), Point(1.95, -1.0))
snowman_nose.setFill("Orange")
snowman_nose.draw(win)
win.getMouse()
win.close()
main()
Reference
이 문제에 관하여(눈사람), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/sagordondev/snowman-4ch5텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)