diff options
Diffstat (limited to 'appl/acme/graph.b')
| -rw-r--r-- | appl/acme/graph.b | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/appl/acme/graph.b b/appl/acme/graph.b new file mode 100644 index 00000000..9b8eb738 --- /dev/null +++ b/appl/acme/graph.b @@ -0,0 +1,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); +} |
