그래서 내 프로그램이 이미지를 생성하기 위해 특정 좌표를 조작 할 수 있도록 설계되었습니다 : 임의의 원 파이썬의 기울기를 그리기
그러니까 기본적으로 내 프로그램이 임의의 원의 무리를 그리고 난의 라인을 조작해야 방정식을 사용하여 빨간색 섹션을 만듭니다. 지금까지 내 이미지는 다음과 같습니다.
다른 빨간색 수식을 추가하여 다른 빨간색 섹션을 만드는 방법을 생각할 수 없습니다. 어떤 도움이라도 대단히 감사하겠습니다!
# 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-300)/(200 - 800)
b = 150 - (slopeTwo * 40)
lineEquationOne = (slopeOne * x) + b
lineEquationTwo = (slopeTwo * x) + b
if y > lineEquationOne:
return "red"
elif y > lineEquationTwo:
return "red"
else:
return 'white'
######################################################################
#
# 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()
SimpleGraphics 라이브러리의 출처는 어디입니까? 우리는 어떻게 사본을 얻을 수 있습니까? – martineau