Пример #1
0
def fonctions_partie2():
    print("\n######################################")
    print("                Partie 2")
    print("######################################")

    # question 1
    print("\n------------- question 1 ------------------")
    lst = [1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0]
    print("largeur de l'image : ", largeur_image(lst, 20))

    import time

    # strategie 1
    print("\n------------- strategie 1 ------------------")
    dessine_bandes1(lst, 50, 20)
    graph.attend_fenetre()

    # strategie 2
    print("\n------------- strategie 2 ------------------")
    dessine_bandes2(lst, 50, 20)
    graph.attend_fenetre()

    # Temps de calcul
    start_time = time.time()
    dessine_bandes1(lst, 50, 20)
    print("Temps premiere strategie = ", time.time() - start_time)
    graph.fengra.ferme()
    graph.fengra = None
    start_time = time.time()
    dessine_bandes2(lst, 50, 20)
    print("Temps deuxieme strategie = ", time.time() - start_time)
    graph.fengra.ferme()
    graph.fengra = None
Пример #2
0
def fonctions_partie3():
    print("\n######################################")
    print("                Partie 3")
    print("######################################")

    lstlst = [[0, 1, 1, 0, 1, 1, 1, 0], [1, 0, 0, 1, 1, 0, 0, 1],
              [0, 1, 0, 1, 1, 0, 0, 1], [0, 1, 0, 1, 0, 0, 1, 1],
              [1, 0, 1, 0, 0, 1, 1, 0], [1, 1, 0, 0, 0, 1, 0, 1]]

    # question 1
    print("\n------------- question 1 ------------------")
    print("Nombre de lignes de lstlst : ", nb_lignes(lstlst))

    # question 2
    print("\n------------- question 2 ------------------")
    print("Nombre de lignes de lstlst : ", nb_colonnes(lstlst))

    # question 3
    print("\n------------- question 3 ------------------")
    print("Nombre de lignes de lstlst : ", taille_image(lstlst, 40))

    # question 4
    print("\n------------- question 4 ------------------")
    dessine_grille(lstlst, 40)
    graph.attend_fenetre()
Пример #3
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()
Пример #4
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()
Пример #5
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()
Пример #6
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()
Пример #7
0
    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)
        rectangle_blanc(500, 800, 50, 200, 150, 450)
        graph.attend_fenetre()