Ejemplo n.º 1
0
def initalize(cols, rows, showGrid=False):
    global pallet, grid, win, tools, lineThickness, saveMenu

    #if grid already exsists delete it then recreate it
    try:
        del grid
    except:
        pass

    pygame.display.set_icon(paintBrush)
    win = pygame.display.set_mode((int(wid), int(heigh) + 100))
    pygame.display.set_caption('Untitled')
    win.fill((255, 255, 255))

    #CREATION OF OBJECTS
    grid = pixelArt(win, int(wid), int(heigh), cols, rows, showGrid)
    grid.drawGrid()

    for x in range(len(grid.getGrid())):
        for y in range(len(grid.getGrid()[x])):
            if (x == 0 or x == len(grid.getGrid()) - 1 or y == 0
                    or y == len(grid.getGrid()[x]) - 1):
                grid.getGrid()[x][y].click(grid.screen, (0, 0, 0))

    pallet = colorPallet(win, 90, 90, 3, 3, True, 10, grid.height + 2)
    pallet.drawGrid()

    colorList = [(0, 0, 0), (255, 255, 255), (255, 0, 0), (0, 255, 0),
                 (0, 0, 255), (255, 255, 0), (255, 168, 0), (244, 66, 173),
                 (65, 244, 226)]
    pallet.setColor(colorList)

    tools = menu(win, 200, 40, 5, 1, True, grid.width - 210, grid.height + 50)
    tools.drawGrid()

    buttons = ['D', 'E', 'F', 'R', 'C']
    tools.setText(buttons)
    tools.drawGrid()

    l = tools.getGrid()
    l[0][0].show(grid.screen, (255, 0, 0), 1, True)

    lineThickness = menu(win, 180, 40, 4, 1, True, grid.width - 200,
                         grid.height + 10)
    lineThickness.drawGrid()

    buttons = ['1', '2', '3', '4']
    lineThickness.setText(buttons)

    saveMenu = menu(win, 140, 40, 2, 1, True, grid.width - 400,
                    grid.height + 25)
    saveMenu.drawGrid()

    buttons = ['Save', 'Open']
    saveMenu.setText(buttons)

    pygame.display.update()
Ejemplo n.º 2
0
                            tools.drawGrid(
                            )  #Redraw the grid so that we dont see the red highlight
                            buttons = ['D', 'E', 'F', 'R', 'C']
                            tools.setText(buttons)
                            l = tools.getGrid()
                            l[0][0].show(grid.screen, (255, 0, 0), 1, True)

                    #If they click on the color pallet
                    elif pos[0] >= pallet.startx and pos[
                            0] <= pallet.startx + pallet.width and pos[
                                1] >= pallet.starty and pos[
                                    1] <= pallet.starty + pallet.height:
                        clicked = pallet.clicked(pos)
                        color = clicked.getColor()  # Set current drawing color

                        pallet = colorPallet(win, 90, 90, 3, 3, True, 10,
                                             grid.height + 2)
                        pallet.drawGrid()

                        colorList = [(0, 0, 0), (255, 255, 255), (255, 0, 0),
                                     (0, 255, 0), (0, 0, 255), (255, 255, 0),
                                     (255, 168, 0), (244, 66, 173),
                                     (65, 244, 226)]
                        pallet.setColor(colorList)
                        clicked.show(grid.screen, (255, 0, 0), 3, True)

                    elif pos[0] >= lineThickness.startx and pos[
                            0] <= lineThickness.startx + lineThickness.width and pos[
                                1] >= lineThickness.starty and pos[
                                    1] <= lineThickness.starty + lineThickness.height:
                        lineThickness.drawGrid(
                        )  #Redraw the grid so that we dont see the red highlight