Skip to main content

New

new() -> function 

Create a new palette based on a base style

let p = cetz.palette.new(colors: (red, blue, green))
for i in range(0, p("len")) {
set-style(..p(i))
circle((0,0), radius: .5)
set-origin((1.1, 0))
}

The functions returned by this function have the following named arguments:

fill:

Default: true

If true, the returned fill color is one of the colors from the colors list, otherwise the base styles fill is used.

stroke:

Default: false

If true, the returned stroke color is one of the colors from the colors list, otherwise the base styles stroke color is used.

You can use a palette for stroking via: red.with(stroke: true).

base:

Default: base-style

Style dictionary to use as base style for the styles generated per color

colors:

Default: ()

List of colors the returned palette should return styles with.

dash:

Default: ()

List of stroke dash patterns the returned palette should return styles with.