let render_world (EditorState (m, { board; pos = px, py; size })) =
let module M = (val m) in
- let w = (Graphics.size_x () / size) + 1
- and h = (Graphics.size_y () / size) + 1 in
+ let sx = Graphics.size_x ()
+ and sy = Graphics.size_y () in
+ let w = (sx / size) + 1
+ and h = (sy / size) + 1 in
let wx = px - (w / 2)
and wy = py - (h / 2) in
for x = wx to wx + w do
let r, g, b = M.color (Automata.get x y board) in
let r, g, b = (int_of_char r, int_of_char g, int_of_char b) in
Graphics.set_color (Graphics.rgb r g b);
- Graphics.fill_rect ((x - wx) * size) ((y - wy) * size) size size;
- Graphics.set_color (Graphics.rgb 127 127 127);
- Graphics.draw_rect ((x - wx) * size) ((y - wy) * size) size size
+ Graphics.fill_rect ((x - wx) * size) ((y - wy) * size) size size
done
done;
Graphics.set_color (Graphics.rgb 127 127 127);
+ for x = 0 to w do
+ Graphics.moveto (x * size) 0;
+ Graphics.lineto (x * size) sy
+ done;
+ for y = 0 to h do
+ Graphics.moveto 0 (y * size);
+ Graphics.lineto sx (y * size)
+ done;
Graphics.draw_rect (((px - wx) * size) + 1) (((py - wy) * size) + 1) (size - 2) (size - 2)
module rec Command : (Mode with type initer = string) = struct