-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRita.adb
123 lines (106 loc) · 3.75 KB
/
Rita.adb
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
With ada.text_io, ada.integer_text_io, Images, Bresenham, Tools, Console, Ada.strings.unbounded;
Use ada.text_io, ada.integer_text_io, Images, Bresenham, Tools, Console, Ada.strings.unbounded;
Procedure Rita is
choix: character;
r, v, b: integer;
Nom : unbounded_string;
H, L,
x0, y0,
x1, y1,
xmin, xmax,
ymin, ymax,
marge: integer;
MyImg : T_Image;
MyPix : Pixel;
begin
clearBelow;
Put ("Faites votre choix.", White, Black); new_line;
Put_line ("1. Tracé de segment");
Put_line ("2. Tracé de cercle");
sGet (choix, "12");
moveCursor (Up, 3); clearBelow;
Case choix is
when '1' =>
Put ("Tracé de segment de Bresenham", White, Black); new_line;
Put_line ("x0 : ");
Put_line ("y0 : ");
Put_line ("x1 : ");
Put_line ("y1 : ");
Put_line ("Marge : ");
Put_line ("R : ");
Put_line ("v : ");
Put_line ("B : ");
Put ("Nom : ");
moveCursor (Up, 8); sGet (x0);
moveCursor (right, 8); sGet (y0);
moveCursor (right, 8); sGet (x1);
moveCursor (right, 8); sGet (y1);
moveCursor (right, 8); sGet (marge, 0);
moveCursor (right, 8); sGet (R, 0, 255);
moveCursor (right, 8); sGet (V, 0, 255);
moveCursor (right, 8); sGet (B, 0, 255);
moveCursor (right, 8); Nom := to_unbounded_string(get_line);
MyPix := (float(R)/255.0,float(V)/255.0,float(B)/255.0);
if x0 < x1 then
xmin := x0;
xmax := x1;
else
xmin := x1;
xmax := x0;
end if;
if y0 < y1 then
ymin := y0;
ymax := y1;
else
ymin := y1;
ymax := y0;
end if;
MyImg := new Image (ymin - marge..ymax + marge,
xmin - marge..xmax + marge);
traceLine (x0,y0,x1,y1, MyPix, MyImg);
when '2' =>
moveCursor (Up, 1); clearBelow;
Put ("Tracé de cercle", White, Black); new_line;
Put_line ("1. Bresenham");
Put_line ("2. Andrès");
sGet (choix, "12");
moveCursor (Up, 2); clearBelow;
if choix = '1' then
Put ("Tracé de cercle de Bresenham", White, Black); new_line;
else
Put ("Tracé de cercle d'Andrès", White, Black); new_line;
end if;
Put_line ("Rayon : ");
Put_line ("Marge : ");
Put_line ("R : ");
Put_line ("v : ");
Put_line ("B : ");
Put ("Nom : ");
moveCursor (Up, 5); sGet (H);
moveCursor (right, 8); sGet (marge, 0);
moveCursor (right, 8); sGet (R, 0, 255);
moveCursor (right, 8); sGet (V, 0, 255);
moveCursor (right, 8); sGet (B, 0, 255);
moveCursor (right, 8); Nom := to_unbounded_string(get_line);
MyPix := (float(R)/255.0,float(V)/255.0,float(B)/255.0);
L := H;
H := H + marge;
MyImg := new Image (-H..H,
-H..H);
if choix = '1' then
BresenhamCircle (
0, 0, L,
MyPix,
TRUE,
MyImg);
else
AndresCircle (
0, 0, L,
MyPix,
TRUE,
MyImg);
end if;
when others => null;
end case;
Save (MyImg, to_string(nom)&".ppm");
end Rita;