LANGUAGE=PYTHON My goal was to write a function that draws a snowman at various scales, but as you can see, the scaling

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

LANGUAGE=PYTHON My goal was to write a function that draws a snowman at various scales, but as you can see, the scaling

Post by answerhappygod »

LANGUAGE=PYTHON
My goal was to write a function that draws a snowman at various
scales, but as you can see, the scaling function is not working
correctly. See if you can fix my code so that the snowman looks
correct at any scaling (not just the ones shown).
Language Python My Goal Was To Write A Function That Draws A Snowman At Various Scales But As You Can See The Scaling 1
Language Python My Goal Was To Write A Function That Draws A Snowman At Various Scales But As You Can See The Scaling 1 (70.59 KiB) Viewed 47 times
from graphics import *
def drawSnowman(win, x, y, size=1):
head = Circle(Point(x, y), 30 * size)
body = Circle(Point(x, y + 60), 40 * size)
base = Circle(Point(x, y + 120), 50 * size)
head.setFill("white")
body.setFill("white")
base.setFill("white")
leftEye = Oval(Point(x - 12, y-10), Point(x
- 7, y-4))
rightEye = Oval(Point(x + 7, y-10), Point(x + 12,
y-4))
leftEye.setFill("black")
rightEye.setFill("black")
base.draw(win)
body.draw(win)
head.draw(win)
leftEye.draw(win)
rightEye.draw(win)
def drawBackground(win):
sky = Rectangle(Point(0, 0), Point(400, 400))
sky.setFill("skyblue")
sky.draw(win)
ground = Rectangle(Point(0, 200), Point(400,
400))
ground.setFill("white")
ground.draw(win)
win = GraphWin('Snow Legion', 400, 400) # give title and
dimensions
drawBackground(win)
drawSnowman(win, 170, 150)
drawSnowman(win, 50, 170, size=.5)
drawSnowman(win, 350, 70, size=2)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply