cetz icon indicating copy to clipboard operation
cetz copied to clipboard

Allow decoration to be set with style keys.

Open fenjalien opened this issue 1 year ago • 4 comments

You currently have to wrap the path that you want to decorate with another decoration function which effectively modifies the output drawables of the path. Instead (or alongside) I would prefer the option to set a path's decoration through a style key:

line((0,0), (1,1), decoration: "zigzag")

Styling options for the decoration could be given further as a dictionary similar to how mark styling works.

fenjalien avatar Jan 17 '24 16:01 fenjalien

This would effectively resolve #446

fenjalien avatar Jan 17 '24 16:01 fenjalien

Idea we've discussed: Allow to register path modifiers at the context object. So libraries can add their custom path modifiers, like with user definable (define-mark) marks.

johannes-wolf avatar Jan 17 '24 20:01 johannes-wolf

API idea

Elements have a modifier: style key. A modifier can be the name of a modifier function or a dictionary containing the name + style arguments. A user can pass a list of modifiers to an element. All modifiers share some common keys like begin and end to denote the sup section of a path to apply the modifier to.

The modifier API replaces the current path decoration lib.

There will be a separate apply-modifier(.., body) function to apply a modifier to a body.

Modifiers

A path modifier is a function with the following signature (ctx, style, segments, close) -> segments that gets called by the internals.

A user can provide custom modifier functions.

johannes-wolf avatar Apr 07 '24 01:04 johannes-wolf

Considering what I've detailed in #467 I don't agree. Restricting modifiers to be like this feels like a waste of potential. Decorations should really be a subset of modifiers.

fenjalien avatar Apr 07 '24 11:04 fenjalien