@@ -60,7 +60,7 @@ def save_as_png(canvas: Canvas):
60
60
61
61
def make_animation (canvas : Canvas ):
62
62
if hasattr (canvas , "frame_number" ):
63
- cmd = ["magick" , "-delay" , "20 " , "-loop" , "0" ]
63
+ cmd = ["magick" , "-delay" , "10 " , "-loop" , "0" ]
64
64
frames = []
65
65
frames .extend (f"frame{ i } .png" for i in range (canvas .frame_number ))
66
66
cmd .extend (frames )
@@ -77,6 +77,7 @@ def key_callback(root: Tk, canvas: Canvas, event: Event):
77
77
root .quit ()
78
78
elif event .keysym == "s" :
79
79
make_animation (canvas )
80
+ root .quit ()
80
81
else :
81
82
print (f"évenement inconnu: { event } " )
82
83
@@ -244,43 +245,47 @@ def droite(x: complex, p: float) -> complex:
244
245
245
246
246
247
cA , cB = None , None
248
+ dot_radius = 0.1 if args .save else 0.03
247
249
248
250
249
- def intersect (r , d ):
251
+ def intersect (r , d , min_r ):
250
252
global cA , cB
251
253
252
254
P , Q = circle_intersect (A , r , B , r + d )
253
255
if not P :
254
256
return
255
257
256
- if cA :
257
- canvas .delete (cA )
258
- if cB :
259
- canvas .delete (cB )
258
+ if d > 0 :
259
+ if cA :
260
+ canvas .delete (cA )
261
+ if cB :
262
+ canvas .delete (cB )
260
263
261
- cA = circle (A , r , outline = "red" )
262
- cB = circle (B , r + d , outline = "red" )
264
+ cA = circle (A , r , outline = "red" )
265
+ cB = circle (B , r + d , outline = "red" )
263
266
264
- circle (P , 0.05 , fill = "white" )
265
- circle (Q , 0.05 , fill = "white" )
267
+ circle (P , dot_radius , fill = "white" )
268
+ circle (Q , dot_radius , fill = "white" )
266
269
267
270
save_as_png (canvas )
268
271
269
- if r > 0 :
270
- # rend l'animation plus fluide
271
- if r > 2 :
272
- e = 0.2
273
- elif r > 0.75 :
274
- e = 0.05
275
- else :
276
- e = 0.01
272
+ # rend l'animation plus fluide
273
+ if r - min_r > 2 :
274
+ e = 0.2
275
+ elif r - min_r > 1 :
276
+ e = 0.1
277
+ elif r - min_r > 0.1 :
278
+ e = 0.05
279
+ else :
280
+ e = 0.01
281
+ r -= e
277
282
278
- # e = 0.01 * r
279
- root .after (2 , lambda : intersect (r - e , d ))
283
+ if r > 0 :
284
+ root .after (20 , lambda : intersect (r , d , min_r ))
280
285
281
286
282
287
root .title ("Construction par ensemble de points d'une hyperbole" )
283
- intersect (12 , d )
284
- # intersect(12, -d)
288
+ intersect (12 , d , c - a )
289
+ intersect (12 + d , - d , c + a )
285
290
286
291
root .mainloop ()
0 commit comments