summaryrefslogtreecommitdiff
path: root/src/library/image.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-02-17 15:47:54 +0100
committerLaurenz <laurmaedje@gmail.com>2022-02-17 17:32:56 +0100
commitc5e67af22bd6242366819879be84c10c4dd135be (patch)
treed857b99b26401d1b3b74c4cebacbf086c25bef40 /src/library/image.rs
parent3d965ae6a479636a13b2e2f2344e8d97bedece1f (diff)
Merge eval and layout contexts into `Vm`
Diffstat (limited to 'src/library/image.rs')
-rw-r--r--src/library/image.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/library/image.rs b/src/library/image.rs
index 59e30364..5527fbdc 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(ctx: &mut EvalContext, args: &mut Args) -> TypResult<Template> {
+ fn construct(vm: &mut Vm, args: &mut Args) -> TypResult<Template> {
let path = args.expect::<Spanned<EcoString>>("path to image file")?;
- let full = ctx.make_path(&path.v);
- let id = ctx.images.load(&full).map_err(|err| {
+ let full = vm.resolve(&path.v);
+ let id = vm.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,
- ctx: &mut LayoutContext,
+ vm: &mut Vm,
regions: &Regions,
styles: StyleChain,
) -> Vec<Constrained<Arc<Frame>>> {
- let img = ctx.images.get(self.0);
+ let img = vm.images.get(self.0);
let pxw = img.width() as f64;
let pxh = img.height() as f64;
let px_ratio = pxw / pxh;