More colors

This commit is contained in:
Alexandre 2024-05-19 12:52:51 +02:00
parent f88a54968e
commit fea1fa9e0a
4 changed files with 9 additions and 5 deletions

BIN
a.out

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -130,15 +130,19 @@ let draw_line_bresenham mat cls origin x1 y1 x2 y2 cutoff =
done;;
let display mat cls =
let colors = [|"\027[30m"; "\027[31m"; "\027[32m"; "\027[33m"; "\027[34m"; "\027[35m"; "\027[36m"; "\027[37m"|] in
let colors = [|"\027[40m"; "\027[41m"; "\027[42m"; "\027[43m"; "\027[44m"; "\027[45m"; "\027[46m"; "\027[47m"; "\027[100m"; "\027[101m"; "\027[102m"; "\027[103m"; "\027[104m"; "\027[105m"; "\027[106m"; "\027[107m"|] in
for i = 0 to (Array.length mat -1) do
for j = 0 to (Array.length mat.(i) -1) do
print_string colors.(cls.(i).(j) mod (Array.length colors));
if cls.(i).(j) = 0 then
print_string colors.(0)
else
print_string colors.(max 1 (cls.(i).(j) mod (Array.length colors)));
if mat.(i).(j) = '&' then
print_char ' '
else
print_char mat.(i).(j)
done;
print_string "\027[0m";
print_char '\n'
done;;
@ -186,14 +190,14 @@ let extremely_fancy_graph_printing g size =
if !i >= size then i := size-1 else ();
if !j >= size then j := size-1 else ();
px.(!i).(3* !j) <- Char.chr (k + 48);
extend px cls !i (3* !j) 3;
extend px cls !i (3* !j) 2;
coords.(k) <- (!i, 3* !j);
done;
(* draw the connections *)
for i = 0 to Array.length g -1 do
for j = 0 to Array.length g.(i) -1 do
draw_line_bresenham px cls i (fst coords.(i)) (snd coords.(i)) (fst coords.(g.(i).(j))) (snd coords.(g.(i).(j))) 7
draw_line_bresenham px cls i (fst coords.(i)) (snd coords.(i)) (fst coords.(g.(i).(j))) (snd coords.(g.(i).(j))) 4
done
done;
@ -201,7 +205,7 @@ let extremely_fancy_graph_printing g size =
display px cls ;;
let gr = [|[|1; 2|]; [|2; 3|]; [|0; 1; 3|]; [|0; 1|]|] ;;
let gr = [|[|1; 2|]; [|2; 3|]; [|0; 1; 3|]; [|0; 1; 4|]; [|2; 3|]; [||]; [||]|] ;;
(*print_mat gr ;;*)