Skip to content

Commit 492600c

Browse files
committed
Add stroke-opacity.
1 parent 033d0ba commit 492600c

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

svg_fmt/src/svg.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,16 @@ pub struct Style {
4141
pub fill: Fill,
4242
pub stroke: Stroke,
4343
pub opacity: f32,
44+
pub stroke_opacity: f32,
4445
}
4546

4647
impl fmt::Display for Style {
4748
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
48-
write!(f, "{};{};fill-opacity:{};",
49+
write!(f, "{};{};fill-opacity:{};stroke-opacity:{};",
4950
self.fill,
5051
self.stroke,
5152
self.opacity,
53+
self.stroke_opacity,
5254
)
5355
}
5456
}
@@ -59,6 +61,7 @@ impl Style {
5961
fill: Fill::Color(black()),
6062
stroke: Stroke::None,
6163
opacity: 1.0,
64+
stroke_opacity: 1.0,
6265
}
6366
}
6467
}
@@ -130,6 +133,11 @@ impl Rectangle {
130133
self
131134
}
132135

136+
pub fn stroke_opacity(mut self, opacity: f32) -> Self {
137+
self.style.stroke_opacity = opacity;
138+
self
139+
}
140+
133141
pub fn style(mut self, style: Style) -> Self {
134142
self.style = style;
135143
self
@@ -198,6 +206,10 @@ impl Circle {
198206
self
199207
}
200208

209+
pub fn stroke_opacity(mut self, opacity: f32) -> Self {
210+
self.style.stroke_opacity = opacity;
211+
self
212+
}
201213

202214
pub fn offset(mut self, dx: f32, dy: f32) -> Self {
203215
self.x += dx;
@@ -284,6 +296,11 @@ impl Polygon {
284296
self
285297
}
286298

299+
pub fn stroke_opacity(mut self, opacity: f32) -> Self {
300+
self.style.stroke_opacity = opacity;
301+
self
302+
}
303+
287304
pub fn style(mut self, style: Style) -> Self {
288305
self.style = style;
289306
self
@@ -431,6 +448,11 @@ impl Path {
431448
self
432449
}
433450

451+
pub fn stroke_opacity(mut self, opacity: f32) -> Self {
452+
self.style.stroke_opacity = opacity;
453+
self
454+
}
455+
434456
pub fn style(mut self, style: Style) -> Self {
435457
self.style = style;
436458
self

0 commit comments

Comments
 (0)