Browse Source

bug racine carre

master
BARRAUX Arthur 2 years ago
parent
commit
a260d3f23d
  1. 7
      package/ctk_app.py
  2. 5
      package/tk_app.py

7
package/ctk_app.py

@ -332,12 +332,15 @@ class App(ctk.CTk):
def draw_graph(self): def draw_graph(self):
"""Dessine les points du graphique""" """Dessine les points du graphique"""
self.fonction_screen.delete('all') self.fonction_screen.delete('all')
min_x, max_x = map(int, self.fonction_bornes_entry.get().split(',')) min_x, max_x = map(int, self.fonction_bornes_entry.get().split(',')) # bornes du graphique
fonction_points = npi2tree(inf2npi(parse_string_to_list(self.fonction_entry.get()))).valeurs_de_fonction(min_x, max_x) fonction_points = npi2tree(inf2npi(parse_string_to_list(self.fonction_entry.get()))).valeurs_de_fonction(min_x, max_x)
max_y = max(fonction_points, key=lambda item: item[1])[1] max_y = max(fonction_points, key=lambda item: item[1])[1]
min_y = min(fonction_points, key=lambda item: item[1])[1] min_y = min(fonction_points, key=lambda item: item[1])[1]
self.draw_framing(min_x, max_x, min_y, max_y) self.draw_framing(min_x, max_x, min_y, max_y)
for i, (x, y) in enumerate(fonction_points): ratio = (fonction_points[0][0] - min_x) / (abs(max_x)+abs(min_x))
i = len(fonction_points) * ratio
for (x, y) in fonction_points:
image_x = i * (self.fonction_screen_width/len(fonction_points)) image_x = i * (self.fonction_screen_width/len(fonction_points))
image_y = self.fonction_screen_height - (y - min_y) * self.fonction_screen_height / (abs(max_y)+abs(min_y)) image_y = self.fonction_screen_height - (y - min_y) * self.fonction_screen_height / (abs(max_y)+abs(min_y))
self.fonction_screen.create_rectangle(image_x, image_y, image_x, image_y) self.fonction_screen.create_rectangle(image_x, image_y, image_x, image_y)
i += 1

5
package/tk_app.py

@ -322,7 +322,10 @@ class App(tk.Tk):
max_y = max(fonction_points, key=lambda item: item[1])[1] max_y = max(fonction_points, key=lambda item: item[1])[1]
min_y = min(fonction_points, key=lambda item: item[1])[1] min_y = min(fonction_points, key=lambda item: item[1])[1]
self.draw_framing(min_x, max_x, min_y, max_y) self.draw_framing(min_x, max_x, min_y, max_y)
for i, (x, y) in enumerate(fonction_points): ratio = (fonction_points[0][0] - min_x) / (abs(max_x)+abs(min_x))
i = len(fonction_points) * ratio
for (x, y) in fonction_points:
image_x = i * (self.fonction_screen_width/len(fonction_points)) image_x = i * (self.fonction_screen_width/len(fonction_points))
image_y = self.fonction_screen_height - (y - min_y) * self.fonction_screen_height / (abs(max_y)+abs(min_y)) image_y = self.fonction_screen_height - (y - min_y) * self.fonction_screen_height / (abs(max_y)+abs(min_y))
self.fonction_screen.create_rectangle(image_x, image_y, image_x, image_y) self.fonction_screen.create_rectangle(image_x, image_y, image_x, image_y)
i += 1
Loading…
Cancel
Save