-
-
Save joshgura/98c3919790e9f19f019d8805169cf42c to your computer and use it in GitHub Desktop.
*my first program* - uses tkinter and a list to draw my logo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tkinter import * | |
root = Tk() | |
canvas = Canvas(root, width=550, height=550) | |
canvas.pack() | |
color_table = ['', 'red', 'black', 'yellow'] | |
logo_pattern_11_by_11 = [1, 2, 3, 2, 2, 3, 2, 2, 3, 2, 1, | |
1, 2, 3, 2, 2, 3, 2, 2, 3, 2, 1, | |
2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, | |
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, | |
2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, | |
2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, | |
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, | |
2, 2, 3, 2, 2, 2, 2, 2, 3, 2, 2, | |
1, 2, 3, 3, 2, 2, 2, 3, 3, 2, 1, | |
1, 2, 2, 3, 3, 2, 3, 3, 2, 2, 1, | |
1, 1, 2, 2, 3, 3, 3, 2, 2, 1, 1] | |
def josh_logo_draw(): | |
''' | |
counter that runs from range (1, 11) vertically and horizontally | |
done with a nested drawing of squares in range(1, 11) | |
to access my fake matrix of colors, represented by 1, 2 and 3. | |
''' | |
for row in range(0, 11): | |
for column in range(0,11): | |
x = column * 50 | |
y = row * 50 | |
color = logo_pattern_11_by_11[row*11+column] | |
canvas.create_rectangle(x, y, x+50, y+50, fill=color_table[color], width=0) | |
#print(y,row*column) #used this to debug | |
if __name__ == '__main__': | |
josh_logo_draw() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment