andreasKroepelin / polylux

A package for creating slides in Typst
https://polylux.dev/book
MIT License
1.18k stars 55 forks source link

True semitransparency during `uncover` #91

Open ntjess opened 1 year ago

ntjess commented 1 year ago

Fix #17 by providing a more generalized cover function. Works with several content types (not just text) and on several background colors instead of assuming white. Sample usage:

```typst #import "polylux.typ": * #set page(width: 2in, height: 2.2in, background: rect(width: 100%, height: 100%)) #let slide = polylux-slide #let img = image("assets/logo.png", height: 0.5in) #slide[ = Hello, world #uncover(2, mode: "transparent", img) #set text(fill: white) #let bg(fill, h: 45%) = place(rect(width: 100%, height: h, fill: fill)) // Typst `green` is not true green #add-hider-mode("green", cover-with-rect.with(fill: rgb(46, 204, 64, 90%))) // Use "transparent" on black background as default when no // mode is specified #add-hider-mode("default", logic.cover-with-black-rect) #bg(black) #uncover(2, [Some text]) #side-by-side[ #uncover(2, img) ][ // Let the user specify their own modes when operating on nonstandard background // colors #uncover(2, mode: "green", box(img, fill: green, outset: 1em)) ] ] ```

Produces: image

andreasKroepelin commented 1 year ago

I tried this myself already but never got the positioning of the covering rect right! So stack seems to be the magic ingredient... Very cool. I will take a closer look at this soon.

ntjess commented 1 year ago

Out of curiosity, any movement on reviewing this PR?

andreasKroepelin commented 1 year ago

Not yet, sorry. I am quite busy at the moment.