Commit 193e76d8 authored by RazrFalcon's avatar RazrFalcon

(usvg) 'clip-path', 'mask', 'filter' and 'opacity' attributes will always be set on groups.

parent 77baf5cd
a-marker-end-001.svg
a-marker-mid-001.svg
a-marker-start-001.svg
a-overflow-001.svg
a-overflow-002.svg
a-overflow-003.svg
e-marker-001.svg
e-marker-002.svg
e-marker-003.svg
e-marker-004.svg
e-marker-005.svg
e-marker-006.svg
e-marker-007.svg
e-marker-008.svg
e-marker-009.svg
e-marker-010.svg
e-marker-011.svg
e-marker-012.svg
e-marker-013.svg
e-marker-014.svg
e-marker-015.svg
e-marker-016.svg
e-marker-017.svg
e-marker-018.svg
e-marker-019.svg
e-marker-020.svg
e-marker-021.svg
e-marker-022.svg
e-marker-023.svg
e-marker-024.svg
e-marker-025.svg
e-marker-026.svg
e-marker-027.svg
e-marker-028.svg
e-marker-029.svg
e-marker-030.svg
e-marker-031.svg
e-marker-032.svg
e-marker-033.svg
e-marker-034.svg
e-marker-035.svg
e-marker-036.svg
e-marker-037.svg
e-marker-038.svg
e-marker-039.svg
e-marker-040.svg
e-marker-041.svg
e-marker-042.svg
e-marker-043.svg
e-marker-044.svg
e-marker-045.svg
e-marker-046.svg
e-marker-047.svg
e-marker-048.svg
e-marker-049.svg
e-marker-050.svg
e-marker-051.svg
e-marker-052.svg
e-marker-053.svg
e-marker-054.svg
e-marker-055.svg
e-marker-056.svg
a-marker-end-001.svg
a-marker-mid-001.svg
a-marker-start-001.svg
a-overflow-001.svg
a-overflow-002.svg
a-overflow-003.svg
e-marker-001.svg
e-marker-002.svg
e-marker-003.svg
e-marker-004.svg
e-marker-005.svg
e-marker-006.svg
e-marker-007.svg
e-marker-008.svg
e-marker-009.svg
e-marker-010.svg
e-marker-011.svg
e-marker-012.svg
e-marker-013.svg
e-marker-014.svg
e-marker-015.svg
e-marker-016.svg
e-marker-017.svg
e-marker-018.svg
e-marker-019.svg
e-marker-020.svg
e-marker-021.svg
e-marker-022.svg
e-marker-023.svg
e-marker-024.svg
e-marker-025.svg
e-marker-026.svg
e-marker-027.svg
e-marker-028.svg
e-marker-029.svg
e-marker-030.svg
e-marker-031.svg
e-marker-032.svg
e-marker-033.svg
e-marker-034.svg
e-marker-035.svg
e-marker-036.svg
e-marker-037.svg
e-marker-038.svg
e-marker-039.svg
e-marker-040.svg
e-marker-041.svg
e-marker-042.svg
e-marker-043.svg
e-marker-044.svg
e-marker-045.svg
e-marker-046.svg
e-marker-047.svg
e-marker-048.svg
e-marker-049.svg
e-marker-050.svg
e-marker-051.svg
e-marker-052.svg
e-marker-053.svg
e-marker-054.svg
e-marker-055.svg
e-marker-056.svg
......@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed
- Shapes without fill and stroke will no longer be removed.
- `clip-path`, `mask`, `filter` and `opacity` attributes will always be set on groups.
- `FilterPrimitive::filter_input` was removed and each filter primitive that can
have an input has it's own `filter_input` field now.
- Rename `filter_input` fields into `input`.
......
......@@ -17,7 +17,8 @@ Attributes: `width`, `height`, `viewBox` and `preserveAspectRatio`.
=== defs
Children: `linearGradient`, `radialGradient`, `clipPath`, `mask` and `pattern`.
Children: `linearGradient`, `radialGradient`, `clipPath`, `mask`, `pattern`,
`marker` and `filter`.
[[linearGradient_elem]]
......@@ -111,7 +112,7 @@ Attributes: `id`, `transform`, `opacity`, `clip-path`, `mask` and `filter`.
=== path
First, the _usvg_ preprocessor will convert all the shapes into paths.
First, the _usvg_ preprocessor will convert all shapes into paths.
Then it will simplify path's data so it will contain only absolute
MoveTo, LineTo, CurveTo and ClosePath segments.
......
......@@ -335,17 +335,9 @@ fn conv_elements(
conv_fill(tree, &p.fill, defs, parent, &mut path_elem);
conv_stroke(tree, &p.stroke, defs, &mut path_elem);
if let Some(ref id) = p.marker.start {
conv_link(tree, defs, AId::MarkerStart, id, &mut path_elem);
}
if let Some(ref id) = p.marker.mid {
conv_link(tree, defs, AId::MarkerMid, id, &mut path_elem);
}
if let Some(ref id) = p.marker.end {
conv_link(tree, defs, AId::MarkerEnd, id, &mut path_elem);
}
conv_opt_link(tree, defs, AId::MarkerStart, &p.marker.start, &mut path_elem);
conv_opt_link(tree, defs, AId::MarkerMid, &p.marker.mid, &mut path_elem);
conv_opt_link(tree, defs, AId::MarkerEnd, &p.marker.end, &mut path_elem);
// Set `stroke-width` if path has a marker.
// Even if `stroke` is not set, the `stroke-width` attribute
......@@ -458,20 +450,13 @@ fn conv_elements(
conv_transform(AId::Transform, &g.transform, &mut g_elem);
g_elem.set_id(g.id.clone());
if let Some(ref id) = g.clip_path {
conv_link(tree, defs, AId::ClipPath, id, &mut g_elem);
}
if let Some(ref id) = g.mask {
conv_link(tree, defs, AId::Mask, id, &mut g_elem);
}
if let Some(ref id) = g.filter {
conv_link(tree, defs, AId::Filter, id, &mut g_elem);
}
conv_opt_link(tree, defs, AId::ClipPath, &g.clip_path, &mut g_elem);
conv_opt_link(tree, defs, AId::Mask, &g.mask, &mut g_elem);
conv_opt_link(tree, defs, AId::Filter, &g.filter, &mut g_elem);
if let Some(opacity) = g.opacity {
g_elem.set_attribute((AId::Opacity, opacity.value()));
match g.opacity {
Some(opacity) => g_elem.set_attribute((AId::Opacity, opacity.value())),
None => g_elem.set_attribute((AId::Opacity, 1.0)),
}
if !g_elem.has_id() && g_elem.attributes().len() == 0 {
......@@ -726,6 +711,20 @@ fn conv_text_spacing(
node.set_attribute((aid, spacing));
}
fn conv_opt_link(
tree: &Tree,
defs: &svgdom::Node,
aid: AId,
id: &Option<String>,
node: &mut svgdom::Node,
) {
if let Some(id) = id {
conv_link(tree, defs, aid, id, node);
} else {
node.set_attribute((aid, AValue::None));
}
}
fn conv_link(
tree: &Tree,
defs: &svgdom::Node,
......
This diff is collapsed.
......@@ -58,6 +58,9 @@ test!(minimal, false,
fill-opacity='1'
fill-rule='nonzero'
stroke='none'
marker-end='none'
marker-mid='none'
marker-start='none'
visibility='visible'
d='M 0 0 L 10 0 L 10 10 L 0 10 Z'/>
</svg>
......@@ -86,6 +89,9 @@ test!(groups, false,
fill-opacity='1'
fill-rule='nonzero'
stroke='none'
marker-end='none'
marker-mid='none'
marker-start='none'
visibility='visible'
d='M 0 0 L 10 0 L 10 10 L 0 10 Z'/>
</svg>
......@@ -159,17 +165,26 @@ test!(group_clippath, false,
fill-opacity='1'
stroke='none'
clip-rule='nonzero'
marker-end='none'
marker-mid='none'
marker-start='none'
visibility='visible'
d='M 0 0 L 10 0 L 10 10 L 0 10 Z'/>
</clipPath>
</defs>
<g
clip-path='url(#clip1)'>
clip-path='url(#clip1)'
filter='none'
mask='none'
opacity='1'>
<path
fill='#000000'
fill-opacity='1'
fill-rule='nonzero'
stroke='none'
marker-end='none'
marker-mid='none'
marker-start='none'
visibility='visible'
d='M 0 0 L 10 0 L 10 10 L 0 10 Z'/>
</g>
......@@ -198,6 +213,9 @@ test!(ignore_groups_with_id, false,
fill-opacity='1'
fill-rule='nonzero'
stroke='none'
marker-end='none'
marker-mid='none'
marker-start='none'
visibility='visible'
d='M 0 0 L 10 0 L 10 10 L 0 10 Z'/>
</svg>
......@@ -222,6 +240,9 @@ test!(pattern_with_invalid_child, false,
<path
fill='none'
stroke='none'
marker-end='none'
marker-mid='none'
marker-start='none'
visibility='hidden'
d='M 0 0 L 10 0 L 10 10 L 0 10 Z'/>
</svg>
......@@ -244,6 +265,9 @@ test!(pattern_without_children, false,
<path
fill='none'
stroke='none'
marker-end='none'
marker-mid='none'
marker-start='none'
visibility='hidden'
d='M 0 0 L 10 0 L 10 10 L 0 10 Z'/>
</svg>
......@@ -334,6 +358,9 @@ test!(preserve_id, false,
fill-opacity='1'
stroke='none'
clip-rule='nonzero'
marker-end='none'
marker-mid='none'
marker-start='none'
visibility='visible'
d='M 0 0 L 10 0 L 10 10 L 0 10 Z'/>
</clipPath>
......@@ -350,12 +377,18 @@ test!(preserve_id, false,
fill-opacity='1'
fill-rule='nonzero'
stroke='none'
marker-end='none'
marker-mid='none'
marker-start='none'
visibility='visible'
d='M 0 0 L 10 0 L 10 10 L 0 10 Z'/>
</pattern>
</defs>
<g
clip-path='url(#clip1)'>
clip-path='url(#clip1)'
filter='none'
mask='none'
opacity='1'>
<path
id='rect1'
fill='url(#lg1)'
......@@ -369,6 +402,9 @@ test!(preserve_id, false,
stroke-miterlimit='4'
stroke-opacity='1'
stroke-width='1'
marker-end='none'
marker-mid='none'
marker-start='none'
visibility='visible'
d='M 0 0 L 10 0 L 10 10 L 0 10 Z'/>
</g>
......@@ -378,6 +414,9 @@ test!(preserve_id, false,
fill-opacity='1'
fill-rule='nonzero'
stroke='none'
marker-end='none'
marker-mid='none'
marker-start='none'
visibility='visible'
d='M 10 20 L 30 40'/>
<text
......@@ -461,12 +500,19 @@ test!(keep_groups_with_id, true,
usvg:version='0.4.0'>
<defs/>
<g
id='some_group'>
id='some_group'
clip-path='none'
filter='none'
mask='none'
opacity='1'>
<path
fill='#000000'
fill-opacity='1'
fill-rule='nonzero'
stroke='none'
marker-end='none'
marker-mid='none'
marker-start='none'
visibility='visible'
d='M 0 0 L 10 0 L 10 10 L 0 10 Z'/>
</g>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment