1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
(*
* (C) arty 2002
* This software is covered under the GNU lesser general public license
*)
open Pycaml ;;
let colorsys = pyimport_importmodule "colorsys"
let dict = pymodule_getdict colorsys
let triplet = pytuple3 (pyfloat_fromdouble 1.0,
pyfloat_fromdouble 0.5,
pyfloat_fromdouble 0.2) ;;
let rgbtoyiq = pydict_getitemstring (dict,"rgb_to_yiq")
let triplet = pyeval_callobject (rgbtoyiq,triplet)
let _ = print_endline ((string_of_float
(pyfloat_asdouble (pytuple_getitem (triplet,0)))) ^
" " ^
(string_of_float
(pyfloat_asdouble (pytuple_getitem (triplet,1)))) ^
" " ^
(string_of_float
(pyfloat_asdouble (pytuple_getitem (triplet,2))))) ;;
let x = pywrap_closure
(fun x -> print_string (pystring_asstring (pytuple_getitem (x,0))) ;
pynone ())
let _ = pyeval_callobject
(x,pytuple_fromsingle (pystring_fromstring "hi there"))
|