Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Add graphic version for caml

  • Loading branch information...
Louis Gasnault
Louis Gasnault committed Oct 14, 2018
1 parent 9972201 commit 6c7b0aa94516432d1e83e74ed15fcc5c4be7fa12
Showing with 15 additions and 0 deletions.
  1. +15 −0 Caml/hello_world_graphics.ml
@@ -0,0 +1,15 @@

(* Implementation of the Hello World! using the graphics library of Caml *)
(* Lozul, Hacktoberfest 2018 *)

(* Load library *)
#load "graphics.cma" ;; (* Load the graphics library *)
open Graphics ;; (* Open the module *)
open_graph "300x300" ;; (* 300w x 300h window *)

let hello = "Hello World!";;
let window_width = size_x () and window_height = size_y ();;
let text_width = match (text_size hello) with (a,b) -> a;;

moveto ((window_width / 2) - (text_width / 2)) (window_height / 2);;
draw_string hello;;

0 comments on commit 6c7b0aa

Please sign in to comment.
You can’t perform that action at this time.