diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-01-22 13:26:42 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-01-22 13:26:42 +0100 |
| commit | 83b68581461df8968e408bec1b979ed2e3a8f0c5 (patch) | |
| tree | 9c36f1ccb25187ff20eac970847b554ddd01df8b /src | |
| parent | a2d77e36bab83056e3c487adfbeff161485ca47d (diff) | |
Math framework
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc.rs | 18 | ||||
| -rw-r--r-- | src/model/styles.rs | 5 |
2 files changed, 21 insertions, 2 deletions
@@ -7,7 +7,8 @@ use std::sync::Arc; use crate::font::Font; use crate::geom::{ - Abs, Align, Axes, Dir, Em, Numeric, Paint, Point, Shape, Size, Transform, + self, Abs, Align, Axes, Color, Dir, Em, Geometry, Numeric, Paint, Point, RgbaColor, + Shape, Size, Stroke, Transform, }; use crate::image::Image; use crate::model::{ @@ -160,7 +161,7 @@ impl Frame { self.size.y } - /// The baseline of the frame. + /// The vertical position of the frame's baseline. pub fn baseline(&self) -> Abs { self.baseline.unwrap_or(self.size.y) } @@ -170,6 +171,19 @@ impl Frame { self.baseline = Some(baseline); } + /// The distance from the baseline to the top of the frame. + /// + /// This is the same as `baseline()`, but more in line with the terminology + /// used in math layout. + pub fn ascent(&self) -> Abs { + self.baseline() + } + + /// The distance from the baseline to the bottom of the frame. + pub fn descent(&self) -> Abs { + self.size.y - self.baseline() + } + /// An iterator over the elements inside this frame alongside their /// positions relative to the top-left of the frame. pub fn elements(&self) -> std::slice::Iter<'_, (Point, Element)> { diff --git a/src/model/styles.rs b/src/model/styles.rs index e78d83cd..27c40309 100644 --- a/src/model/styles.rs +++ b/src/model/styles.rs @@ -48,6 +48,11 @@ impl StyleMap { } } + /// Remove the style that was last set. + pub fn unset(&mut self) { + self.0.pop(); + } + /// Whether the map contains a style property for the given key. pub fn contains<K: Key>(&self, _: K) -> bool { self.0 |
