[go: up one dir, main page]

File: addons.ml

package info (click to toggle)
advi 1.10.2-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 15,008 kB
  • sloc: ml: 12,279; sh: 1,032; ansic: 1,016; makefile: 705; perl: 55
file content (105 lines) | stat: -rw-r--r-- 3,936 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
(***********************************************************************)
(*                                                                     *)
(*                             Active-DVI                              *)
(*                                                                     *)
(*                   Projet Cristal, INRIA Rocquencourt                *)
(*                                                                     *)
(*  Copyright 2003 Institut National de Recherche en Informatique et   *)
(*  en Automatique.  All rights reserved.  This file is distributed    *)
(*  under the terms of the GNU Lesser General Public License.          *)
(*                                                                     *)
(*  Jun Furuse, Didier Rmy and Pierre Weis.                           *)
(*  Contributions by Roberto Di Cosmo, Didier Le Botlan,               *)
(*  Xavier Leroy, and Alan Schmitt.                                    *)
(*                                                                     *)
(*  Based on Mldvi by Alexandre Miquel.                                *)
(***********************************************************************)

(*  Predefined gradient color background drawing functions.
    Roberto Di Cosmo, Pierre Weis.                                     *)

(* $Id: addons.ml,v 1.1 2007/01/18 14:14:35 rousse Exp $ *)

(* Gradients:
   - h is horizontal,
   - v is vertical,
   - d1 is parallel to the first bissector (d stands for diagonal),
   - d2 is parallel to the second bissector,
   - c is centered (enlarging squares with a common center),
   - circ is circular (also centered using enlarging circles) *)

open Graphics;;
open Gradient;;
open Grdev;;

let start_color color = function
  | None -> Graphics.white
  | Some c -> c;;

let stop_color color = function
  | None -> color
  | Some c -> c;;

let hgradient {
    argcolor = c0; argcolorstart = c1; argcolorstop = c2;
    argfunviewport = {vx = x; vy = y; vw = w; vh = h};
    argxcenter = xc; argycenter = yc;
    argviewport = _;
   } =
  let c1 = start_color c0 c1
  and c2 = stop_color c0 c2 in
  Gradient.grad_rect (Rect_Horizontal (c1, c2)) x y w h;;

let vgradient {
    argcolor = c0; argcolorstart = c1; argcolorstop = c2;
    argfunviewport = {vx = x; vy = y; vw = w; vh = h};
    argxcenter = xc; argycenter = yc;
    argviewport = _;
   } =
  let c1 = start_color c0 c1
  and c2 = stop_color c0 c2 in
  Gradient.grad_rect (Rect_Vertical (c1, c2)) x y w h;;

let d1gradient {
    argcolor = c0; argcolorstart = c1; argcolorstop = c2;
    argfunviewport = {vx = x; vy = y; vw = w; vh = h};
    argxcenter = xc; argycenter = yc;
    argviewport = _;
   } =
  let c1 = start_color c0 c1
  and c2 = stop_color c0 c2 in
  Gradient.grad_rect (Rect_Diagonal1 (c1, c2)) x y w h;;

let d2gradient {
    argcolor = c0; argcolorstart = c1; argcolorstop = c2;
    argfunviewport = {vx = x; vy = y; vw = w; vh = h};
    argxcenter = xc; argycenter = yc;
    argviewport = _;
   } =
  let c1 = start_color c0 c1
  and c2 = stop_color c0 c2 in
  Gradient.grad_rect (Rect_Diagonal2 (c1, c2)) x y w h;;

(* For compatibility (already compatibility, when this feature is not
   yet available to any distribution :) *)
let dgradient = d1gradient;;

let cgradient {
    argcolor = c0; argcolorstart = c1; argcolorstop = c2;
    argfunviewport = {vx = x; vy = y; vw = w; vh = h} as _viewport;
    argxcenter = xc; argycenter = yc;
    argviewport = _;
   } =
  let c1 = start_color c0 c1
  and c2 = stop_color c0 c2 in
  Gradient.grad_rect (Rect_Centered (c1, c2, xc, yc)) x y w h;;

let circgradient {
    argcolor = c0; argcolorstart = c1; argcolorstop = c2;
    argfunviewport = {vx = x; vy = y; vw = w; vh = h} as _viewport;
    argxcenter = xc; argycenter = yc;
    argviewport = _;
   } =
  let c1 = start_color c0 c1
  and c2 = stop_color c0 c2 in
  Gradient.grad_rect (Rect_Circular (c1, c2, xc, yc)) x y w h;;