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

[Feature Request] Make CetZ compatible with Polylux #251

Closed
cristobaltapia opened this issue Oct 13, 2023 · 10 comments
Closed

[Feature Request] Make CetZ compatible with Polylux #251

cristobaltapia opened this issue Oct 13, 2023 · 10 comments
Labels
RFE 🎁 Request for Enhancement (feature request)

Comments

@cristobaltapia
Copy link

Hi, thanks for staring this project and give Typst some nice graphic library!

I was thinking of using CetZ in a presentation with Polylux and in general it works very good. However, one feature that is not working is the use of the special functions of polylux to uncover elements (e.g. only, uncover), equivalent to "overlays" in LaTex+Beamer. It would be nice if CetZ could understand/use those functions within a figure, in order to make nice animations. Certainly this has not a great urgency, but it would be a nice addition :) .

@johannes-wolf
Copy link
Member

That is possible. It would be easier if Polylux exposed some public functions that take the location from locate as argument and return instead of calling locate itself. I will take a look into this.

@johannes-wolf johannes-wolf added the RFE 🎁 Request for Enhancement (feature request) label Oct 13, 2023
@cristobaltapia
Copy link
Author

Thanks for considering this! Maybe I can open an issue in polylux about this.

@andreasKroepelin
Copy link

(Polylux author here)
There is the fundamental issue that you can't hide lines or paths in Typst. That's why Polylux' uncover, pause etc. don't play nicely with CeTZ at the moment.

@johannes-wolf
Copy link
Member

johannes-wolf commented Oct 21, 2023

Yes, that is because cetz lines or paths are not Typst content but dictionaries. But Polylux' uncover returns content that must be visible in the document (locate(..)).

I mean you could hide paths in cetz by setting their stroke and fill to none without changing up bboxes or anchors.

@andreasKroepelin
Copy link

Well, you still can't hide them, regardless of how CeTZ represents them intermediately. But using none for strokes is a clever trick!

And you're right, Polylux should export some more overlay functions. Currently I'm thinking about good ways to provide information about the current subslide via a function. You could then do something like

#name-tba(args => {
  cetz.canvas({
    if "we're at the correct subslide" {
      cetz.stroke(red)
    } else {
      cetz.stroke(none)
    }
    // ...
  })
})

@johannes-wolf
Copy link
Member

What would real hiding them look like? I mean, I could also suppress the draw call, without the stroke/fill none hack, but there is no such flag as of now.

@andreasKroepelin
Copy link

andreasKroepelin commented Oct 22, 2023

I was referring to the builtin hide function. So

#hide(line())

still shows a line, and this effect propagates to CetZ.

@laurmaedje
Copy link

That's pretty clearly a bug in Typst and not something polylux or cetz should have to work around.

@Enivex
Copy link

Enivex commented Oct 22, 2023

That's pretty clearly a bug in Typst and not something polylux or cetz should have to work around.

There's an existing issue, just under a somewhat specific name

typst/typst#2040

@Geronymos
Copy link

Sry for posting to a closed issue. But I want to share a workaround for polylux' only() and uncover() in CeTZ with a little scripting for anyone who needs a quick solution in the meantime.

#polylux-slide[
  #for i in range(1,4) [
    #only(i)[
      #cetz.canvas({
        // only(1) in CeTZ
        cetz.draw.rect((0,0), (rel: (3,3)), stroke: if (i == 1) {5pt + red} else {none})
        cetz.draw.rect((4,0), (rel: (3,3)), stroke: 5pt + green)
        // uncover(3-) in CeTZ
        if (i >= 3) {
          cetz.draw.rect((8,0), (rel: (3,3)), stroke: 5pt + blue)
        }
      })
    ]
  ]
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFE 🎁 Request for Enhancement (feature request)
Projects
None yet
Development

No branches or pull requests

7 participants