added basic stairs
This commit is contained in:
@@ -826,6 +826,54 @@ pub fn build_svg(layout: &DungeonLayout, settings: &UiSettings) -> String {
|
||||
settings.colorblind_mode,
|
||||
);
|
||||
|
||||
// Draw stairs and elevators.
|
||||
for stair in &layout.stairs {
|
||||
let x = g.left() + stair.cell.0 as f32 * g.cell;
|
||||
let y = g.top() + stair.cell.1 as f32 * g.cell;
|
||||
let w = stair.size as f32 * g.cell;
|
||||
let h = stair.size as f32 * g.cell;
|
||||
|
||||
if stair.is_elevator {
|
||||
let fill = if settings.colorblind_mode {
|
||||
"rgb(180,180,180)"
|
||||
} else {
|
||||
"rgb(100,150,200)"
|
||||
};
|
||||
let _ = writeln!(
|
||||
s,
|
||||
"<rect x='{x}' y='{y}' width='{w}' height='{h}' fill='{fill}' fill-opacity='0.35' stroke='rgb(100,150,200)' stroke-width='2'/>"
|
||||
);
|
||||
let _ = writeln!(
|
||||
s,
|
||||
"<text x='{cx}' y='{cy}' text-anchor='middle' dominant-baseline='middle' fill='white' font-size='{fs}'>E</text>",
|
||||
cx = x + w / 2.0,
|
||||
cy = y + h / 2.0,
|
||||
fs = (g.cell * stair.size as f32 * 0.4).clamp(14.0, 48.0)
|
||||
);
|
||||
} else {
|
||||
let fill = if settings.colorblind_mode {
|
||||
"rgb(180,180,180)"
|
||||
} else {
|
||||
"rgb(200,150,50)"
|
||||
};
|
||||
let _ = writeln!(
|
||||
s,
|
||||
"<rect x='{x}' y='{y}' width='{w}' height='{h}' fill='{fill}' fill-opacity='0.35' stroke='rgb(150,100,30)' stroke-width='2'/>"
|
||||
);
|
||||
let steps = (stair.size as f32 * 2.0).round() as usize;
|
||||
let step_h = h / steps as f32;
|
||||
for i in 0..steps {
|
||||
let sy = y + (i as f32 * step_h) + step_h * 0.5;
|
||||
let _ = writeln!(
|
||||
s,
|
||||
"<line x1='{x1}' y1='{sy}' x2='{x2}' y2='{sy}' stroke='rgb(150,100,30)' stroke-width='1.5'/>",
|
||||
x1 = x + 2.0,
|
||||
x2 = x + w - 2.0
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s.push_str("</svg>\n");
|
||||
s
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user