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

Polylux Integration #492

Closed
wants to merge 3 commits into from
Closed

Polylux Integration #492

wants to merge 3 commits into from

Conversation

johannes-wolf
Copy link
Member

@johannes-wolf johannes-wolf commented Feb 11, 2024

This PR adds integration for the Polylux module by @andreasKroepelin.
The code currently uses private functions from Polylux logic.typ, maybe those could be made public @andreasKroepelin (see /src/lib/polylux.typ)?

To use Polylux with CeTZ, the user has to pass the Polylux module to the canvas. This allows using different Polylux versions with CeTZ, without CeTZ having a dependency on Polylux.

For an example, see the test case.
The following Polylux functions are available from cetz.polylux:

  • only
  • uncover

@fenjalien, to be able to modify state (counters) I've added a list of functions to ctx that get executed in the canvas function and allow returning content prior to the canvas block. Since the content returned by counter updates is not visible, this should be fine. I could not come up with a better solution.

We could also implement this binding on the Polylux side.

With #494 there is a proof-of-concept for a plug-in API either Polylux or a package like cetz-polylux could use for providing the Polylux bindings.

@johannes-wolf johannes-wolf added the feature 🎁 Feature Request label Feb 11, 2024
@andreasKroepelin
Copy link

Wow, that's cool! What Polylux functions specifically should be made public?

@johannes-wolf
Copy link
Member Author

Wow, that's cool! What Polylux functions specifically should be made public?

See https://github.com/johannes-wolf/cetz/pull/492/files#diff-3d4562bd25428e8bd4aabe76e4f474ce42c427243eab52f8e09b121f1f687d4e

I had to replicate _conditional-display (which I guess is fine) and I am calling _last-required-subslide and _check-visible + using the repetitions and subslides counters.

@OrangeX4
Copy link

As a lower-level foundational graphics package, should cetz rely on higher-level slide packages like polylux and touying, especially when adding a polylux parameter to cetz's canvas? I remain skeptical. I feel that even if support for slides is to be added, it should be done by finding a way for cetz to extract a better interface. For example, adding a parameter "current subslide index" to canvas and letting polylux depend on cetz, rather than the other way around.

For example, touying now supports the use of only in cetz (thanks for the code from polylux). So I thought there might be a better way to deal with the direction of dependency.

#import "@preview/touying:0.2.0": *
#import "@preview/cetz:0.2.0"

#(s.page-args.width = auto)
#(s.page-args.height = auto)
#(s.page-args.footer = none)
#let (init, slide) = utils.methods(s)
#show: init

#slide(repeat: 3, self => [
  #let (only,) = utils.methods(self)

  Current index: #self.subslide

  #cetz.canvas({
    import cetz.draw: *

    rect((-1,-1), (1,1), fill: red)
    only(2, circle((.5,.3), fill: blue))
    only("2-3", {
      line((.2,.1), (rel: (1,1.3)), (rel: (.7, -1.8)), fill: green, close: true)
      content((0, -2), [Hello])
    })
  })
])

image

@OrangeX4
Copy link

Like here: #251 (comment)

@fenjalien
Copy link
Member

Closing this as @johannes-wolf and I figured last night that CeTZ should not be the package containing the integrations/plugins from other packages. They should be in the integrating package or a separate package. We are working on making integrations easier in #494, @OrangeX4 and @andreasKroepelin please join us there to discuss.

@fenjalien fenjalien closed this Feb 12, 2024
johannes-wolf added a commit that referenced this pull request Feb 12, 2024
This PR adds the good parts of #492: having the option to enable canvas
bounds calculation for hidden elements. Supersedes #498.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🎁 Feature Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants