Source

clutter-ocaml / examples / cogl-actor.ml


open Printf
open Clutter

let _ =
  let stage = ClutterStage.get_default () in
  stage#set_size ~width:800 ~height:600;
  let c = CoglBox.create
    (fun _ ->
       let color = Color.rgb (255,0,0) in
       Cogl.color color#obj;
       Cogl.push_matrix ();
       Cogl.Path.round_rectangle ~x:(from_device 5) ~y:(from_device 5)
	 ~width:(from_device 790) ~height:(from_device 590)
	 ~radius:(from_device 10)
	 ~arc_step:(angle_from_deg 0.5);
       Cogl.Path.stroke ();
       
       Cogl.translate 200 200 0;
       
       Cogl.Path.line ~x1:(from_device (-50)) ~y1:(from_device (-25))
	 ~x2:(from_device 250) ~y2:(from_device 125);
       (*Cogl.Path.fill ();*)
       Cogl.Path.stroke ();
       Cogl.pop_matrix ();
    ) in
  let c = new ClutterActor.actor (as_actor c) in
  stage#add_actor c;
  let actor = ClutterTexture.create ~filename:"./examples/ohpowers.png" () in
  stage#add_actor actor;
  actor#set_position ~x:100 ~y:100;
  actor#set_rotation `Z_AXIS ~angle:180. ~x:(actor#width / 2)
    ~y:(actor#height / 2) ~z:0;
  stage#show_all;
  Clutter.main ()