Add and display polygons

This commit is contained in:
Mikolaj Wielgus 2026-03-10 14:23:55 +01:00
parent b07c770aee
commit d9927d1231
1 changed files with 27 additions and 1 deletions

View File

@ -4,7 +4,7 @@
use specctra::{
math::PointWithRotation,
structure::{DsnFile, Shape},
structure::{DsnFile, Point, Shape},
};
use crate::{
@ -66,6 +66,16 @@ impl Board {
0,
false,
),
// ... TODO.
Shape::Polygon(polygon) => Self::place_polygon(
&mut board,
place.point_with_rotation(),
pin.point_with_rotation(),
&polygon.coords,
polygon.width,
0,
false,
),
_ => (),
}
}
@ -113,6 +123,22 @@ impl Board {
});
}
pub fn place_polygon(
board: &mut Board,
place: PointWithRotation,
pin: PointWithRotation,
coords: &[Point],
width: f64,
layer: usize,
flip: bool,
) {
let vertices: Vec<[i64; 2]> = coords
.iter()
.map(|coord| Self::pos(place, pin, coord.x, coord.y, flip))
.collect();
board.add_polygon(Polygon { vertices, layer });
}
fn pos(
place: PointWithRotation,
pin: PointWithRotation,