Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlay images or absolute positioning? #157

Open
kescobo opened this issue Mar 29, 2024 · 4 comments
Open

Overlay images or absolute positioning? #157

kescobo opened this issue Mar 29, 2024 · 4 comments

Comments

@kescobo
Copy link

kescobo commented Mar 29, 2024

I have a series of images that I'd like to animate in, but I'm not sure how to get them to occupy the same space. Eg, say I have

decision-tree_1

and

decision-tree_2

which together make

decision-tree_3

Is there a way to place one on top of the other in animation?

Of course, I can export the combined image (the 3rd) and do something like

#slide(title: [Decision trees])[
  #only(1)[#image("assets/decision-tree_1.png")]
  #only(2)[#image("assets/decision-tree_3.png")]
]

but that's less ideal.

@andreasKroepelin
Copy link
Owner

andreasKroepelin commented Mar 31, 2024

Can you look into the alternatives family of functions in the Polylux docs? They might do what you want.

@kescobo
Copy link
Author

kescobo commented Apr 1, 2024

Not quite - You're right I could do that instead of the #only example at the end, but that still replaces once image with another, rather than stacking them. Eg

#slide(title: [Decision trees])[
  #alternatives[#image("assets/decision-tree_1.png")
  ][#image("assets/decision-tree_2.png")]
]

gives

image

Whereas I'd like it to be more like this on the second slide:

#slide(title: [Decision Trees])[
  #cetz.canvas({
    import cetz.draw: *
    // Your drawing code goes here
    content((0,0), [#image("assets/decision-tree_1.png")])
    content((0,0), [#image("assets/decision-tree_2.png")])
})
]

image

I've tried sticking the calls to #only and other timing functionality inside the cetz canvas, but they don't seem to do anything.

@andreasKroepelin
Copy link
Owner

Using alternatives-fn and then having an appropriate if block in the CeTZ code, deciding whether or not to draw the second image, might work.

@kescobo
Copy link
Author

kescobo commented Apr 2, 2024

OK, I'll look into that, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants