This commit is contained in:
John Whitington 2023-06-07 16:35:26 +01:00
parent 77e6dcdda3
commit 65e7bbf68f
2 changed files with 9 additions and 9 deletions

View File

@ -3,7 +3,7 @@ open Pdfutil
let colours =
map
(fun (a, b) -> (b, a))
(fun (a, b) -> (String.lowercase_ascii b, a))
[(0xF0F8FF, "AliceBlue");
(0xFAEBD7, "AntiqueWhite");
(0x00FFFF, "Aqua");

View File

@ -1140,13 +1140,13 @@ let setaddtext s =
setop (AddText s) ()
let parse_color s =
match String.lowercase_ascii s with
| "white" -> Cpdfaddtext.RGB (1., 1., 1.)
| "black" -> Cpdfaddtext.RGB (0., 0., 0.)
| "red" -> Cpdfaddtext.RGB (1., 0., 0.)
| "green" -> Cpdfaddtext.RGB (0., 1., 0.)
| "blue" -> Cpdfaddtext.RGB (0., 0., 1.)
| _ ->
match lookup (String.lowercase_ascii s) Cpdfcolours.colours with
| Some c ->
let r = float_of_int ((c land 0xFF0000) lsr 16) /. 255. in
let g = float_of_int ((c land 0x00FF00) lsr 8) /. 255. in
let b = float_of_int (c land 0x0000FF) /. 255. in
Cpdfaddtext.RGB (r, g, b)
| None ->
let getnum = function
| Pdfgenlex.LexInt i -> float i
| Pdfgenlex.LexReal f -> f