(* {{{ COPYING *)
(*
 * +-----------------------------------------------------------------+
 * | Copyright (C) 2006 Florent Monnier                              |
 * +-----------------------------------------------------------------+
 * | This script is a small ImageMagick demo made through Grinnm.    |
 * +-----------------------------------------------------------------+
 * |                                                                 |
 * | This program is free software; you can redistribute it and/or   |
 * | modify it under the terms of the GNU General Public License     |
 * | as published by the Free Software Foundation; either version 2  |
 * | of the License, or (at your option) any later version.          |
 * |                                                                 |
 * | This program is distributed in the hope that it will be useful, |
 * | but WITHOUT ANY WARRANTY; without even the implied warranty of  |
 * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   |
 * | GNU General Public License for more details.                    |
 * |                                                                 |
 * | http://www.fsf.org/licensing/licenses/gpl.html                  |
 * |                                                                 |
 * | You should have received a copy of the GNU General Public       |
 * | License along with this program; if not,                        |
 * | write to the Free Software Foundation, Inc.,                    |
 * | 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA    |
 * |                                                                 |
 * +-----------------------------------------------------------------+
 * | Author: Florent Monnier <monnier.florent(_)gmail.com>           |
 * +-----------------------------------------------------------------+
 *
 * }}} *)

(* {{{ main *)

open Grinnm ;;

let _ =
  let width  = 760
  and height = 570
  and border = 14
  and frames = 66
  in
  let width, height = width + 2*border, height + 2*border
  in
  let plasma_background =
    Magick.create_image ~width ~height ~pseudo_format:"plasma:fractal"
  and hexagons_pattern_foreground =
    Magick.create_image ~width ~height ~pseudo_format:"pattern:hexagons"
  in
  let layers =
    (crop ~x:border ~y:border ~width:(width - 2*border) ~height:(height - 2*border)
      (composite ~compose:Magick.HardLight
       ~img_above:
        (shade ~azimuth:30. ~elevation:30.
          (blur ~radius:3. ~sigma:5.
            (swirl_ft ~degrees:(f_param_evolve ~param:(`max 120.) ~cycle_type:`COS_010 ())
              (extern hexagons_pattern_foreground)
            )
          )
        )
       ~img_below:
        (swirl_ft ~degrees:(f_param_evolve ~param:(`max(-180.)) ~cycle_type:`COS_101 ())
          (emboss ~radius:4. ~sigma:2.
            (blur ~radius:8. ~sigma:12.
              (extern plasma_background)
            )
          )
        )
      )
    )
  in
  ignore(render_layers ~frames ~animate:true ~delay:8 ~layers ~save:(Some(`where "/tmp")) ());
;;

(* }}} *)

(* vim: sw=2 sts=2 ts=2 et fdm=marker
 *)