cetz icon indicating copy to clipboard operation
cetz copied to clipboard

Refactor & Improve Marks

Open johannes-wolf opened this issue 8 months ago • 0 comments

Changes:

  • Marks draw functions now return elements
  • The mark tip/base offset is now calculated by using new "tip" and "base" anchors
  • The marks length is auto determined

Visual Changes:

  • Straight marks have no default extra padding anymore, can be set by via the mark-style

New Features:

  • Users can provide custom marks using the new register-mark() API
#canvas({
  import draw: *

  register-mark("face", style => {
    circle((0,0), radius: .5, fill: yellow)
    arc((0,0), start: 180deg + 30deg, delta: 180deg - 60deg, anchor: "origin", radius: .3)
    circle((-.15, +.15), radius: .1, fill: white)
    circle((-.10, +.10), radius: .025, fill: black)
    circle((+.15, +.15), radius: .1, fill: white)
    circle((+.20, +.10), radius: .025, fill: black)

    anchor("tip", (+.5, 0))
    anchor("base", (-.5, 0))
  }, mnemonic: ":)")

  catmull((-3, 0), (-1,1), (1,-1), (3,0), mark: (
    end: "face", start: (symbol: ":)", flip: true, reverse: true), ))
})

grafik

Ping: @Jollywatt

johannes-wolf avatar May 25 '24 19:05 johannes-wolf