summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJovansonlee Cesar <ivanceras@gmail.com>2018-07-29 21:39:25 +0800
committerJovansonlee Cesar <ivanceras@gmail.com>2018-07-29 21:39:25 +0800
commit60645decbbbfcc3eb5de1af71b94e57461938dde (patch)
treed68f3781e4d148e0424049cd4c9fb201008cd089
parent8e421aaa097aa2d4fb19cd94d2504db0dae2915f (diff)
implementation on dashed line
-rw-r--r--svgbob/src/element.rs6
-rw-r--r--svgbob/src/focus_char.rs3
-rw-r--r--svgbob/src/fragments.rs6
-rw-r--r--svgbob/src/grid.rs3
-rw-r--r--svgbob/src/properties.rs12
5 files changed, 26 insertions, 4 deletions
diff --git a/svgbob/src/element.rs b/svgbob/src/element.rs
index 8fb31ab..2f3d737 100644
--- a/svgbob/src/element.rs
+++ b/svgbob/src/element.rs
@@ -65,6 +65,10 @@ pub fn line(a: &Point, b: &Point) -> Element {
Element::Line(a.clone(), b.clone(), Solid, vec![])
}
+pub fn dashed_line(a: &Point, b: &Point) -> Element {
+ Element::Line(a.clone(), b.clone(), Dashed, vec![])
+}
+
pub fn solid_circle(c: &Point, r: f32) -> Element {
Element::Circle(c.clone(), r, "solid".to_string())
}
@@ -247,8 +251,8 @@ impl Element {
match *stroke {
Solid => (),
Dashed => {
- svg_line.assign("stroke-dasharray", (3, 3));
svg_line.assign("fill", "none");
+ svg_line.assign("class","dashed");
}
};
diff --git a/svgbob/src/focus_char.rs b/svgbob/src/focus_char.rs
index 0fd0435..7fe56af 100644
--- a/svgbob/src/focus_char.rs
+++ b/svgbob/src/focus_char.rs
@@ -13,7 +13,7 @@ use point::Point;
use loc_block::LocBlock;
use element::Element;
use fragments::Fragment::Text;
-use element::{line,arrow_line,start_arrow_line,arc,open_circle,solid_circle,text};
+use element::{line,dashed_line,arrow_line,start_arrow_line,arc,open_circle,solid_circle,text};
use location::Location;
use settings::Settings;
@@ -136,6 +136,7 @@ impl<'g> FocusChar<'g> {
let unit_x = self.loc_block().unit_x();
match frag {
Fragment::Line(p1, p2) => line(&self.point(&p1), &self.point(&p2)),
+ Fragment::DashedLine(p1, p2) => dashed_line(&self.point(&p1), &self.point(&p2)),
Fragment::ArrowLine(p1, p2) => arrow_line(&self.point(&p1), &self.point(&p2)),
Fragment::StartArrowLine(p1, p2) => start_arrow_line(&self.point(&p1), &self.point(&p2)),
diff --git a/svgbob/src/fragments.rs b/svgbob/src/fragments.rs
index 436ef7d..15682d4 100644
--- a/svgbob/src/fragments.rs
+++ b/svgbob/src/fragments.rs
@@ -1,4 +1,4 @@
-use self::Fragment::{Arc, ArrowLine, Line, OpenCircle, SolidCircle, StartArrowLine};
+use self::Fragment::{Arc, ArrowLine, Line, DashedLine, OpenCircle, SolidCircle, StartArrowLine};
use point_block::PointBlock;
@@ -10,6 +10,7 @@ use point_block::PointBlock;
#[derive(Debug, Clone, PartialOrd, PartialEq, Ord, Eq)]
pub enum Fragment {
Line(PointBlock, PointBlock),
+ DashedLine(PointBlock, PointBlock),
ArrowLine(PointBlock, PointBlock),
StartArrowLine(PointBlock, PointBlock), // the arrow is at the start marker
Arc(PointBlock, PointBlock, i32), //i32 is the multiplier to 1/4 of textwidth
@@ -21,6 +22,9 @@ pub enum Fragment {
pub fn line(p1: &PointBlock, p2: &PointBlock) -> Fragment {
Line(p1.clone(), p2.clone())
}
+pub fn dashed_line(p1: &PointBlock, p2: &PointBlock) -> Fragment {
+ DashedLine(p1.clone(), p2.clone())
+}
pub fn arrow_line(p1: &PointBlock, p2: &PointBlock) -> Fragment {
ArrowLine(p1.clone(), p2.clone())
}
diff --git a/svgbob/src/grid.rs b/svgbob/src/grid.rs
index c8d933f..0b210e3 100644
--- a/svgbob/src/grid.rs
+++ b/svgbob/src/grid.rs
@@ -250,6 +250,9 @@ fn get_styles(settings: &Settings) -> Style {
stroke-linecap: round;
stroke-linejoin: miter;
}}
+ line.dashed {{
+ stroke-dasharray: 5;
+ }}
circle {{
stroke: black;
stroke-width: {stroke_width};
diff --git a/svgbob/src/properties.rs b/svgbob/src/properties.rs
index 46b15ba..5a5ce23 100644
--- a/svgbob/src/properties.rs
+++ b/svgbob/src/properties.rs
@@ -5,7 +5,7 @@ use block::Block::{A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U
use point_block::PointBlock;
use fragments::Fragment;
-use fragments::{arc, arrow_line, line, open_circle, solid_circle, start_arrow_line};
+use fragments::{arc, arrow_line, line, open_circle, solid_circle, start_arrow_line, dashed_line};
use self::Signal::{Medium, Strong, Weak};
use box_drawing;
@@ -1495,6 +1495,16 @@ impl Properties for char {
],
})
}
+ else if self.is(':'){
+ Some(Characteristic{
+ intensify: vec![],
+ intended_behavior: vec![],
+ properties: vec![
+ (C, Strong, vec![dashed_line(c,w)]),
+ (W, Strong, vec![dashed_line(c,w)]),
+ ],
+ })
+ }
// if nothing matches, try checking in box drawing
else {
let (blocks, fragments) = box_drawing::box_drawing(&self);