
❰23:10❱ benjamin@ivr94-5-82-237-225-118:~/taf/paintworms_opt❯./xpm_to_ml bonus
❰23:10❱ benjamin@ivr94-5-82-237-225-118:~/taf/paintworms_opt❯cat bonus.ml
(*
* pixmap Bonus (size 32x32) generated from bonus.xpm
*
*
* code examples:
*
* change white in transparent and draw centered at (42,42):
* Bonus.draw_center_mapped [(Graphics.rgb 255 255 255,-1)] 42 42;;
*
* change white in transparent , black in white and draw centered at (42,42):
* Bonus.draw_center_mapped [(Graphics.rgb 255 255 255 , -1);
* (Graphics.rgb 0 0 0 , Graphics.rgb 255 255 255)] 42 42;;
*
*)
let cols =
[|
Graphics.rgb 0xFF 0xFF 0xFF;
Graphics.rgb 0x00 0x00 0x00;
Graphics.rgb 0xFF 0x00 0xD4;
Graphics.rgb 0x00 0x0D 0xFF;
Graphics.rgb 0xFF 0x0D 0x00;
Graphics.rgb 0x00 0xFF 0x0D;
Graphics.rgb 0xFF 0x99 0x00;
Graphics.rgb 0xFF 0xF2 0x00
|]
;;
let ar =
[|
[|0;0;0;0;0;0;0;0;1;1;1;0;0;0;0;0;0;0;0;0;0;1;1;1;0;0;0;0;0;0;0;0|];
[|0;0;0;0;0;0;1;1;2;2;2;1;0;0;0;0;0;0;0;0;1;3;3;3;1;1;0;0;0;0;0;0|];
[|0;0;0;0;0;1;2;2;2;2;2;2;1;0;0;0;0;0;0;1;3;3;3;3;3;3;1;0;0;0;0;0|];
[|0;0;0;0;1;2;2;2;2;2;2;2;1;0;0;0;0;0;0;1;3;3;3;3;3;3;3;1;0;0;0;0|];
[|0;0;0;0;1;2;2;2;2;2;2;2;1;0;0;0;0;0;0;1;3;3;3;3;3;3;3;1;0;0;0;0|];
[|0;0;0;0;1;2;2;2;2;2;2;2;1;0;0;0;0;0;0;1;3;3;3;3;3;3;3;1;0;0;0;0|];
[|0;0;0;0;0;1;2;2;2;2;2;2;2;1;0;0;0;0;1;3;3;3;3;3;3;3;1;0;0;0;0;0|];
[|0;0;0;0;0;0;1;2;2;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6;6;6;1;0;0;1;7;7;7;7;1;0;0;0;0;0;0;0;0;0|];
[|0;0;0;0;0;0;0;0;1;6;6;6;6;1;0;0;0;0;1;7;7;7;7;1;0;0;0;0;0;0;0;0|];
[|0;0;0;0;0;0;0;1;6;6;6;6;6;1;0;0;0;0;1;7;7;7;7;7;1;0;0;0;0;0;0;0|];
[|0;0;0;0;0;0;1;6;6;6;6;6;6;1;0;0;0;0;1;7;7;7;7;7;7;1;0;0;0;0;0;0|];
[|0;0;0;0;0;1;6;6;6;6;6;6;6;1;0;0;0;0;1;7;7;7;7;7;7;7;1;0;0;0;0;0|];
[|0;0;0;0;1;6;6;6;6;6;6;6;1;0;0;0;0;0;0;1;7;7;7;7;7;7;7;1;0;0;0;0|];
[|0;0;0;0;1;6;6;6;6;6;6;6;1;0;0;0;0;0;0;1;7;7;7;7;7;7;7;1;0;0;0;0|];
[|0;0;0;0;0;1;6;6;6;6;6;6;1;0;0;0;0;0;0;1;7;7;7;7;7;7;1;0;0;0;0;0|];
[|0;0;0;0;0;0;1;1;6;6;6;1;0;0;0;0;0;0;0;0;1;7;7;7;1;1;0;0;0;0;0;0|];
[|0;0;0;0;0;0;0;0;1;1;1;0;0;0;0;0;0;0;0;0;0;1;1;1;0;0;0;0;0;0;0;0|]
|]
;;
let width () = 32 ;;
let height () = 32 ;;
let colormap () = cols ;;
let colormap_mapped l =
Array.map (fun x -> try List.assoc x l with _ -> x) cols ;;
let array () = Array.map (fun x -> (Array.map (fun y -> cols.(y)) x)) ar;;
let array_mapped l =
let map = colormap_mapped l in
Array.map (fun x -> (Array.map (fun y -> map.(y)) x)) ar;;
let image () = Graphics.make_image (array ()) ;;
let image_mapped l = Graphics.make_image (array_mapped l) ;;
let draw x y = Graphics.draw_image (image ()) x y ;;
let draw_center x y = Graphics.draw_image (image ()) (x+16) (y+16) ;;
let draw_mapped l x y = Graphics.draw_image (image_mapped l) x y ;;
let draw_center_mapped l x y =
Graphics.draw_image (image_mapped l) (x+16) (y+16) ;;
❰23:10❱ benjamin@ivr94-5-82-237-225-118:~/taf/paintworms_opt❯