-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
feature requestNew feature or requestNew feature or requestvisualizeRelated to drawing and visualizations.Related to drawing and visualizations.
Description
Description
I propose adding a filter()
function to apply CSS-style visual filters to arbitrary Typst content. This would allow users to dynamically modify content appearance without external tools.
Expected API:
// Function signature
#filter(
..args // Filter effects with CSS-compatible values
content: content, // Content to apply filters to
) -> content
Example syntax:
// Filters for images
#filter(blur: 2pt, brightness: 80%)[#image("foo.png")]
// Filters for texts
#filter(drop-shadow: (x-offset: 2pt, y-offset: 2pt, blur: 1pt, paint: red)[#strong[Warning]]
// Filters for anything
#filter(saturate: 150%, hue-rotate: 45deg)[#foo-bar-baz()]
Key Parameters (partial implementation):
Filter | Value Type | Example |
---|---|---|
blur |
length | 3pt |
brightness |
ratio | 120% |
contrast |
ratio | 75% |
drop-shadow |
dictionary(x-offset: length , y-offset: length ,blur: length , paint: color ) |
(x-offset: 2pt, y-offset: 1pt, blur: 4pt, paint: rgba(0,0,0,0.5)) |
grayscale |
ratio | 100% |
hue-rotate |
angle | 90deg |
invert |
ratio | 100% |
opacity |
ratio | 40% |
saturate |
ratio | 50% |
sepia |
ratio | 80% |
Use Case
This feature would enable:
- Professional document styling (e.g., muted background images via
opacity
) - Dynamic diagram highlighting (e.g.,
grayscale
for inactive elements) - Accessibility adjustments (e.g.,
contrast
enhancement) - Creative typography effects (text with
drop-shadow
/blur
)
Without this, users must externally pre-process images and lack live content adjustments. Implemented natively, this would:
- Reduce workflow friction
- Enhance design consistency
- Enable responsive styling based on content
cAttte, ShiningYangYXN, Ujjwal1604, T1mVo, hooyuser and 5 moreShiningYangYXN, DVDTSB and pohlrabi404ShiningYangYXN and DVDTSBShiningYangYXN and DVDTSB
Metadata
Metadata
Assignees
Labels
feature requestNew feature or requestNew feature or requestvisualizeRelated to drawing and visualizations.Related to drawing and visualizations.