Rosaces modélisées
par
, 15/12/2020 à 19h30 (846 Affichages)
Alors voici Rosaces 1.0, un petit programme Python avec le module Tkinter qui permet d'afficher des rosaces numérisées (modélisées) et aussi, mais là c'est pour faire la blague, un test de psychanalyse!
Voici: rosaces_1-0.py
Et la version Rosaces 1.2 rosaces_1-2.py, plus complète.
Alors bien évidemment ce n'est pas tiré de nulle-part, encore d'une vidéo de MicMaths:
Et voici le code-source que j'ai développé pour 1.0
Et le code-source pour 1.2:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 # --*-- coding:utf-8 --*--# #Dessin des tables de multiplications #en Rosaces modulo 360. # from tkinter import * from math import pi from math import cos from math import sin global y y=1 def dessin(): can.delete(ALL) y=yy x=1 xmax=360 angle=(2*pi)/xmax while x<xmax+1: z=y*x a1=0-(((x%xmax)*angle)-(pi/2)) a2=0-(((z%xmax)*angle)-(pi/2)) x1,y1=275+250*cos(a1),275-250*sin(a1) x2,y2=275+250*cos(a2),275-250*sin(a2) can.create_line(x1,y1,x2,y2,width=1,fill="black") x=x+1 def augmente(): global yy yy=yy+1 dessin() def diminue(): global yy yy=yy-1 if yy<2: yy=2 dessin() yy=y fen=Tk() can=Canvas(fen,bg="white",height=550,width=550) can.pack(side=LEFT) b1=Button(fen,text="Quitter",command=fen.destroy) b1.pack(side=BOTTOM) b2=Button(fen,text="Augmenter",command=augmente) b2.pack() b3=Button(fen,text="Diminuer",command=diminue) b3.pack() fen.mainloop()
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76 # --*-- coding:utf-8 --*--# #Dessin des tables de multiplications #en Rosaces modulo 360. # from tkinter import * from math import pi from math import cos from math import sin def dessin(yy,xx): txt=yy,"modulo",xx can.delete(ALL) y=yy x=1 xmax=xx angle=(2*pi)/xmax while x<xmax+1: z=y*x a1=0-(((x%xmax)*angle)-(pi/2)) a2=0-(((z%xmax)*angle)-(pi/2)) x1,y1=275+250*cos(a1),275-250*sin(a1) x2,y2=275+250*cos(a2),275-250*sin(a2) can.create_line(x1,y1,x2,y2,width=1,fill="black") x=x+1 print(yy,"modulo",xx) def augmente(): global yy yy=yy+1 dessin(yy,xx) def diminue(): global yy yy=yy-1 if yy<2: yy=2 dessin(yy,xx) def plusprecis(): global xx xx=xx+10 dessin(yy,xx) def moinsprecis(): global xx xx=xx-10 if xx<10: xx=10 dessin(yy,xx) yy=1 xx=360 fen=Tk() can=Canvas(fen,bg="white",height=550,width=550) can.pack(side=LEFT) b1=Button(fen,text="Quitter",command=fen.destroy) b1.pack(side=BOTTOM) b2=Button(fen,text="Augmenter",command=augmente) b2.pack() b3=Button(fen,text="Diminuer",command=diminue) b3.pack() b4=Button(fen,text="+ Précis",command=plusprecis) b4.pack() b5=Button(fen,text="- Précis",command=moinsprecis) b5.pack() fen.mainloop()