more
This commit is contained in:
parent
e8aa935aa8
commit
88970eacc8
|
@ -1750,6 +1750,8 @@ let whingemalformed () =
|
||||||
type drawops_colspec =
|
type drawops_colspec =
|
||||||
NoCol
|
NoCol
|
||||||
| RGB of float * float * float
|
| RGB of float * float * float
|
||||||
|
| Grey of float
|
||||||
|
| CYMK of float * float * float * float
|
||||||
|
|
||||||
type drawops =
|
type drawops =
|
||||||
| Rect of float * float * float * float (* x, y, w, h *)
|
| Rect of float * float * float * float (* x, y, w, h *)
|
||||||
|
@ -1761,7 +1763,19 @@ type drawops =
|
||||||
|
|
||||||
let drawops = ref []
|
let drawops = ref []
|
||||||
|
|
||||||
(* Add rect to list of drawing commands *)
|
let col_of_string s =
|
||||||
|
match parse_color s with
|
||||||
|
| Cpdfaddtext.RGB (r, g, b) -> RGB (r, g, b)
|
||||||
|
| Cpdfaddtext.Grey g -> Grey g
|
||||||
|
| Cpdfaddtext.CYMK (c, y, m, k) -> CYMK (c, y, m, k)
|
||||||
|
| exception _ -> NoCol
|
||||||
|
|
||||||
|
let setstroke s =
|
||||||
|
drawops := Stroke (col_of_string s)::!drawops
|
||||||
|
|
||||||
|
let setfill s =
|
||||||
|
drawops := Fill (col_of_string s)::!drawops
|
||||||
|
|
||||||
let addrect s =
|
let addrect s =
|
||||||
let x, y, w, h = Cpdfcoord.parse_rectangle (Pdf.empty ()) s in
|
let x, y, w, h = Cpdfcoord.parse_rectangle (Pdf.empty ()) s in
|
||||||
drawops := Rect (x, y, w, h)::!drawops
|
drawops := Rect (x, y, w, h)::!drawops
|
||||||
|
@ -2559,6 +2573,8 @@ and specs =
|
||||||
("-rect", Arg.String addrect, " Draw rectangle");
|
("-rect", Arg.String addrect, " Draw rectangle");
|
||||||
("-to", Arg.String addto, " Move to");
|
("-to", Arg.String addto, " Move to");
|
||||||
("-line", Arg.String addline, " Line to");
|
("-line", Arg.String addline, " Line to");
|
||||||
|
("-stroke", Arg.String setstroke, " Set stroke colour");
|
||||||
|
("-fill", Arg.String setfill, " Set fill colour");
|
||||||
("-end", Arg.Unit endpath, " End path");
|
("-end", Arg.Unit endpath, " End path");
|
||||||
(* These items are undocumented *)
|
(* These items are undocumented *)
|
||||||
("-remove-unused-resources", Arg.Unit (setop RemoveUnusedResources), "");
|
("-remove-unused-resources", Arg.Unit (setop RemoveUnusedResources), "");
|
||||||
|
@ -3125,14 +3141,28 @@ type state =
|
||||||
|
|
||||||
let state =
|
let state =
|
||||||
{fill = NoCol;
|
{fill = NoCol;
|
||||||
stroke = NoCol}
|
stroke = RGB (0., 0., 0.)}
|
||||||
|
|
||||||
let ops_of_drawop = function
|
let ops_of_drawop = function
|
||||||
| Rect (x, y, w, h) -> [Pdfops.Op_re (x, y, w, h)]
|
| Rect (x, y, w, h) -> [Pdfops.Op_re (x, y, w, h)]
|
||||||
| To (x, y) -> [Pdfops.Op_m (x, y)]
|
| To (x, y) -> [Pdfops.Op_m (x, y)]
|
||||||
| Line (x, y) -> [Pdfops.Op_l (x, y)]
|
| Line (x, y) -> [Pdfops.Op_l (x, y)]
|
||||||
| Fill x -> (* FIXME: do col *) state.fill <- x; []
|
| Fill x ->
|
||||||
| Stroke x -> (* FIXME: do col *) state.stroke <- x; []
|
state.fill <- x;
|
||||||
|
begin match x with
|
||||||
|
| RGB (r, g, b) -> [Op_rg (r, g, b)]
|
||||||
|
| Grey g -> [Op_g g]
|
||||||
|
| CYMK (c, y, m, k) -> [Op_k (c, y, m, k)]
|
||||||
|
| NoCol -> []
|
||||||
|
end
|
||||||
|
| Stroke x ->
|
||||||
|
state.stroke <- x;
|
||||||
|
begin match x with
|
||||||
|
| RGB (r, g, b) -> [Op_RG (r, g, b)]
|
||||||
|
| Grey g -> [Op_G g]
|
||||||
|
| CYMK (c, y, m, k) -> [Op_K (c, y, m, k)]
|
||||||
|
| NoCol -> []
|
||||||
|
end
|
||||||
| EndPath ->
|
| EndPath ->
|
||||||
begin match state.fill, state.stroke with
|
begin match state.fill, state.stroke with
|
||||||
| NoCol, NoCol -> []
|
| NoCol, NoCol -> []
|
||||||
|
|
Loading…
Reference in New Issue