-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplayer-graphics2d-buffered.adb
87 lines (78 loc) · 2.35 KB
/
player-graphics2d-buffered.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
package body Player.Graphics2d.Buffered is
procedure Clear (This : in out Object) is
begin
This.Pending.Append (Action'(Clear, 0));
end Clear;
procedure Set_Color (This : in out Object;
Color : in Types.Player_Color_Type)
is
begin
This.Pending.Append (Action'(Set_Color, 0, Color));
end Set_Color;
procedure Draw_Polyline (This : in out Object;
Points : in Types.Point_2d_Array)
is
begin
This.Pending.Append
(Action'
(Polyline_Array,
Points'Length,
Points));
end Draw_Polyline;
procedure Draw_Polyline (This : in out Object;
Points : in Types.Point_2d_Vector) is
begin
This.Pending.Append
(Action'
(Polyline_Vector,
Natural (Points.Length),
Points));
end Draw_Polyline;
procedure Fill_Polygon (This : in out Object;
Points : in Types.Point_2d_Array) is
begin
This.Pending.Append
(Action'
(Fill_Array,
Natural (Points'Length),
Points));
end Fill_Polygon;
procedure Fill_Polygon (This : in out Object;
Points : in Types.Point_2d_Vector) is
begin
This.Pending.Append
(Action'
(Fill_Vector,
Natural (Points.Length),
Points));
end Fill_Polygon;
procedure Flush (This : in out Object) is
use Action_Lists;
I : Cursor := Action_Lists.First (This.Pending);
begin
while Has_Element (I) loop
Perform (Graphics2d.Object (This), Element (I));
Next (I);
end loop;
This.Pending.Clear;
end Flush;
procedure Perform (This : in out Graphics2d.Object;
Act : Action)
is
begin
case Act.Kind is
when Clear =>
This.Clear;
when Set_Color =>
This.Set_Color (Act.Color);
when Polyline_Array =>
This.Draw_Polyline (Act.Point_Array);
when Polyline_Vector =>
This.Draw_Polyline (Act.Point_Vector);
when Fill_Array =>
This.Fill_Polygon (Act.Fill_Arr);
when Fill_Vector =>
This.Fill_Polygon (Act.Fill_Vec);
end case;
end Perform;
end Player.Graphics2d.Buffered;