Skip to content

Commit

Permalink
Reverting the merging of opacity with offset. Opacity now takes a num…
Browse files Browse the repository at this point in the history
…ber.
  • Loading branch information
Mbodin committed Nov 29, 2023
1 parent 7478b52 commit a496fd1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
15 changes: 10 additions & 5 deletions lib/svg_f.ml
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ struct
let a_fy = user_attrib string_of_coord "fy"

let a_offset x =
user_attrib C.string_of_number_or_percentage "offset" x
user_attrib C.string_of_offset "offset" x

let a_patternUnits x =
user_attrib C.string_of_big_variant "patternUnits" x
Expand Down Expand Up @@ -539,7 +539,7 @@ struct
let a_animation_fill x =
user_attrib C.string_of_big_variant "fill" x

let a_fill_opacity = user_attrib C.string_of_number_or_percentage "fill-opacity"
let a_fill_opacity = user_attrib C.string_of_opacity "fill-opacity"

let a_fill_rule = user_attrib C.string_of_fill_rule "fill-rule"

Expand Down Expand Up @@ -713,9 +713,12 @@ struct
let a_ontouchmove = Xml.touch_event_handler_attrib "ontouchmove"
let a_ontouchcancel = Xml.touch_event_handler_attrib "ontouchcancel"


let a_opacity = user_attrib C.string_of_opacity "opacity"

let a_stop_color = color_attrib "stop-color"

let a_stop_opacity = user_attrib C.string_of_number "stop-opacity"
let a_stop_opacity = user_attrib C.string_of_opacity "stop-opacity"

let a_stroke = user_attrib C.string_of_paint "stroke"

Expand All @@ -737,7 +740,7 @@ struct
user_attrib C.string_of_length "stroke-dashoffset"

let a_stroke_opacity =
user_attrib C.string_of_number "stroke-opacity"
user_attrib C.string_of_opacity "stroke-opacity"

(* xlink namespace given a nickname since some attributes mandated by
the svg standard such as xlink:href live in that namespace, and we
Expand Down Expand Up @@ -1106,7 +1109,7 @@ struct

let string_of_numbers_semicolon = list ~sep:"; " string_of_number

let string_of_number_or_percentage = function
let string_of_offset = function
| `Number x -> string_of_number x
| `Percentage x -> string_of_percentage x

Expand All @@ -1116,6 +1119,8 @@ struct

let string_of_paint = string_of_paint

let string_of_opacity = string_of_number

let string_of_fill_rule = string_of_fill_rule

let string_of_strokedasharray = function
Expand Down
9 changes: 4 additions & 5 deletions lib/svg_sigs.mli
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,7 @@ module type T = sig
val a_animation_fill : [< | `Freeze | `Remove ] wrap -> [> | `Fill_Animation ] attrib
[@@reflect.attribute "fill" ["animate"]]

val a_fill_opacity :
[< `Number of number | `Percentage of percentage ] wrap ->
[> | `Fill_opacity ] attrib
val a_fill_opacity : number wrap -> [> | `Fill_opacity ] attrib

val a_fill_rule : fill_rule wrap -> [> | `Fill_rule ] attrib

Expand Down Expand Up @@ -637,6 +635,8 @@ module type T = sig
| `Text_after_edge | `Text_before_edge | `Inherit ] wrap ->
[> | `Dominant_Baseline ] attrib

val a_opacity : number wrap -> [> | `Opacity ] attrib

val a_stop_color : color wrap -> [> | `Stop_Color ] attrib

val a_stop_opacity : number wrap -> [> | `Stop_Opacity ] attrib
Expand Down Expand Up @@ -1111,8 +1111,7 @@ module type Wrapped_functions = sig

val string_of_numbers_semicolon : (float list, string) Xml.W.ft

val string_of_number_or_percentage :
([< `Number of number | `Percentage of percentage ], string) Xml.W.ft
val string_of_offset : ([< Svg_types.offset], string) Xml.W.ft

val string_of_orient : (Svg_types.Unit.angle option, string) Xml.W.ft

Expand Down
2 changes: 1 addition & 1 deletion test/test_ppx.ml
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ let svg = "svg", SvgTests.make Svg.[

"fill_opacity, circle",
[[%svg "<circle cx=50 cy=50 r=50 fill-opacity=0.5 />"]],
[rect ~a:[a_cx (50., None); a_cy (50., None); a_r (50., None); a_fill_opacity (`Number 0.5)] []] ;
[rect ~a:[a_cx (50., None); a_cy (50., None); a_r (50., None); a_fill_opacity 0.5] []] ;

"fill_rule type nonzero",
[[%svg "<path fill-rule='nonzero'/>"]],
Expand Down

0 comments on commit a496fd1

Please sign in to comment.