mirror of https://codeberg.org/topola/topola.git
Add and display polygons
This commit is contained in:
parent
b07c770aee
commit
d9927d1231
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue