(*  Copyright (C) 1997-2006  the PHP Documentation Group
  This exemple was converted from a PHP exemple found at:
  http://php.net/manual/en/swfshape.setline.php
  which is available under  Open Publication License  *)

open SWF
open OO

let () =
  let s = new swfShape() in
  let f1 = s#add_fill ~r:0xff ~g:0    ~b:0    ~a:0x7f in
  let f2 = s#add_fill ~r:0xff ~g:0x7f ~b:0    ~a:0x7f in
  let f3 = s#add_fill ~r:0xff ~g:0xff ~b:0    ~a:0x7f in
  let f4 = s#add_fill ~r:0    ~g:0xff ~b:0    ~a:0x7f in
  let f5 = s#add_fill ~r:0    ~g:0    ~b:0xff ~a:0x7f in

  (* ming-fonts-1.00.tar.gz  from  http://ming.sourceforge.net/ *)
  let filename = "./ming-fonts-1.00/fdb/Bitstream Vera Serif.fdb" in
  let font = new swfFont ~filename in

  let put_glyph ~c ~fill ~r ~g ~b =
    s#set_right_fill ~fill;
    s#set_line ~width:40  ~r ~g ~b ~a:148;
    s#draw_glyph ~font  ~c;
    let str = Printf.sprintf "%c" c in
    s#move_pen ~x:(font#get_width str)  ~y:0.0;
  in

  put_glyph ~c:'!' ~fill:f1 ~r:0x7f ~g:0    ~b:0;
  put_glyph ~c:'#' ~fill:f2 ~r:0x7f ~g:0x3f ~b:0;
  put_glyph ~c:'%' ~fill:f3 ~r:0x7f ~g:0x7f ~b:0;
  put_glyph ~c:'*' ~fill:f4 ~r:0x7f ~g:0    ~b:0x7f;
  put_glyph ~c:'@' ~fill:f5 ~r:0    ~g:0x7f ~b:0x7f;

  let m = new swfMovie in
  m#set_dimension ~x:3000.0 ~y:2000.0;
  m#set_rate ~rate:12.0;
  let i = m#add ~block:(SWFShape s) in
  i#move_to ~x:(1500.0 -. (font#get_width "!#%*@") /. 2.0)
            ~y:(1000.0 +. (font#get_ascent()) /. 2.0);

  let size = m#save ~filename:"set_line.ml.swf" in
  ignore(size);