So my program is designed to manipulate certain coordinates in order to create this image:
So basically my program draw a bunch of random circles and I have to manipulate the line of equation to create the red sections. So far my image is the following:
I can't seem to figure out how to add another line equation to create the other red section. Any help would be greatly appreciated!
# using the SimpleGraphics library
from SimpleGraphics import *
# tell SimpleGraphics to only draw when I use the update() function
setAutoUpdate(False)
# use the random library to generate random numbers
import random
# size of the circles drawn
diameter = 15
resize(600, 400)
##
# returns a vaid color 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
slopeOne = (200 - 300)/(0-150)
b = 0 - (slopeOne * 200)
#slopeTwo = (0-150)/(200 - 300)
#b = 200 - (slopeOne * )
lineEquationOne = (slopeOne * x) + b
#lineEquationTwo = (slope * x) + b
if y > lineEquationOne:
return "white"
else:
return 'red'
######################################################################
#
# Do NOT change anything below this line
#
######################################################################
# repeat until window is closed
while not closed():
for i in range(500):
# 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)
update()
Aucun commentaire:
Enregistrer un commentaire