diff --git a/src/core/draw/participant/actor.typ b/src/core/draw/participant/actor.typ index e38bae8..b1256bf 100644 --- a/src/core/draw/participant/actor.typ +++ b/src/core/draw/participant/actor.typ @@ -1,32 +1,54 @@ #import "/src/cetz.typ": draw -#import "/src/core/utils.typ": normalize-measure -#import "/src/consts.typ": * +#import "/src/core/utils.typ": normalize-measure, normalize-units #let name = "actor" #let render(x, y, p, bottom) = { - let m = measure(p.display-name) + let m = normalize-measure(p.display-name) let style = p.resolved-style - let w2 = ACTOR-WIDTH / 2 - let head-r = ACTOR-WIDTH / 4 - let height = ACTOR-WIDTH * 2 + let spacing = normalize-units(style.spacing) + let width = normalize-units(style.width) + let height = width * 2 + let w2 = width / 2 + let head-r = width / 4 let arms-y = height * 0.375 let y0 = if bottom { - y - m.height / 1pt - SYM-GAP + y - m.height - spacing } else { - y + m.height / 1pt + height + SYM-GAP + y + m.height + height + spacing } + + // Head draw.circle( (x, y0 - head-r), radius: head-r, fill: style.fill, stroke: style.stroke ) - draw.line((x, y0 - head-r * 2), (x, y0 - height + w2), stroke: black + .5pt) - draw.line((x - w2, y0 - arms-y), (x + w2, y0 - arms-y), stroke: black + .5pt) - draw.line((x - w2, y0 - height), (x, y0 - height + w2), (x + w2, y0 - height), stroke: black + .5pt) + + // Body + draw.line( + (x, y0 - head-r * 2), + (x, y0 - height + w2), + stroke: style.stroke + ) + + // Arms + draw.line( + (x - w2, y0 - arms-y), + (x + w2, y0 - arms-y), + stroke: style.stroke + ) + + // Legs + draw.line( + (x - w2, y0 - height), + (x, y0 - height + w2), + (x + w2, y0 - height), + stroke: style.stroke + ) draw.content( (x, y), p.display-name, @@ -37,12 +59,17 @@ #let get-size(par) = { let m = normalize-measure(par.display-name) - //ACTOR-WIDTH * 1pt - //ACTOR-WIDTH * 2pt + SYM-GAP * 1pt + h + let width = normalize-units(par.resolved-style.width) + let height = width * 2 + let spacing = normalize-units(par.resolved-style.spacing) - return m + return ( + width: calc.max(m.width, width), + height: height + spacing + m.height + ) } #let default-style = ( - : + width: 20pt, + spacing: 5pt ) \ No newline at end of file diff --git a/src/core/draw/participant/custom.typ b/src/core/draw/participant/custom.typ index c46c1c9..b3b6cf2 100644 --- a/src/core/draw/participant/custom.typ +++ b/src/core/draw/participant/custom.typ @@ -1,7 +1,6 @@ #import "/src/cetz.typ": draw #import "/src/core/utils.typ": normalize-measure, normalize-units -#import "/src/consts.typ": * #let name = "custom"