Skip to content
Snippets Groups Projects
Commit fd35df4c authored by Finn Bear's avatar Finn Bear
Browse files

Triangle primitive.

parent ffcba171
No related branches found
No related tags found
No related merge requests found
// See component directory. This file exists to make the individual components accessible to the
// rest of the code.
pub mod arrow;
/// See component directory. This file exists to make the individual components accessible to the
/// rest of the code.
pub mod code;
pub mod grid;
pub mod triangle;
......@@ -4,6 +4,7 @@ use eframe::emath::Rot2;
use std::cmp::Ordering;
/// Pointy line used to emphasize something.
#[must_use = "must call show"]
pub struct Arrow {
pub origin: Pos2,
pub tip: Pos2,
......
use crate::egui::{Pos2, Stroke, Ui};
use eframe::egui::{Color32, Shape};
/// Three-point polygon.
#[must_use = "must call show"]
pub struct Triangle {
pub points: [Pos2; 3],
pub stroke: Color32,
pub stroke_width: f32,
pub fill: Color32,
}
impl Default for Triangle {
fn default() -> Self {
Self {
points: [Pos2::ZERO; 3],
stroke: Color32::BLACK,
stroke_width: 1.0,
fill: Color32::TRANSPARENT,
}
}
}
impl Triangle {
pub fn show(&self, ui: &mut Ui) {
ui.painter().add(Shape::convex_polygon(
self.points.into(),
self.fill,
Stroke::new(self.stroke_width, self.stroke),
));
}
}
use eframe::egui::{Context, Ui};
/// See slide directory. This file exists to make the individual slides accessible to the
/// rest of the code.
// See slide directory. This file exists to make the individual slides accessible to the
// rest of the code.
pub mod s1_title;
pub mod s2_introduction;
pub mod s3_complexity;
......
use crate::egui::Ui;
use crate::component::triangle::Triangle;
use crate::egui::{Color32, Ui};
use crate::slide::Slide;
use eframe::egui::style::Margin;
use eframe::egui::Frame;
use eframe::egui::{Frame, Pos2};
#[derive(Default)]
pub struct Mosaic {}
......@@ -13,6 +14,18 @@ impl Slide for Mosaic {
ui.heading("Going Further");
ui.add_space(8.0);
ui.label("TODO: Triangle mosaic");
Triangle {
points: [
Pos2::new(200.0, 150.0),
Pos2::new(500.0, 220.0),
Pos2::new(300.0, 400.0),
],
stroke_width: 0.0,
fill: Color32::RED,
..Triangle::default()
}
.show(ui)
});
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment