This code should draw the concentric circle in a patch design and alternate its colours between, Red, Blue, Green(or whatever the user enters from the validColours list) but it wont work. Somebody fix this please.

``````from graphics import *

def main():
x = 0
y = 0
while not(3<=x<=9):
x = input("Enter The Width Of Your Patch: ")
while not(3<=y<=9):
y = input("Enter The Height Of Your Patch: ")
validColours = ["red", "green", "blue", "orange", "grey"]
colour1 = ""
colour2 = ""
colour3 = ""
while not(colour1 in validColours):
colour1 = raw_input("Enter The 1st Colour Of Your Design: ")
while colour2 ==  colour1 or not(colour2 in validColours):
colour2 = raw_input("Enter The 2nd Colour Of Your Design: ")
while colour3 == colour1 or colour3 == colour2 or not(colour3  in validColours):
colour3 = raw_input("Enter The 3rd Colour Of Your Design: ")
win = GraphWin("MiniProject", x * 100, y * 100)
borderColour =[colour1,colour2,colour3] * x + [colour1,colour2,colour3] * y
drawPatch1(win, x, y, borderColour)

def drawPatch1(win, x, y, borderColour):
for i in range(10):
radius = 50 - (i * 5)
patch1 = Circle(Point(100, 100 + (i * 5)), radius)
patch1.setOutline(borderColour)
patch1.draw(win)``````

Where did you get the module graphics from?? I don't have it on my default list of libraries.

hopefully this works for you

I do not know what you want to accomplish, but this code does at least something:

``````from graphics import *

def main():
x = 0
y = 0
while not(3<=x<=9):
x = int(raw_input("Enter The Width Of Your Patch: "))
while not(3<=y<=9):
y = int(raw_input("Enter The Height Of Your Patch: "))
validColours = ["red", "green", "blue", "orange", "grey"]
colour1 = ""
colour2 = ""
colour3 = ""
while not(colour1 in validColours):
colour1 = raw_input("Enter The 1st Colour Of Your Design: ")
while colour2 ==  colour1 or not(colour2 in validColours):
colour2 = raw_input("Enter The 2nd Colour Of Your Design: ")
while colour3 == colour1 or colour3 == colour2 or not(colour3  in validColours):
colour3 = raw_input("Enter The 3rd Colour Of Your Design: ")
win = GraphWin("MiniProject", x * 100, y * 100)
borderColour =[colour1,colour2,colour3] * x + [colour1,colour2,colour3] * y
drawPatch1(win, x, y, borderColour)
win.mainloop()

def drawPatch1(win, x, y, borderColour):
for i, colour in enumerate(borderColour):
radius = 50 - (i * 5)
patch1 = Circle(Point(100, 100 + (i * 5)), radius)
patch1.setOutline(colour)
patch1.draw(win)
main()``````

Tony thanks for your help, i should have worded it better. Basically our task is to draw a patchwork quilt sort of thing that looks like the image below. I have drawn the first patch which is the border, (the concentric circles) image of them is below, and i havent yet drawn the second patch. So i am attempting to draw the whole quilt using the circle design, and the colours must alternate from red to blue to green. Hopefully the pictures will help.

So you should have color going around all time red-blue-green and every second line (odd zero based count inside the sub pattern) is unfilled at min or max of x or y, in middle the other pattern with white square at center. Still I do not see connection to the expanding ripple pattern.

Okay, any ideas how to have the circle design on the whole patch alternating colours ?? thanks

Do you have to use the graphic module ???

Yeahh thats the only thing we've been taught to use. So yeah has to be grpahics/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.