List Info

Thread: "ocaml_beginners"::[] graphics on OSX ocaml - GUI?




"ocaml_beginners"::[] graphics on OSX ocaml - GUI?
country flaguser name
United States
2007-04-08 04:00:41

Hello,

I just installed ocalm 3.09 from its compiled version onto an intel-based mac (OSX 10.4.9).

ocaml runs without trouble in the terminal window, and I even found a reasonable GUI for
mac at <http://www.cs.unm.edu/~wneumann/cococaml> (seems not updated for a couple
of years though).

I run into problems with graphics output. Being a terrible beginner I cannot even understand
whether my compiled version lacks the graphics libraries (how can I check?), and/or if I need
something better than the basic OSX terminal to see something :-(

Any advice on how to get a graphics-enabled solution on OSX would be most welcome!

TIA,
Hervé Sainct

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] graphics on OSX ocaml - GUI?
country flaguser name
United Kingdom
2007-04-08 10:06:14

On Sun, Apr 08, 2007 at 09:00:41AM -0000, herve_5 wrote:
&gt; I run into problems with graphics output. Being a terrible beginner
> I cannot even understand whether my compiled version lacks the
> graphics libraries (how can I check?), and/or if I need something
> better than the basic OSX terminal to see something :-(
>
> Any advice on how to get a graphics-enabled solution on OSX would be
> most welcome!

I guess the question is - which graphics module?

The very primitive Graphics module is a basic part of OCaml and
probably works on Mac OS X. You should see if the example from here
works or you:
http://www.ocaml-tutorial.org/the_structure_of_ocaml_programs

You might need to install X11.app (from Mac OS X install disk 1) for
the above to work.

As for widget libraries -- probably more useful for you -- there are a
variety of options, none of which seem to be very well developed. For
example, alpha-quality Cocoa bindings:
http://labo.epimac.org/article.php3?id_article=7 and it may be
possible to get Gtk and lablgtk2 working, but you'll probably end up
compiling everything yourself.

Rich.

--
Richard Jones
Red Hat

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] graphics on OSX ocaml - GUI?
country flaguser name
United States
2007-04-08 15:49:45

On Apr 8, 2007, at 9:06 AM, Richard Jones wrote:

> You might need to install X11.app (from Mac OS X install disk 1) for
> the above to work.

Yes. To use the Graphics module, you need to install and run X11.app
(though I remember a project that somehow used native graphics,
though I can't find it with a half-assed google search). Then start
your toplevel from the X11 temminal (if you're using cococaml, you
can launch it with "open /Applications/CocOCaml.app&quot;).

Then just enter
#load "graphics.cma&quot;;;
open Graphics;;

into the toplevel, and you're good to go.

open_graph " 600x600&quot;;;
set_color yellow;;
fill_circle 300 300 200;;
set_color black;;
fill_ellipse 225 375 35 50;;
fill_ellipse 375 375 35 50;;
set_line_width 5;;
draw_arc 300 300 100 100 225 315;;
draw_circle 300 300 200;;

let draw_face x y r =
set_color yellow;
fill_circle x y r;
set_color black;
let offset = 3 * r / 8 in
fill_ellipse (x - offset) (y + offset) (r / 5) (r / 4);
fill_ellipse (x + offset) (y + offset) (r / 5) (r / 4);
set_line_width (max 1 (r/40));
draw_arc x y (r / 2) (r/2) 225 315;
draw_circle x y r;;

draw_face 500 500 25;;

William D. Neumann

"I eat T-bone steaks, I lift barbell plates, I'm sweeter than a
German chocolate cake. I'm the reflection of perfection, the number
one selection. I'm the man of the hour, the man with the power, too
sweet to be sour. The ladies' pet, the men's regret, where what you
see is what you get, and what you don't see, is better yet."

--Superstar Billy Graham

__._,_.___
.

__,_._,___
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )