File: rgb.ml

package info (click to toggle)
lambda-term 3.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,108 kB
  • sloc: ml: 14,981; ansic: 522; makefile: 32
file content (28 lines) | stat: -rw-r--r-- 705 bytes parent folder | download | duplicates (6)
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
(*
 * rgb.ml
 * ------
 * Copyright : (c) 2011, Jeremie Dimino <jeremie@dimino.org>
 * Licence   : BSD3
 *
 * This file is a part of Lambda-Term.
 *)

open Lwt
open LTerm_style
open LTerm_text

let main () =
  if Array.length Sys.argv <> 4 then begin
    LTerm.eprintlf "usage: %s <red> <blue> <green>"
      (Filename.basename Sys.executable_name)
    >>= fun () ->
    exit 2
  end else begin
    let r = int_of_string Sys.argv.(1)
    and g = int_of_string Sys.argv.(2)
    and b = int_of_string Sys.argv.(3) in
    LTerm.printls (eval [S(Printf.sprintf "color with component (%d, %d, %d): " r g b);
                           B_fg(rgb r g b); S"example"; E_fg])
  end

let () = Lwt_main.run (main ())