shield_maker/
flat_style.rs1use crate::badge::{Renderer, Badger, GradientStop};
2use crate::xml;
3use crate::xml::Pusher;
4
5pub(crate) struct Flat {}
6
7impl Badger for Flat {
8    fn vertical_margin(&self) -> f32 { 0.0 }
9
10    fn height(&self) -> f32 { 20.0 }
11
12    fn shadow(&self) -> bool { true }
13
14    fn render(&self, parent: &Renderer) -> Vec<xml::Node> {
15        let gradient = xml::Node::with_name_and("linearGradient", |n| {
16            n.add_attrs(&[
17                ("id", "s"),
18                ("x2", "0"),
19                ("y2", "100%"),
20            ]);
21            let stops = vec![
22                GradientStop { offset: "0", stop_color: "#bbb", stop_opacity: ".1" },
23                GradientStop { offset: "1", stop_color: "#000", stop_opacity: ".1" },
24            ];
25            for stop in stops {
26                n.push_node_named("stop", |n| stop.into_attributes(n));
27            }
28        });
29
30        let clip_path = parent.make_clip_path_element(3.0);
31
32        let background_group = parent.make_background_group_element(true, &[("clip-path", "url(#r)")]);
33        let foreground_group_element = parent.make_foreground_group_element();
34
35        vec![gradient, clip_path, background_group, foreground_group_element]
36    }
37}