Source

clutter-ocaml / examples / actor2.ml

open Clutter
open Printf
module Group = ClutterGroup
  
let display_actor_props a =
  Printf.printf "props: depth=%d has_clip=%b\n%!"
    (Gobject.get ClutterProps.Actor.P.depth a)
    (Gobject.get ClutterProps.Actor.P.has_clip a)

let display_texture_props t =
  printf "props: disable-slicing=%b keep-aspect-ratio=%b pixel-format=%d repeat-x=%b repeat-y=%b sync-size=%b tile-waste=%d\n%!" t#disable_slicing t#keep_aspect_ratio t#pixel_format t#repeat_x t#repeat_y t#sync_size t#tile_waste

let test () =
  let module P = ClutterProps.Rectangle.P in
  let r = ClutterProps.Rectangle.create [] in
  let get p = Gobject.get p r in
  Printf.printf "props: has_border=%b\n%!"
    (get P.has_border)
    
let _ =
  let stage = ClutterStage.get_default () in

  let group = Group.create ()
  and group2 = Group.create () in
  let _ = group#connect#add (fun _ _ -> Printf.printf "added\n%!") in
  let actor1 = ClutterTexture.create
    ~filename:"./examples/ohpowers.png" ~x:0 ~y:0 ()
  and actor2 = ClutterTexture.create
    ~filename:"./examples/ohpowers.png" ~x:200 ~y:0 () in
  let actor3 = ClutterTexture.create
    ~filename:"./examples/ohpowers.png" ~x:0 ~y:0 ()
  and actor4 = ClutterTexture.create
    ~filename:"./examples/ohpowers.png" ~x:200 ~y:0 () in
  
  group#add_many [|actor1#as_actor; actor2#as_actor|];
  group2#add_many [|actor3#as_actor; actor4#as_actor|];
  
  display_actor_props actor1#as_actor;
  display_actor_props actor2#as_actor;
  display_texture_props actor1;
  test ();

  stage#add_actor group;
  stage#add_actor group2;
  
  group#set_position ~x:100 ~y:100;
  group#set_rotation `X_AXIS ~angle:80. ~x:(group#width / 2)
    ~y:(group#width / 2) ~z:(-0);
  group2#set_position ~x:100 ~y:200;
  group2#set_rotation `X_AXIS ~angle:80. ~x:(group#width / 2)
    ~y:(group#width / 2) ~z:0;
  group#show_all;
  group2#show_all;
  stage#show_all;

  clutter_main ()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.