-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgraphwin.pas
More file actions
153 lines (132 loc) · 2.6 KB
/
graphwin.pas
File metadata and controls
153 lines (132 loc) · 2.6 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
unit GraphWin;
interface
procedure SetBrushStyle(style:integer);
procedure DrawOblong(x1,y1,x2,y2:integer);
procedure EraseOblong(x1,y1,x2,y2:integer);
procedure SetPenColour(r,g,b:byte);
procedure SetBrushColour(r,g,b:byte);
procedure DrawText(x,y:integer; s:string);
procedure EraseText(x,y:integer; s:string);
procedure ReDisplay;
procedure WriteMoo(msg:string);
procedure Sleep(time:real);
procedure InitGraphWin;
function KeyPressed: boolean;
function ReadKey: Char;
implementation
var BrushStyle:integer;
BrushR, BrushG, BrushB: byte;
PenR, PenG, PenB: byte;
procedure InitGraphWin;
begin
WriteLn('{"action":"init"}');
end;
procedure SetBrushStyle(style:integer);
begin
BrushStyle := style;
end;
procedure DrawOblong(x1,y1,x2,y2:integer);
begin
WriteLn('{"action":"drawoblong",',
'"x1":',x1,',',
'"y1":',y1,',',
'"x2":',x2,',',
'"y2":',y2,',',
'"style":',BrushStyle,',',
'"penr":',PenR,',',
'"peng":',PenG,',',
'"penb":',PenB,',',
'"brushr":',BrushR,',',
'"brushg":',BrushG,',',
'"brushb":',BrushB,'}'
);
end;
procedure EraseOblong(x1,y1,x2,y2:integer);
begin
WriteLn('{"action":"eraseoblong",',
'"x1":',x1,',',
'"y1":',y1,',',
'"x2":',x2,',',
'"y2":',y2,',',
'"style":',BrushStyle,',',
'"penr":',PenR,',',
'"peng":',PenG,',',
'"penb":',PenB,',',
'"brushr":',BrushR,',',
'"brushg":',BrushG,',',
'"brushb":',BrushB,'}'
);
end;
procedure SetPenColour(r,g,b:byte);
begin
PenR := r;
PenG := g;
PenB := b;
end;
procedure SetBrushColour(r,g,b:byte);
begin
BrushR := r;
BrushG := g;
BrushB := b;
end;
procedure DrawText(x,y:integer; s:string);
begin
WriteLn('{"action":"drawtext",',
'"x":',x,',',
'"y":',y,',',
'"penr":',PenR,',',
'"peng":',PenG,',',
'"penb":',PenB,',',
'"string":"',s,'"}'
);
end;
procedure EraseText(x,y:integer; s:string);
begin
WriteLn('{"action":"erasetext",',
'"x":',x,',',
'"y":',y,',',
'"penr":',PenR,',',
'"peng":',PenG,',',
'"penb":',PenB,',',
'"string":"',s,'"}'
);
end;
procedure ReDisplay;
begin
end;
function KeyPressed: boolean;
var out:integer;
begin
WriteLn('{"action":"keypressed"}');
Flush(output);
ReadLn(out);
KeyPressed := out <> 0;
end;
function ReadKey: Char;
var out:Char;
begin
WriteLn('{"action":"readkey"}');
Flush(output);
ReadLn(out);
ReadKey := out;
end;
procedure WriteMoo(msg:string);
begin
WriteLn('{"action":"writeln","string":"', msg, '"}');
end;
procedure Sleep(time:real);
var out:Char;
begin
WriteLn('{"action":"sleep","duration":', time, '}');
Flush(output);
ReadLn(out);
end;
begin
BrushStyle := 0;
PenR := 0;
PenG := 0;
PenB := 0;
BrushR := 0;
BrushG := 0;
BrushB := 0;
end.