diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-05-14 11:14:28 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-05-14 11:14:28 +0200 |
| commit | e65c2b949c61fde471e03881359a2946845b554f (patch) | |
| tree | 912633376c8dfc9ab63bde24951886df455604b8 /src/layout | |
| parent | 33733fd1efda760d65ff9124b6d143a147edbd11 (diff) | |
Remove resource abstraction and handle images natively
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/background.rs | 2 | ||||
| -rw-r--r-- | src/layout/frame.rs | 30 | ||||
| -rw-r--r-- | src/layout/shaping.rs | 2 |
3 files changed, 6 insertions, 28 deletions
diff --git a/src/layout/background.rs b/src/layout/background.rs index 515eef71..33a9ce75 100644 --- a/src/layout/background.rs +++ b/src/layout/background.rs @@ -30,7 +30,7 @@ impl Layout for BackgroundNode { } }; - let element = Element::Geometry(Geometry { shape, fill: self.fill }); + let element = Element::Geometry(shape, self.fill); frame.elements.insert(0, (point, element)); } diff --git a/src/layout/frame.rs b/src/layout/frame.rs index 9890e33f..ea0f6aa8 100644 --- a/src/layout/frame.rs +++ b/src/layout/frame.rs @@ -1,5 +1,5 @@ use crate::color::Color; -use crate::env::{FaceId, ResourceId}; +use crate::env::{FaceId, ImageId}; use crate::geom::{Length, Path, Point, Size}; use serde::{Deserialize, Serialize}; @@ -41,9 +41,9 @@ pub enum Element { /// Shaped text. Text(Text), /// A geometric shape. - Geometry(Geometry), + Geometry(Shape, Fill), /// A raster image. - Image(Image), + Image(ImageId, Size), } /// A run of shaped text. @@ -54,7 +54,7 @@ pub struct Text { /// The font size. pub size: Length, /// The glyph fill color / texture. - pub color: Fill, + pub fill: Fill, /// The glyphs. pub glyphs: Vec<Glyph>, } @@ -83,19 +83,6 @@ impl Text { } } -/// A shape with some kind of fill. -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct Geometry { - /// The shape to draw. - pub shape: Shape, - /// How the shape looks on the inside. - // - // TODO: This could be made into a Vec<Fill> or something such that - // the user can compose multiple fills with alpha values less - // than one to achieve cool effects. - pub fill: Fill, -} - /// Some shape. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub enum Shape { @@ -113,12 +100,3 @@ pub enum Fill { /// The fill is a color. Color(Color), } - -/// An image element. -#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)] -pub struct Image { - /// The image resource. - pub id: ResourceId, - /// The size of the image in the document. - pub size: Size, -} diff --git a/src/layout/shaping.rs b/src/layout/shaping.rs index e6e28a4a..8a407260 100644 --- a/src/layout/shaping.rs +++ b/src/layout/shaping.rs @@ -70,7 +70,7 @@ impl<'a> ShapedText<'a> { let mut text = Text { face_id, size: self.props.size, - color: self.props.color, + fill: self.props.color, glyphs: vec![], }; |
