I am trying to edit the colours of the flag so they represent the flag of Sweden but I am not getting results. Any ideas on what I'm doing wrong? The program currently draw random circles and I am trying to edit the parameters to manipulate the colours (blue and yellow).Thanks
# using the SimpleGraphics library
from SimpleGraphics import *
# use the random library to generate random numbers
import random
diameter = 15
width, height = getWidth(), getHeight()
cx, cy = width // 2, height // 2
##
# returns a valid colour based on the input coordinates
#
# @param x is an x-coordinate
# @param y is a y-coordinate
# @return a colour based on the input x,y values for the given flag
##
def define_colour(x,y):
##
# add your code to this method and change the return value
if getHeight() <= cx <= getWidth() or getHeight() <= cy <= getWidth:
return 'blue'
else:
return 'yellow'
return c
# This is the ONLY place you should modify this file
# (except for maybe changing the size of the graphics window)
##
return None
# repeat until window is closed
while not closed():
# generate random x and y values
x = random.randint(0, getWidth())
y = random.randint(0,getHeight())
# set colour for current circle
setFill( define_colour(x,y) )
# draw the current circle
ellipse(x, y, diameter, diameter)
Aucun commentaire:
Enregistrer un commentaire