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
|
implement Graph;
include "common.m";
sys : Sys;
drawm : Draw;
dat : Dat;
gui : Gui;
utils : Utils;
Image, Point, Rect, Font, Display : import drawm;
black, white, display : import gui;
error : import utils;
refp : ref Point;
pixarr : array of byte;
init(mods : ref Dat->Mods)
{
sys = mods.sys;
drawm = mods.draw;
dat = mods.dat;
gui = mods.gui;
utils = mods.utils;
refp = ref Point;
refp.x = refp.y = 0;
}
charwidth(f : ref Font, c : int) : int
{
s : string = "z";
s[0] = c;
return f.width(s);
}
strwidth(f : ref Font, s : string) : int
{
return f.width(s);
}
balloc(r : Rect, c : Draw->Chans, col : int) : ref Image
{
im := display.newimage(r, c, 0, col);
if (im == nil)
error("failed to get new image");
return im;
}
draw(d : ref Image, r : Rect, s : ref Image, m : ref Image, p : Point)
{
d.draw(r, s, m, p);
}
stringx(d : ref Image, p : Point, f : ref Font, s : string, c : ref Image)
{
d.text(p, c, (0, 0), f, s);
}
cursorset(p : Point)
{
gui->cursorset(p);
}
cursorswitch(c : ref Dat->Cursor)
{
gui->cursorswitch(c);
}
binit()
{
}
bflush()
{
}
berror(s : string)
{
error(s);
}
|