1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 06:10:06 -04:00

Allow resizing fonts at runtime

This commit is contained in:
Emil Ernerfeldt
2019-01-17 11:03:39 -06:00
parent fe3542a28d
commit 88fdd127ea
9 changed files with 156 additions and 57 deletions

View File

@@ -8,7 +8,7 @@ use crate::{
types::{Color, PaintCmd},
};
#[derive(Clone, Copy, Debug, Default)]
#[derive(Clone, Copy, Debug, Default, Serialize)]
pub struct Vertex {
/// Pixel coordinates
pub pos: Vec2,
@@ -18,7 +18,7 @@ pub struct Vertex {
pub color: Color,
}
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug, Default, Serialize)]
pub struct Frame {
/// Draw as triangles (i.e. the length is a multiple of three)
pub indices: Vec<u32>,
@@ -33,6 +33,14 @@ pub enum PathType {
use self::PathType::*;
impl Frame {
pub fn append(&mut self, frame: &Frame) {
let index_offset = self.vertices.len() as u32;
for index in &frame.indices {
self.indices.push(index_offset + index);
}
self.vertices.extend(frame.vertices.iter());
}
fn triangle(&mut self, a: u32, b: u32, c: u32) {
self.indices.push(a);
self.indices.push(b);
@@ -224,6 +232,9 @@ impl Frame {
);
}
}
PaintCmd::Frame(cmd_frame) => {
frame.append(cmd_frame);
}
PaintCmd::Line {
points,
color,