-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve drawing traits, adjust parsing
- Restructure `Canvas` and `Draw` - Enable parsing of Altium arrays - Restructure logging
- Loading branch information
Showing
13 changed files
with
657 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use crate::{ | ||
common::{Color, Location, PosHoriz, PosVert, Rotation}, | ||
font::Font, | ||
sch::Justification, | ||
}; | ||
|
||
/// Generic trait for something that can be drawn. Beware, unstable! | ||
pub trait Canvas { | ||
fn draw_text(&mut self, item: DrawText); | ||
fn draw_line(&mut self, item: DrawLine); | ||
fn draw_polygon(&mut self, item: DrawPolygon); | ||
fn draw_rectangle(&mut self, item: DrawRectangle); | ||
fn draw_image(&mut self, item: DrawImage); | ||
fn add_comment<S: Into<String>>(&mut self, comment: S) {} | ||
} | ||
|
||
/// Helper struct to write some text | ||
#[derive(Clone, Debug, Default)] | ||
pub struct DrawText<'a> { | ||
pub x: i32, | ||
pub y: i32, | ||
pub text: &'a str, | ||
pub font: &'a Font, | ||
pub anchor_h: PosHoriz, | ||
pub anchor_v: PosVert, | ||
pub color: Color, | ||
pub rotation: Rotation, | ||
} | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct DrawLine { | ||
pub start: Location, | ||
pub end: Location, | ||
pub color: Color, | ||
pub width: u16, | ||
// pub width: Option<&'a str>, | ||
} | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct DrawRectangle { | ||
pub x: i32, | ||
pub y: i32, | ||
pub width: i32, | ||
pub height: i32, | ||
pub fill_color: Color, | ||
pub stroke_color: Color, | ||
pub stroke_width: u16, | ||
} | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct DrawPolygon<'a> { | ||
pub locations: &'a [Location], | ||
pub fill_color: Color, | ||
pub stroke_color: Color, | ||
pub stroke_width: u16, | ||
} | ||
|
||
pub struct DrawImage {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.