From ae2e8d904f00ff58d3d4e99ad96e4aaee722ae04 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Fri, 12 May 2023 19:01:59 +0100 Subject: [PATCH] more --- cpdfcommand.ml | 14 ++++++++++++++ cpdfdraw.ml | 7 ++++++- cpdfdraw.mli | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/cpdfcommand.ml b/cpdfcommand.ml index e818c34..49974f8 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -1829,6 +1829,18 @@ let addbezier s = | _ -> error "-bez requires six numbers" | exception _ -> error "malformed -bez" +let addbezier23 s = + match readfloats s with + | [a; b; c; d] -> addop (Cpdfdraw.Bezier23 (a, b, c, d)) + | _ -> error "-bez23 requires four numbers" + | exception _ -> error "malformed -bez23" + +let addbezier13 s = + match readfloats s with + | [a; b; c; d] -> addop (Cpdfdraw.Bezier13 (a, b, c, d)) + | _ -> error "-bez13 requires four numbers" + | exception _ -> error "malformed -bez13" + let addcircle s = match readfloats s with | [x; y; r] -> @@ -2867,6 +2879,8 @@ and specs = ("-to", Arg.String addto, " Move to"); ("-line", Arg.String addline, " Add line to"); ("-bez", Arg.String addbezier, " Add Bezier curve to path"); + ("-bez23", Arg.String addbezier23, " Add Bezier v-op to path"); + ("-bez13", Arg.String addbezier13, " Add Bezier y-op to path"); ("-circle", Arg.String addcircle, " Add circle to path"); ("-strokecol", Arg.String setstroke, " Set stroke colour"); ("-fillcol", Arg.String setfill, " Set fill colour"); diff --git a/cpdfdraw.ml b/cpdfdraw.ml index 809fa66..9f91146 100644 --- a/cpdfdraw.ml +++ b/cpdfdraw.ml @@ -10,6 +10,8 @@ type colspec = type drawops = | Rect of float * float * float * float | Bezier of float * float * float * float * float * float + | Bezier23 of float * float * float * float + | Bezier13 of float * float * float * float | To of float * float | Line of float * float | ClosePath @@ -52,7 +54,8 @@ let rec string_of_drawop = function | Qq o -> "Qq (" ^ string_of_drawops o ^ ")" | FormXObject (_, _, _, _, _, o) -> "FormXObject (" ^ string_of_drawops o ^ ")" | TextSection o -> "TextSection (" ^ string_of_drawops o ^ ")" - | Rect _ -> "Rect" | Bezier _ -> "Bezier" | To _ -> "To" | Line _ -> "Line" + | Rect _ -> "Rect" | Bezier _ -> "Bezier" | Bezier23 _ -> "Bezier23" + | Bezier13 _ -> "Bezier13" | To _ -> "To" | Line _ -> "Line" | ClosePath -> "ClosePath" | SetFill _ -> "SetFill" | SetStroke _ -> "SetStroke" | SetLineThickness _ -> "SetLineThickness" | SetLineCap _ -> "SetLineCap" | SetLineJoin _ -> "SetLineJoin" | SetMiterLimit _ -> "SetMiterLimit" @@ -170,6 +173,8 @@ let rec ops_of_drawop pdf endpage filename bates batespad num page = function | Matrix m -> [Pdfops.Op_cm m] | Rect (x, y, w, h) -> [Pdfops.Op_re (x, y, w, h)] | Bezier (a, b, c, d, e, f) -> [Pdfops.Op_c (a, b, c, d, e, f)] + | Bezier23 (a, b, c, d) -> [Pdfops.Op_v (a, b, c, d)] + | Bezier13 (a, b, c, d) -> [Pdfops.Op_y (a, b, c, d)] | To (x, y) -> [Pdfops.Op_m (x, y)] | Line (x, y) -> [Pdfops.Op_l (x, y)] | SetFill x -> diff --git a/cpdfdraw.mli b/cpdfdraw.mli index 3b9194a..409421c 100644 --- a/cpdfdraw.mli +++ b/cpdfdraw.mli @@ -7,6 +7,8 @@ type colspec = type drawops = | Rect of float * float * float * float | Bezier of float * float * float * float * float * float + | Bezier23 of float * float * float * float + | Bezier13 of float * float * float * float | To of float * float | Line of float * float | ClosePath