{"action":"closed","issue":{"url":"https://api.github.com/repos/Matchoo95/Programming/issues/1","labels_url":"https://api.github.com/repos/Matchoo95/Programming/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/Matchoo95/Programming/issues/1/comments","events_url":"https://api.github.com/repos/Matchoo95/Programming/issues/1/events","html_url":"https://github.com/Matchoo95/Programming/issues/1","id":119584701,"number":1,"title":"Coursework Term 1","user":{"login":"Matchoo95","id":16089712,"avatar_url":"https://avatars.githubusercontent.com/u/16089712?v=3","gravatar_id":"","url":"https://api.github.com/users/Matchoo95","html_url":"https://github.com/Matchoo95","followers_url":"https://api.github.com/users/Matchoo95/followers","following_url":"https://api.github.com/users/Matchoo95/following{/other_user}","gists_url":"https://api.github.com/users/Matchoo95/gists{/gist_id}","starred_url":"https://api.github.com/users/Matchoo95/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Matchoo95/subscriptions","organizations_url":"https://api.github.com/users/Matchoo95/orgs","repos_url":"https://api.github.com/users/Matchoo95/repos","events_url":"https://api.github.com/users/Matchoo95/events{/privacy}","received_events_url":"https://api.github.com/users/Matchoo95/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-30T21:27:08Z","updated_at":"2015-11-30T21:27:31Z","closed_at":"2015-11-30T21:27:31Z","body":"# PYTHON COURSEWORK: A PATCHWORK SAMPLER\r\n# MATTHEW HAWKINS 769535\r\n# TERM 1\r\n\r\nfrom graphics import *\r\n\r\n\r\ndef main():\r\n    #set variables\r\n    patchWorkSize = 0\r\n    colours = [\"\", \"\", \"\"]\r\n    \r\n    #get user inputs\r\n    patchWorkSize, colours = userInputs()\r\n    \r\n    #draw patches\r\n    drawPatchwork(patchWorkSize, colours)\r\n    \r\n    \r\n   \r\n    \r\n\r\ndef userInputs():\r\n    availableSizes = ['5', '7', '9']\r\n    patchWorkSize = input(\"Enter the number of size of the patchwork, available options are '5', '7' or '9': \")  #put on two seperate lines\r\n    while patchWorkSize not in availableSizes or patchWorkSize.isalpha():\r\n        patchWorkSize = input(\"Please input a valid measurements e.g. '5', '7' or '9': \")  \r\n    \r\n\r\n    availableColours = ['red', 'green', 'blue', 'orange', 'magenta', 'cyan']\r\n    colours = []   \r\n    for i in range(3):\r\n        getColours = input(\"Enter a colour for the patch design, a list of available colours can be request by typing 'colours', you can't have the same colour more than once: \") #put on two seperate lines\r\n        if getColours == \"colours\":\r\n            print(availableColours)\r\n        else:\r\n            while (getColours not in availableColours) or (getColours not in availableColours):\r\n                getColours = input(\"Please enter a valid colour: \")\r\n                colours.append(getColours)\r\n\r\n    \r\n    return int(patchWorkSize), colours\r\n \r\n \r\n \r\ndef drawPatchwork(patchWorkSize, colours):\r\n    win = GraphWin(\"patchwork\", patchWorkSize * 100, patchWorkSize * 100)\r\n    win.setBackground(\"white\")\r\n    win.setCoords(0, 0, 1, 1)\r\n    \r\n    x = 0\r\n    y = 0\r\n    \r\n    \r\n    lineX = 0\r\n    lineY = 0\r\n    \r\n    \r\n    for j in range(patchWorkSize):\r\n        lineDown = Line(Point(lineX, lineY), Point(lineX, lineY))\r\n        lineDown.setOutline(\"black\")\r\n        lineDown.draw(win)\r\n        lineX = lineX + 0.2\r\n        \r\n        \r\n    lineX = 0\r\n    lineY = 0\r\n    \r\n    for k in range(patchWorkSize):\r\n        lineAcross = Line(Point(lineX, lineY), Point(lineX, lineY))\r\n        lineAcross.setOutline(\"black\")\r\n        lineAcross.draw(win)\r\n        lineY = lineY + 0.2\r\n        \r\n    \r\n    \r\n    for l in range(patchWorkSize):\r\n        n = l\r\n        for l in range(patchWorkSize):\r\n            drawPatchTwo(win, x, y, patchWorkSize, colours)\r\n        \r\n    for m in range(patchWorkSize):\r\n        x = x + 0.2\r\n        y = y + 0.2\r\n        \r\n        drawPatchOne(win, x, y, patchWorkSize, colours) \r\n\r\n \r\ndef drawPatchOne(win, x, y, patchWorkSize, colours): \r\n\r\n    x = x + 45\r\n    y = y + 45\r\n    \r\n    radius = 55\r\n    \r\n    for n in range(patchWorkSize):\r\n\r\n        radius = radius - 5\r\n        x = y + 5\r\n            \r\n        centre = Point(x, y)\r\n        loops = Circle(centre, radius)\r\n        loops.setWidth(1)\r\n            \r\n        for o in range(patchWorkSize):\r\n            loops.setOutline(colours)\r\n            loops.draw(win)\r\n            mouse = win.getMouse()\r\n            \r\ndef drawPatchTwo(win, x, y, patchWorkSize, colours):\r\n    \r\n    for p in range(patchWorkSize):\r\n        \r\n        for q in range(patchWorkSize):\r\n            radius = 5\r\n            miniCircle = Circle(Point(x, y), radius)\r\n            miniCircle.draw(win)\r\n            miniCircle.setFill(colours)\r\n            mouse = win.getMouse()\r\n\r\nmain()\r\n\r\n# make sure you draw the correct patch in the correct pattern\r\n# make sure the colours circle through the user inputted circles\r\n# make sure user cant choose the same colour twice\r\n\r\n# advanced -- swap two clicked patches around\r\n"}}