aboutsummaryrefslogtreecommitdiff
path: root/src/svg
diff options
context:
space:
mode:
Diffstat (limited to 'src/svg')
-rw-r--r--src/svg/mod.rs11
-rw-r--r--src/svg/style.rs8
2 files changed, 15 insertions, 4 deletions
diff --git a/src/svg/mod.rs b/src/svg/mod.rs
index fffc00b..af066f1 100644
--- a/src/svg/mod.rs
+++ b/src/svg/mod.rs
@@ -13,10 +13,10 @@ use style::Style;
use svgtypes::{Path as SVGPath, PathSegment};
use xmltree::{Element, XMLNode};
-// Find the first XML-Node with the given name. With depth, the maximum depth the
-// algorithm will search to can be set. If it is set to `None`, the algorithm will search the
-// entire sub-tree. Returns `None` if no such child can be found. Returns itself, in case the root
-// node is already of the name given.
+/// Find the first XML-Node with the given name. With depth, the maximum depth the
+/// algorithm will search to can be set. If it is set to `None`, the algorithm will search the
+/// entire sub-tree. Returns `None` if no such child can be found. Returns itself, in case the root
+/// node is already of the name given.
pub fn find_first_node(root: Element, name: &str, depth: Option<usize>) -> Option<Element> {
// The abort condition of this recursive function. If the element itself is of the required
// name, return it.
@@ -68,7 +68,10 @@ pub fn read_svg_file<P: AsRef<Path>>(file: P) -> io::Result<Element> {
}
}
+/// Trait that indicates a struct is capable of drawing SVG-elements.
pub trait DrawSVG {
+ /// Draw the elements given by `svg_data` and all its children to the implementor, with the
+ /// specified scale and translated by `position_px`.
fn draw_svg(&mut self, svg_data: &Element, pixels_per_m: f32, position_px: Vec2<f32>);
}
diff --git a/src/svg/style.rs b/src/svg/style.rs
index 78b800d..7a0110e 100644
--- a/src/svg/style.rs
+++ b/src/svg/style.rs
@@ -1,3 +1,8 @@
+//! Style options for SVG components.
+//!
+//! For information on SVG styles, pleas see the SVG documentation.
+// TODO: There should be a lib available that can be integrated into the program
+
use raylib::ffi::Color;
use std::str::FromStr;
@@ -32,6 +37,7 @@ pub fn colour_from_html(html: &str) -> Option<Color> {
/// The style of the end of the stroke.
/// See [stroke-line-cap property](https://www.w3.org/TR/SVG11/painting.html#StrokeLinecapProperty)
/// in the SVG Documentation.
+#[allow(missing_docs)]
pub enum StrokeLineCap {
Butt,
Round,
@@ -41,6 +47,7 @@ pub enum StrokeLineCap {
/// The style of the joining corners of the stroke.
/// See [stroke-line-join property](https://www.w3.org/TR/SVG11/painting.html#StrokeLinejoinProperty)
/// in the SVG Documentation
+#[allow(missing_docs)]
pub enum StrokeLineJoin {
Miter,
Round,
@@ -48,6 +55,7 @@ pub enum StrokeLineJoin {
}
/// The style of a path drawing instruction.
+#[allow(missing_docs)]
pub struct Style {
pub fill: Option<Color>,
pub stroke: Color,