Ejemplo n.º 1
0
import draw

sche = [(0, 0, 0, 0), (1, 0, 4.9, 0), (2, 4.9, 16.9, 0), (3, 16.9, 32.4, 0),
        (4, 32.4, 40, 0)]

#cont = {0: {0, 1, 2, 3, 4, 5, 9, 10}, 1: {6, 7, 8, 11, 12}}
#cont = {0: {0, 1, 2, 3, 4, 5, 9, 10,6, 7, 8, 11, 12}}
cont = {0: {0}, 1: {1}, 2: {2}}
for i in range(5):
    cont[i] = {i}

draw.draw_canvas(sche, cont, 'a.png')

# rgbstr='aabbcc'
# print(tuple(ord(c) for c in rgbstr.decode('hex')))
Ejemplo n.º 2
0
from draw import initial_canvas, draw_canvas, draw_point

# initialise canvas (32*2 col, 32 row)
canvas = [[" " for x in range(64)] for y in range(32)]
initial_canvas(canvas)

# read data
f = open("data1.txt", "r")
dList = []
for line in f:
    tmp = eval(line)
    dList.append(tmp)

for (x, y) in dList:
    draw_point(x, y, canvas, mark='*')

draw_canvas(canvas)




Ejemplo n.º 3
0
                        draw.fill_square(screen, color, grid_column + pos[0],
                                         grid_row + pos[1])
    return


def on_size(event_pos: tuple) -> bool:
    for index, area in enumerate(settings.size_areas):
        if area.collidepoint(event_pos):
            # Index of areas are in order of size
            # Index + 1 = size option
            settings.change_size(index + 1)
            return True


settings = Settings()
draw.draw_canvas(screen, settings.colors)
while True:
    for event in pygame.event.get():
        # Red X is clicked
        if event.type == pygame.QUIT:
            pygame.quit()
            break
        # Mouse down could be an attempt to draw or change colors
        elif event.type == pygame.MOUSEBUTTONDOWN:
            # Left click only
            if event.button == 1:
                if on_canvas(event.pos):
                    drawing(settings.current_color)

                elif on_color_selector(event.pos):
                    settings.current_color = settings.colors[get_color_index(