Пример #1
0
def draw_columns2(a_lst, height, column_width):
    graph.ouvre_fenetre(height, get_image_width(a_lst, column_width))
    for i in range(len(a_lst)):
        if not a_lst[i]:
            black_rectangle(i * column_width, i * column_width + column_width,
                            0, height)
    graph.attend_fenetre()
Пример #2
0
def draw_columns1(a_lst, height, column_width):
    graph.ouvre_fenetre(height, get_image_width(a_lst, column_width))
    for y in range(height):
        for x in range(get_image_width(a_lst, column_width)):
            if not a_lst[get_column_number(x, column_width)]:
                graph.plot(y, x)
    graph.attend_fenetre()
Пример #3
0
def draw_grid(mtx, size):
    image_size = get_image_size(mtx, size)
    graph.ouvre_fenetre(image_size[1], image_size[0])
    for i in range(count_lines(mtx)):
        for j in range(len(mtx[i])):
            if not mtx[i][j]:
                black_rectangle(j * size, j * size + size, i * size,
                                i * size + size)
    graph.attend_fenetre()
Пример #4
0
def sapin(haut, larg):
    graph.ouvre_fenetre(haut, 200)
    print((haut * 9) // 10)
    for i in range(0, (haut * 9) // 10):
        debut = larg // 2 + 1 - i
        fin = debut + 2 * i - 1
        segment_horiz(i, debut, fin)

    rectangle(9 * haut // 10, haut, larg // 2 - 20, larg // 2 + 20)
    graph.attend_fenetre()
Пример #5
0
def dessine_arche(arche, taille=50):
    h, l = taille_image(arche, taille)
    graph.ouvre_fenetre(h, l)
    for i in range(len(arche)):
        ligne = arche[i]
        for j in range(len(arche[0])):
            ele = ligne[j]
            if ele.lower() == "o" or ele == "0":
                rectangle_couleur(i * taille, (i + 1) * taille, j * taille,
                                  (j + 1) * taille, "#775B02")
    return
Пример #6
0
def dessine_bandes2(lst, hauteur, largeur_bandes):
    largeur = largeur_image(lst, largeur_bandes)
    graph.ouvre_fenetre(hauteur, largeur)

    # parcours bandes
    for i in range(len(lst)):
        if lst[i] == 0:
            rectangle(0, hauteur, largeur_bandes * i, largeur_bandes * (i + 1))

    # graph.attend_fenetre()
    return
Пример #7
0
def dessine_grille(lstlst, taille):
    ha, la = taille_image(lstlst, taille)
    graph.ouvre_fenetre(ha, la)

    nl = nb_lignes(lstlst)
    nc = nb_colonnes(lstlst)
    for il in range(nl):
        ligne = lstlst[il]
        for ic in range(nc):
            if ligne[ic] == 0:
                rectangle(taille * il, taille * (il + 1), taille * ic,
                          taille * (ic + 1))
Пример #8
0
def draw_grid(mtx, size):
    """
    Draws the grid of the labyrinth.
    :param mtx: The grid.
    :param size: The size of each grid content.
    """
    image_size = get_image_size(mtx, size)
    if graph.fengra is None:
        graph.ouvre_fenetre(image_size[0], image_size[1])
    for i in range(count_lines(mtx)):
        for j in range(len(mtx[i])):
            if mtx[i][j] != 1:
                draw_rectangle(j * size, i * size, size, get_color(mtx[i][j]))
Пример #9
0
def dessine_bandes1(lst, hauteur, largeur_bandes):
    largeur = largeur_image(lst, largeur_bandes)
    graph.ouvre_fenetre(hauteur, largeur)

    # parcour pixels
    for y in range(hauteur):
        for x in range(largeur):
            nb = num_bande(x, y, largeur_bandes)
            if lst[nb] == 0:
                graph.plot(y, x)

    # graph.attend_fenetre()
    return
Пример #10
0
    print("    1. bande noire a gauche")
    print("    2. rectangle noir sur blanc")
    print("    3. rectangle blanc sur noir")
    print("    4. numero bande")
    print("    5. condition noire")
    print("    6. rayures verticales")
    print("    7. damier")
    print("    8. damier colore")
    print("  100. Tout afficher")
    print("")
    reponse = int(input("Choisissez quelle reponse voir : "))
    print("")

    if reponse == 0 or reponse == 100:
        # Exemple
        graph.ouvre_fenetre(400, 600)
        noir(400, 600)
        graph.attend_fenetre()
    if reponse == 1 or reponse == 100:
        # Question 1
        graph.ouvre_fenetre(500, 800)
        bande_noire_gauche(500, 800, 100)
        graph.attend_fenetre()
    if reponse == 2 or reponse == 100:
        # Question 2
        graph.ouvre_fenetre(500, 800)
        rectangle_noir(500, 800, 50, 200, 150, 450)
        graph.attend_fenetre()
    if reponse == 3 or reponse == 100:
        # Question 3
        graph.ouvre_fenetre(500, 800)
Пример #11
0
            if c % (2 * band_width) > band_width:
                graph.plot(l, c)


def conditional_checkerboard(height, length, box_width):
    for y in range(height):
        for x in range(length):
            if (x % (2 * box_width) < box_width or y %
                (2 * box_width) < box_width) and (x %
                                                  (2 * box_width) > box_width
                                                  or y %
                                                  (2 * box_width) > box_width):
                graph.plot(y, x)


def nh(x, box_width):
    whichBand = x // box_width

    return whichBand


def nv(y, box_width):
    whichBand = y // box_width

    return whichBand


graph.ouvre_fenetre(400, 500)
conditional_checkerboard(400, 500, 20)
graph.attend_fenetre()
Пример #12
0

def rectangle(y1, y2, x1, x2):
    for x in range(x1, x2):
        for y in range(y1, y2):
            graph.plot(y, x)


def vertical_strip(image_height, image_width, band_width):
    for rectStart in range(0, image_width, band_width * 2):
        rectangle(0, image_height, rectStart, rectStart + band_width)


def checkerboard(image_height, image_width, box_width):
    boxStartX = 0
    boxStartY = 0

    for boxStartX in range(0, image_width, box_width * 2):
        for boxStartY in range(0, image_height, box_width * 2):
            rectangle(boxStartY, boxStartY + box_width, boxStartX,
                      boxStartX + box_width)

        for boxStartY in range(0, image_height, box_width * 2):
            rectangle(boxStartY + box_width, boxStartY + (2 * box_width),
                      boxStartX + box_width, boxStartX + (2 * box_width))


graph.ouvre_fenetre(120, 160)

graph.attend_fenetre()
Пример #13
0
    elif random == 8:
        return "black"


def rainbow_damier(width, height, length):
    cases = []
    last_column = -1
    for y in range(height):
        offset = 0
        y_column = get_column_number(y, length)
        if last_column != y_column:
            cases.append([get_random_color()])
            last_column = y_column
        if y_column % 2 != 0:
            offset = 1
        for x in range(width):
            x_column = get_column_number(x, length)
            if x_column == len(cases[y_column]):
                cases[y_column].append(get_random_color())
            if x_column % 2 - offset != 0:
                graph.plot(y, x, cases[y_column][x_column])


_width = 600
_height = 400
graph.ouvre_fenetre(_height, _width)

rainbow_damier(_width, _height, 50)

graph.attend_fenetre()