summaryrefslogtreecommitdiff
path: root/library/src/visualize/image.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-12-15 22:51:55 +0100
committerLaurenz <laurmaedje@gmail.com>2022-12-15 23:11:20 +0100
commitb6202b646a0d5ecced301d9bac8bfcaf977d7ee4 (patch)
tree7d42cb50f9e66153e7e8b2217009684e25f54f42 /library/src/visualize/image.rs
parentf3980c704544a464f9729cc8bc9f97d3a7454769 (diff)
Reflection for castables
Diffstat (limited to 'library/src/visualize/image.rs')
-rw-r--r--library/src/visualize/image.rs15
1 files changed, 8 insertions, 7 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,
}