diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-12-15 22:51:55 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-12-15 23:11:20 +0100 |
| commit | b6202b646a0d5ecced301d9bac8bfcaf977d7ee4 (patch) | |
| tree | 7d42cb50f9e66153e7e8b2217009684e25f54f42 /library/src/visualize | |
| parent | f3980c704544a464f9729cc8bc9f97d3a7454769 (diff) | |
Reflection for castables
Diffstat (limited to 'library/src/visualize')
| -rw-r--r-- | library/src/visualize/image.rs | 15 | ||||
| -rw-r--r-- | library/src/visualize/line.rs | 2 | ||||
| -rw-r--r-- | library/src/visualize/shape.rs | 6 |
3 files changed, 14 insertions, 9 deletions
diff --git a/library/src/visualize/image.rs b/library/src/visualize/image.rs index b8b05aec..936ec3bf 100644 --- a/library/src/visualize/image.rs +++ b/library/src/visualize/image.rs @@ -5,6 +5,8 @@ use typst::image::{Image, ImageFormat, RasterFormat, VectorFormat}; use crate::prelude::*; /// Show a raster or vector graphic. +/// +/// Tags: visualize. #[func] #[capable(Layout, Inline)] #[derive(Debug, Hash)] @@ -112,11 +114,10 @@ pub enum ImageFit { castable! { ImageFit, - Expected: "string", - Value::Str(string) => match string.as_str() { - "cover" => Self::Cover, - "contain" => Self::Contain, - "stretch" => Self::Stretch, - _ => Err(r#"expected "cover", "contain" or "stretch""#)?, - }, + /// The image should completely cover the area. + "cover" => Self::Cover, + /// The image should be fully contained in the area. + "contain" => Self::Contain, + /// The image should be stretched so that it exactly fills the area. + "stretch" => Self::Stretch, } diff --git a/library/src/visualize/line.rs b/library/src/visualize/line.rs index ed6a3d92..9c9b8b00 100644 --- a/library/src/visualize/line.rs +++ b/library/src/visualize/line.rs @@ -1,6 +1,8 @@ use crate::prelude::*; /// Display a line without affecting the layout. +/// +/// Tags: visualize. #[func] #[capable(Layout, Inline)] #[derive(Debug, Hash)] diff --git a/library/src/visualize/shape.rs b/library/src/visualize/shape.rs index 702fc6f8..a3443189 100644 --- a/library/src/visualize/shape.rs +++ b/library/src/visualize/shape.rs @@ -3,6 +3,8 @@ use std::f64::consts::SQRT_2; use crate::prelude::*; /// A sizable and fillable shape with optional content. +/// +/// Tags: visualize. #[func] #[capable(Layout, Inline)] #[derive(Debug, Hash)] @@ -25,7 +27,7 @@ impl<const S: ShapeKind> ShapeNode<S> { /// How to fill the shape. pub const FILL: Option<Paint> = None; /// How to stroke the shape. - #[property(skip, resolve, fold)] + #[property(reflect, skip, resolve, fold)] pub const STROKE: Smart<Sides<Option<PartialStroke>>> = Smart::Auto; /// How much to pad the shape's content. @@ -36,7 +38,7 @@ impl<const S: ShapeKind> ShapeNode<S> { pub const OUTSET: Sides<Option<Rel<Length>>> = Sides::splat(Rel::zero()); /// How much to round the shape's corners. - #[property(skip, resolve, fold)] + #[property(reflect, skip, resolve, fold)] pub const RADIUS: Corners<Option<Rel<Length>>> = Corners::splat(Rel::zero()); fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> { |
