Skip to content

Commit d4b6cb3

Browse files
authored
Adjust stroke width (#1283)
1 parent 961b1fa commit d4b6cb3

File tree

4 files changed

+76
-32
lines changed

4 files changed

+76
-32
lines changed

src/map/map_info.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ impl MapInfo {
171171
},
172172
MapInfoLayer {
173173
map_info_type: MapInfoType::Outline,
174-
css: vec![CSSClass::FillNone, CSSClass::OutlineStroke],
174+
css: vec![
175+
CSSClass::FillNone,
176+
CSSClass::OutlineStroke,
177+
CSSClass::StrokeWidth2,
178+
],
175179
force_connected: false,
176180
colorize: false,
177181
},
@@ -192,7 +196,11 @@ impl MapInfo {
192196
},
193197
MapInfoLayer {
194198
map_info_type: MapInfoType::Outline,
195-
css: vec![CSSClass::FillNone, CSSClass::OutlineStroke],
199+
css: vec![
200+
CSSClass::FillNone,
201+
CSSClass::OutlineStroke,
202+
CSSClass::StrokeWidth2,
203+
],
196204
force_connected: false,
197205
colorize: false,
198206
},

src/map/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use common::round;
99
use map_info::MapInfo;
1010
use ordermap::OrderSet;
1111
use points::{Point, TracePoints, points_to_svg_path};
12-
use style::{CSSClass, get_style, get_used_definitions};
12+
use style::{CSSClass, get_class_names, get_style, get_used_definitions};
1313

1414
use super::util::decompress_base64_data;
1515
use log::debug;
@@ -303,9 +303,9 @@ impl MapData {
303303
document = document.add(defs).set("viewBox", viewbox.to_svg_viewbox());
304304

305305
if !subsets.is_empty() {
306-
let group_css = CSSClass::WallBase;
307-
let mut group = Group::new().set("class", get_style(&group_css).class_name);
308-
styles.insert(group_css);
306+
let group_css = [CSSClass::WallBase, CSSClass::StrokeWidth2];
307+
let mut group = Group::new().set("class", get_class_names(&group_css));
308+
styles.extend(group_css);
309309

310310
for subset in &subsets {
311311
let (css, subset) = get_svg_subset(subset, rotation)?;

src/map/style.rs

Lines changed: 58 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,12 @@ fn get_definition(def: Definition) -> Box<dyn svg::node::Node> {
6868
#[cfg_attr(test, derive(EnumIter))]
6969
pub(super) enum CSSClass {
7070
Path,
71+
7172
FillNone,
73+
StrokeWidth2,
74+
7275
OutlineStroke,
76+
7377
RoomUnreachable,
7478
RoomUnknown,
7579
RoomColor0,
@@ -78,6 +82,7 @@ pub(super) enum CSSClass {
7882
RoomColor3,
7983
RoomColor4,
8084
RoomColor5,
85+
8186
WallBase,
8287
VirtualWall,
8388
NoMoppingWall,
@@ -150,35 +155,66 @@ fn get_styles() -> &'static HashMap<CSSClass, CSSEntry> {
150155
static STYLES: OnceLock<HashMap<CSSClass, CSSEntry>> = OnceLock::new();
151156
STYLES.get_or_init(|| {
152157
HashMap::from([
153-
(CSSClass::Path, CSSEntry{
154-
identifier: "path",
155-
value: "stroke-width: 1.5; vector-effect: non-scaling-stroke",
156-
class_name: "path",
157-
required_def: None,
158-
}),
158+
(
159+
CSSClass::Path,
160+
CSSEntry {
161+
identifier: "path",
162+
value: "stroke-width: 1.5; vector-effect: non-scaling-stroke",
163+
class_name: "path",
164+
required_def: None,
165+
},
166+
),
159167
(CSSClass::FillNone, css_entry!("f", "fill: none")),
160-
(CSSClass::OutlineStroke, CSSEntry {
161-
class_name: "o",
162-
value: "stroke: #666666; stroke-linecap: round; stroke-linejoin: round; stroke-width: 3",
163-
required_def: None,
164-
identifier: ".o path",
165-
}),
166-
(CSSClass::RoomUnknown, css_entry!("u", "fill: #edf3fb")),
167-
(CSSClass::RoomUnreachable, css_entry!("ru", "fill: url(#ds); mix-blend-mode: multiply;", Definition::DiagonalStripes)),
168+
(
169+
CSSClass::StrokeWidth2,
170+
CSSEntry {
171+
class_name: "s2",
172+
value: "stroke-width: 2",
173+
required_def: None,
174+
identifier: ".s2 path",
175+
},
176+
),
177+
(
178+
CSSClass::OutlineStroke,
179+
CSSEntry {
180+
class_name: "o",
181+
value: "stroke: #666666; stroke-linecap: round; stroke-linejoin: round",
182+
required_def: None,
183+
identifier: ".o path",
184+
},
185+
),
186+
(CSSClass::RoomUnknown, css_entry!("u", "fill: #edf3fb")),
187+
(
188+
CSSClass::RoomUnreachable,
189+
css_entry!(
190+
"ru",
191+
"fill: url(#ds); mix-blend-mode: multiply;",
192+
Definition::DiagonalStripes
193+
),
194+
),
168195
room_color_entry!(RoomColor0, "#a2bce7"),
169196
room_color_entry!(RoomColor1, "#ecd099"),
170197
room_color_entry!(RoomColor2, "#9bd4da"),
171198
room_color_entry!(RoomColor3, "#ecc6c9"),
172199
room_color_entry!(RoomColor4, "#d7bce3"),
173200
room_color_entry!(RoomColor5, "#c3e2b6"),
174-
(CSSClass::WallBase, CSSEntry {
175-
class_name: "w",
176-
value: "stroke-dasharray: 4; stroke-width: 3",
177-
required_def: None,
178-
identifier: ".w path",
179-
}),
180-
(CSSClass::VirtualWall, css_entry!("v", "stroke: #f00000; fill: #f0000030")),
181-
(CSSClass::NoMoppingWall, css_entry!("m", "stroke: #ffa500; fill: #ffa50030")),
201+
(
202+
CSSClass::WallBase,
203+
CSSEntry {
204+
class_name: "w",
205+
value: "stroke-dasharray: 4",
206+
required_def: None,
207+
identifier: ".w path",
208+
},
209+
),
210+
(
211+
CSSClass::VirtualWall,
212+
css_entry!("v", "stroke: #f00000; fill: #f0000030"),
213+
),
214+
(
215+
CSSClass::NoMoppingWall,
216+
css_entry!("m", "stroke: #ffa500; fill: #ffa50030"),
217+
),
182218
])
183219
})
184220
}

0 commit comments

Comments
 (0)