File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -484,6 +484,31 @@ let paint ?separated_by:_ ?default:_ loc name s =
484484 `Icc ([% e iri], Some [% e paint_without_icc loc name remainder])]
485485 end [@ metaloc loc]
486486
487+ let fill_opacity =
488+ let bad_form name loc =
489+ Common. error loc " Value of %s must be a number or percentage" name in
490+
491+ let regexp = Re_str. regexp " \\ ([-+0-9eE.]+\\ )\\ (%\\ )?" in
492+
493+ fun ?separated_by :_ ?default :_ loc name s ->
494+ if not @@ does_match regexp s then bad_form name loc;
495+
496+ begin
497+ let n =
498+ match float_exp loc (Re_str. matched_group 1 s) with
499+ | Some n -> n
500+ | None -> bad_form name loc
501+ in
502+
503+ let v =
504+ if group_matched 2 s then [% expr [% e n] /. 100. ]
505+ else [% expr [% e n]] in
506+
507+ if v > = 0. && v < = 1. then Some v
508+ else
509+ Common. error loc " Value of %s must be between 0 and 1." name in
510+ end [@ metaloc loc]
511+
487512let fill_rule ?separated_by :_ ?default:_ loc _name s =
488513 begin match s with
489514 | "nonzero" ->
Original file line number Diff line number Diff line change @@ -198,6 +198,12 @@ val paint : parser
198198 {:{https://www.w3.org/TR/SVG/painting.html#SpecifyingPaint} Specifying
199199 paint}. *)
200200
201+ val fill_opacity : parser
202+ (* * Parses an SVG fill-opacity value, converting it into a number between 0. and 1.
203+
204+ @see <https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill-opacity>
205+ *)
206+
201207val fill_rule : parser
202208(* * Parses an SVG fill-rule value.
203209
You can’t perform that action at this time.
0 commit comments