fixed export for internal rooms
This commit is contained in:
@@ -321,15 +321,16 @@ fn render_mask_pixmap(
|
||||
context.wall_width,
|
||||
WHITE,
|
||||
);
|
||||
raster::draw_cell_walls(
|
||||
&mut pixmap,
|
||||
g,
|
||||
&scene.room_cells,
|
||||
Some(&scene.room_edges),
|
||||
&scene.door_edges,
|
||||
context.wall_width,
|
||||
WHITE,
|
||||
);
|
||||
for room in &layout.rooms {
|
||||
raster::draw_room_walls(
|
||||
&mut pixmap,
|
||||
g,
|
||||
room,
|
||||
&scene.door_edges,
|
||||
context.wall_width,
|
||||
WHITE,
|
||||
);
|
||||
}
|
||||
("walls_mask", pixmap)
|
||||
}
|
||||
MaskTask::Doors => {
|
||||
|
||||
+99
-9
@@ -65,15 +65,10 @@ pub fn render_pixmap_with_scene(
|
||||
wall_w,
|
||||
BLACK,
|
||||
);
|
||||
draw_cell_walls(
|
||||
&mut pixmap,
|
||||
g,
|
||||
&scene.room_cells,
|
||||
Some(&scene.room_edges),
|
||||
&scene.door_edges,
|
||||
wall_w,
|
||||
BLACK,
|
||||
);
|
||||
|
||||
for room in &layout.rooms {
|
||||
draw_room_walls(&mut pixmap, g, room, &scene.door_edges, wall_w, BLACK);
|
||||
}
|
||||
|
||||
for door in &layout.doors {
|
||||
let (color, style) = if settings.colorblind_mode {
|
||||
@@ -543,6 +538,101 @@ pub fn draw_room_crosshatch(
|
||||
}
|
||||
}
|
||||
|
||||
// Draws room walls.
|
||||
pub fn draw_room_walls(
|
||||
pixmap: &mut Pixmap,
|
||||
g: &ExportGeometry,
|
||||
room: &Room,
|
||||
door_edges: &HashSet<CellEdge>,
|
||||
width: f32,
|
||||
color: (u8, u8, u8, u8),
|
||||
) {
|
||||
for rx in 0..room.width {
|
||||
for ry in 0..room.height {
|
||||
let col = room.x + rx;
|
||||
let row = room.y + ry;
|
||||
let left = (col, row);
|
||||
let right = (col + 1, row);
|
||||
let top = (col, row);
|
||||
let bottom = (col, row + 1);
|
||||
|
||||
if rx == 0 {
|
||||
let neighbor = col.checked_sub(1).map(|x| (x, row));
|
||||
let suppressed = neighbor
|
||||
.map(|n| door_edges.contains(&norm_edge(left, n)))
|
||||
.unwrap_or(false);
|
||||
if !suppressed {
|
||||
if let Some(rect) = g.cell_rect(col, row) {
|
||||
draw_wall_segment(
|
||||
pixmap,
|
||||
rect.left(),
|
||||
rect.top(),
|
||||
rect.left(),
|
||||
rect.bottom(),
|
||||
width,
|
||||
color,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if rx == room.width - 1 {
|
||||
let suppressed = door_edges.contains(&norm_edge(left, right));
|
||||
if !suppressed {
|
||||
if let Some(rect) = g.cell_rect(col, row) {
|
||||
draw_wall_segment(
|
||||
pixmap,
|
||||
rect.right(),
|
||||
rect.top(),
|
||||
rect.right(),
|
||||
rect.bottom(),
|
||||
width,
|
||||
color,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ry == 0 {
|
||||
let neighbor = row.checked_sub(1).map(|y| (col, y));
|
||||
let suppressed = neighbor
|
||||
.map(|n| door_edges.contains(&norm_edge(top, n)))
|
||||
.unwrap_or(false);
|
||||
if !suppressed {
|
||||
if let Some(rect) = g.cell_rect(col, row) {
|
||||
draw_wall_segment(
|
||||
pixmap,
|
||||
rect.left(),
|
||||
rect.top(),
|
||||
rect.right(),
|
||||
rect.top(),
|
||||
width,
|
||||
color,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ry == room.height - 1 {
|
||||
let suppressed = door_edges.contains(&norm_edge(top, bottom));
|
||||
if !suppressed {
|
||||
if let Some(rect) = g.cell_rect(col, row) {
|
||||
draw_wall_segment(
|
||||
pixmap,
|
||||
rect.left(),
|
||||
rect.bottom(),
|
||||
rect.right(),
|
||||
rect.bottom(),
|
||||
width,
|
||||
color,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draws cell walls.
|
||||
pub fn draw_cell_walls(
|
||||
pixmap: &mut Pixmap,
|
||||
|
||||
+84
-8
@@ -122,14 +122,10 @@ pub fn build_svg(layout: &DungeonLayout, settings: &UiSettings) -> String {
|
||||
&scene.door_edges,
|
||||
wall_w,
|
||||
);
|
||||
append_svg_walls(
|
||||
&mut s,
|
||||
&g,
|
||||
&scene.room_cells,
|
||||
Some(&scene.room_edges),
|
||||
&scene.door_edges,
|
||||
wall_w,
|
||||
);
|
||||
|
||||
for room in &layout.rooms {
|
||||
append_svg_room_walls(&mut s, &g, room, &scene.door_edges, wall_w);
|
||||
}
|
||||
|
||||
for door in &layout.doors {
|
||||
let (color, dash) = if settings.colorblind_mode {
|
||||
@@ -254,6 +250,86 @@ pub fn build_svg(layout: &DungeonLayout, settings: &UiSettings) -> String {
|
||||
s
|
||||
}
|
||||
|
||||
// Appends svg room walls.
|
||||
pub fn append_svg_room_walls(
|
||||
out: &mut String,
|
||||
g: &ExportGeometry,
|
||||
room: &crate::layout::Room,
|
||||
door_edges: &HashSet<CellEdge>,
|
||||
width: f32,
|
||||
) {
|
||||
for rx in 0..room.width {
|
||||
for ry in 0..room.height {
|
||||
let col = room.x + rx;
|
||||
let row = room.y + ry;
|
||||
let left = g.left() + col as f32 * g.cell;
|
||||
let top = g.top() + row as f32 * g.cell;
|
||||
let right = left + g.cell;
|
||||
let bottom = top + g.cell;
|
||||
|
||||
if rx == 0 {
|
||||
let neighbor = col.checked_sub(1).map(|x| (x, row));
|
||||
let suppressed = neighbor
|
||||
.map(|n| door_edges.contains(&norm_edge((col, row), n)))
|
||||
.unwrap_or(false);
|
||||
if !suppressed {
|
||||
let _ = writeln!(
|
||||
out,
|
||||
"<rect x='{}' y='{}' width='{width}' height='{}' fill='black'/>",
|
||||
left - (width * 0.5),
|
||||
top - (width * 0.5),
|
||||
(bottom - top) + width
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if rx == room.width - 1 {
|
||||
let neighbor = (col + 1, row);
|
||||
let suppressed = door_edges.contains(&norm_edge((col, row), neighbor));
|
||||
if !suppressed {
|
||||
let _ = writeln!(
|
||||
out,
|
||||
"<rect x='{}' y='{}' width='{width}' height='{}' fill='black'/>",
|
||||
right - (width * 0.5),
|
||||
top - (width * 0.5),
|
||||
(bottom - top) + width
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ry == 0 {
|
||||
let neighbor = row.checked_sub(1).map(|y| (col, y));
|
||||
let suppressed = neighbor
|
||||
.map(|n| door_edges.contains(&norm_edge((col, row), n)))
|
||||
.unwrap_or(false);
|
||||
if !suppressed {
|
||||
let _ = writeln!(
|
||||
out,
|
||||
"<rect x='{}' y='{}' width='{}' height='{width}' fill='black'/>",
|
||||
left - (width * 0.5),
|
||||
top - (width * 0.5),
|
||||
(right - left) + width
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ry == room.height - 1 {
|
||||
let neighbor = (col, row + 1);
|
||||
let suppressed = door_edges.contains(&norm_edge((col, row), neighbor));
|
||||
if !suppressed {
|
||||
let _ = writeln!(
|
||||
out,
|
||||
"<rect x='{}' y='{}' width='{}' height='{width}' fill='black'/>",
|
||||
left - (width * 0.5),
|
||||
bottom - (width * 0.5),
|
||||
(right - left) + width
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Appends svg walls.
|
||||
pub fn append_svg_walls(
|
||||
out: &mut String,
|
||||
|
||||
Reference in New Issue
Block a user