From e45b6c41d13d20a203e4130f6be7d5ec798f5eba Mon Sep 17 00:00:00 2001
From: =?utf8?q?Am=C3=A9lia=20Coutard-Sander?= <git@ameliathe1st.gay>
Date: Sun, 12 Jan 2025 18:45:51 +0100
Subject: [PATCH] Dessin bien plus efficace des lignes entre les cases

---
 bin/modes.ml | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/bin/modes.ml b/bin/modes.ml
index c752918..974df92 100644
--- a/bin/modes.ml
+++ b/bin/modes.ml
@@ -49,8 +49,10 @@ let get_name (m : (module Automata.Automaton)) =
 
 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
@@ -58,12 +60,18 @@ let render_world (EditorState (m, { board; pos = px, py; size })) =
             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
-- 
2.46.0