diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-02-22 14:31:09 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-02-23 14:53:55 +0100 |
| commit | e1f29d6cb9437a4afb2e4fc4ee10a5b8717ab9fa (patch) | |
| tree | 1ce5f2bd858f6665d3867a2939d4b474c1b70377 /src/library/image.rs | |
| parent | 2bf32c51bceb2f3a8b7ebea3d7c7d6d96757591b (diff) | |
Rework the core context
Diffstat (limited to 'src/library/image.rs')
| -rw-r--r-- | src/library/image.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/library/image.rs b/src/library/image.rs index 000aec73..c1220734 100644 --- a/src/library/image.rs +++ b/src/library/image.rs @@ -14,10 +14,10 @@ impl ImageNode { /// How the image should adjust itself to a given area. pub const FIT: ImageFit = ImageFit::Cover; - fn construct(vm: &mut Vm, args: &mut Args) -> TypResult<Template> { + fn construct(ctx: &mut Context, args: &mut Args) -> TypResult<Template> { let path = args.expect::<Spanned<EcoString>>("path to image file")?; - let full = vm.resolve(&path.v); - let id = vm.images.load(&full).map_err(|err| { + let full = ctx.resolve(&path.v); + let id = ctx.images.load(&full).map_err(|err| { Error::boxed(path.span, match err.kind() { std::io::ErrorKind::NotFound => "file not found".into(), _ => format!("failed to load image ({})", err), @@ -36,11 +36,11 @@ impl ImageNode { impl Layout for ImageNode { fn layout( &self, - vm: &mut Vm, + ctx: &mut Context, regions: &Regions, styles: StyleChain, ) -> TypResult<Vec<Arc<Frame>>> { - let img = vm.images.get(self.0); + let img = ctx.images.get(self.0); let pxw = img.width() as f64; let pxh = img.height() as f64; let px_ratio = pxw / pxh; |
