fastdraw 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -10457,7 +10457,7 @@ function parseStatements(src) {
10457
10457
  // src/defaultLook.ts
10458
10458
  var DEFAULT_LOOK = `// FastDraw default look. Copy it with "fastdraw init-look" and change anything.
10459
10459
  // A light neutral page, white cards with rounded corners and a two-tone icon, softly tinted zones,
10460
- // neutral greys for everything else and one tomato red for the subject and the main path. Geist for names and details, Geist Mono for small technical labels.
10460
+ // neutral greys for everything else and one tomato red for the subject and the main path. Libre Caslon Display for the title, Geist for names and details, Geist Mono for small technical labels.
10461
10461
 
10462
10462
  canvas paper=paper dots=ink/0.07 dotgap=24
10463
10463
 
@@ -10479,7 +10479,7 @@ color violet #7c3aed
10479
10479
 
10480
10480
  font sans "Geist"
10481
10481
  font mono "Geist Mono"
10482
- font serif "Newsreader"
10482
+ font serif "Libre Caslon Display"
10483
10483
 
10484
10484
  // ---- boxes ----------------------------------------------------------------
10485
10485
  style node shape=rect radius=10 size=144x64 fill=#ffffff stroke=ink/0.14 sw=1 sub.font=sans sub.color=muted
@@ -10538,7 +10538,7 @@ style lifeline line head=none stroke=ink/0.20 sw=1 dash=4,4 route=straight use="
10538
10538
  style rule line head=none stroke=ink/0.10 sw=1 route=straight use="thin separator, e.g. above a legend"
10539
10539
 
10540
10540
  // ---- text -----------------------------------------------------------------
10541
- style h1 text font=sans size=26 weight=700 spacing=-0.03 color=ink use="diagram title"
10541
+ style h1 text font=serif size=30 weight=400 spacing=-0.01 dy=4 color=ink use="diagram title"
10542
10542
  style kicker text font=mono size=10 weight=500 color=accent spacing=0.12 caps=1 use="optional: a short category above the title, e.g. PROCESS"
10543
10543
  style dek text font=sans size=14 color=muted use="optional: one line under the title saying what the diagram shows"
10544
10544
  style eyebrow text font=mono size=8 color=muted spacing=0.14 caps=1 use="small caps label, e.g. LEGEND"
@@ -11493,13 +11493,14 @@ function standInIcon(name2) {
11493
11493
 
11494
11494
  // src/bundledLooks.ts
11495
11495
  var BUNDLED_LOOKS = {
11496
- night: `// Night: the built-in look after dark. A deep navy page, raised navy cards with a two-tone icon,
11496
+ night: `// Night: the built-in look in the dark theme. A deep navy page, raised navy cards with a two-tone icon,
11497
11497
  // softly tinted zones, cool greys for everything else and one bright tomato red for the subject and the
11498
- // main path. Same styles as the built-in look, so a diagram moves between them without changes.
11498
+ // main path. Same styles as the built-in look, so a diagram moves between them without changes. It is not
11499
+ // offered as a look of its own: a diagram with no look line is drawn in it whenever the theme is dark.
11499
11500
 
11500
11501
  canvas paper=paper dots=ink/0.08 dotgap=24
11501
11502
 
11502
- // already dark, so "fastdraw render --dark" draws the dark image with this look too
11503
+ // already dark, so "fastdraw render --dark" and the dark theme draw this look too
11503
11504
  dark night
11504
11505
 
11505
11506
  color paper #0b1226
@@ -11516,7 +11517,7 @@ color violet #a78bfa
11516
11517
 
11517
11518
  font sans "Geist"
11518
11519
  font mono "Geist Mono"
11519
- font serif "Newsreader"
11520
+ font serif "Libre Caslon Display"
11520
11521
 
11521
11522
  // ---- boxes ----------------------------------------------------------------
11522
11523
  style node shape=rect radius=10 size=144x64 fill=#131c38 stroke=ink/0.14 sw=1 sub.font=sans sub.color=muted
@@ -11575,7 +11576,7 @@ style lifeline line head=none stroke=ink/0.20 sw=1 dash=4,4 route=straight use="
11575
11576
  style rule line head=none stroke=ink/0.10 sw=1 route=straight use="thin separator, e.g. above a legend"
11576
11577
 
11577
11578
  // ---- text -----------------------------------------------------------------
11578
- style h1 text font=sans size=26 weight=700 spacing=-0.03 color=ink use="diagram title"
11579
+ style h1 text font=serif size=30 weight=400 spacing=-0.01 dy=4 color=ink use="diagram title"
11579
11580
  style kicker text font=mono size=10 weight=500 color=accent spacing=0.12 caps=1 use="optional: a short category above the title, e.g. PROCESS"
11580
11581
  style dek text font=sans size=14 color=muted use="optional: one line under the title saying what the diagram shows"
11581
11582
  style eyebrow text font=mono size=8 color=muted spacing=0.14 caps=1 use="small caps label, e.g. LEGEND"
@@ -11597,6 +11598,9 @@ guidance "Finish with a legend: one statement, 'legend at x,y' followed by style
11597
11598
 
11598
11599
  canvas paper=paper dots=ink/0.055 dotgap=22
11599
11600
 
11601
+ // the look the dark theme and "fastdraw render --dark" draw this look with
11602
+ dark reference-dark
11603
+
11600
11604
  color paper #f5f5f5
11601
11605
  color ink #2d3142
11602
11606
  color muted #4f5d75
@@ -11673,6 +11677,95 @@ style legend extends legend title.size=7.5 item.font=sans item.size=8.5
11673
11677
  style note text font=serif italic=1 size=14 color=muted use="a short editorial aside; at most two"
11674
11678
  style small text font=mono size=9 color=muted use="technical detail: a port, path or command"
11675
11679
 
11680
+ guidance "focal, terminal-focal and primary are the accent. Use the accent on at most two things in one diagram."
11681
+ guidance "tag= is a 3 or 4 letter type marker in the corner of a box (EXT, EDGE, API, DB). Use it on architecture boxes, not flowchart shapes."
11682
+ guidance "sub= is for technical detail in mono type: a product name, path, port or protocol. Names of things go in the main text."
11683
+ guidance "Finish with a legend: one statement, 'legend at x,y' followed by style=\\"what it means\\" for each style you used."
11684
+ `,
11685
+ "reference-dark": `// Reference dark: the reference look on a dark page, for the quality comparison in the dark theme.
11686
+ // It is a test fixture, not the look FastDraw will ship with.
11687
+
11688
+ canvas paper=paper dots=ink/0.055 dotgap=22
11689
+
11690
+ // already dark, so "fastdraw render --dark" and the dark theme draw this look too
11691
+ dark reference-dark
11692
+
11693
+ color paper #17181d
11694
+ color ink #e2e4ea
11695
+ color muted #a6adbf
11696
+ color soft #737b90
11697
+ color accent #f08a5d
11698
+ color link #7ea6ec
11699
+
11700
+ font sans "Geist"
11701
+ font mono "Geist Mono"
11702
+ font serif "Instrument Serif"
11703
+
11704
+ // ---- boxes ----------------------------------------------------------------
11705
+ style node shape=rect radius=6 size=144x64 fill=#20222a stroke=ink sw=1
11706
+ tag.color=ink tag.border=ink/0.4
11707
+ use="default box: a backend, service, component or step"
11708
+ style focal extends node fill=accent/0.08 stroke=accent
11709
+ tag.color=accent tag.border=accent/0.5 ghost.color=accent/0.10
11710
+ use="the one or two elements the diagram is about"
11711
+ style store extends node fill=ink/0.05 stroke=muted tag.color=muted tag.border=muted/0.5
11712
+ use="something that holds data or state"
11713
+ style cloud extends node fill=ink/0.03 stroke=ink/0.30 tag.color=soft tag.border=ink/0.22
11714
+ use="a hosted or third-party platform"
11715
+ style external extends node fill=muted/0.10 stroke=soft tag.color=soft tag.border=soft/0.4
11716
+ use="a person or system outside what you own"
11717
+ style optional extends node fill=ink/0.02 stroke=ink/0.22 dash=4,3 tag.color=soft tag.border=ink/0.22
11718
+ use="optional or asynchronous participant"
11719
+ style sticky extends node size=120x120 fill=#3d3719 stroke=ink/0.25 tag.color=ink tag.border=ink/0.3
11720
+ use="a yellow sticky note: an idea, comment or open question"
11721
+ style sticky-orange extends sticky fill=#43301f use="an orange sticky note: a risk or issue"
11722
+ style sticky-violet extends sticky fill=#2c2748 use="a violet sticky note: a decision or note"
11723
+
11724
+ // ---- flowchart shapes -----------------------------------------------------
11725
+ style step extends node size=160x48 use="flowchart action"
11726
+ style terminal shape=rect radius=24 size=160x48 fill=ink/0.03 stroke=ink/0.30 sw=1
11727
+ use="flowchart start or end"
11728
+ style terminal-focal extends terminal fill=accent/0.08 stroke=accent
11729
+ use="the flowchart outcome that matters most"
11730
+ style decision shape=diamond size=200x96 fill=#20222a stroke=ink sw=1
11731
+ use="flowchart yes/no question; put the text on two short lines"
11732
+
11733
+ // ---- other shapes ---------------------------------------------------------
11734
+ style zone shape=rect radius=8 fill=ink/0.02 stroke=ink/0.10 sw=0.8 layer=back
11735
+ title.pos=top title.font=mono title.size=7 title.weight=400 title.color=ink/0.40 title.spacing=0.14 title.caps=1
11736
+ use="a labelled region drawn behind a group of boxes; always give WxH"
11737
+ style bar shape=rect size=8x80 fill=ink/0.06 stroke=muted sw=0.8
11738
+ use="sequence diagram activation bar, centred on a lifeline; always give WxH"
11739
+
11740
+ style table shape=table radius=6 fill=#20222a stroke=ink sw=1 head.fill=ink/0.06 rule=ink/0.1
11741
+ cell.font=mono cell.size=9.5 detail.color=muted
11742
+ use="an entity, class or database table: a header and rows. One line per row: | id \\"name\\" \\"type\\" \\"key\\". Arrows can end on a row: orders.user_id -> users.id"
11743
+ style matrix extends table align=center grid=1 cell.font=sans
11744
+ use="a grid of values: first row with |= for the column headings, first cell of each row is its name"
11745
+ style chart shape=chart fill=none stroke=ink/0.5 sw=1 mask=0 bar.radius=2 grid.color=ink/0.07
11746
+ tick.font=mono tick.size=8 tick.color=muted
11747
+ use="axes with your numbers drawn for you: chart at x,y WxH x=\\"Q1,Q2,Q3\\" y=0..100, then a line per series: | bars \\"Revenue\\" 42 61 75"
11748
+
11749
+ // ---- lines ----------------------------------------------------------------
11750
+ style arrow line stroke=muted sw=1.2 route=ortho radius=8 label.font=mono label.size=8 label.spacing=0.08
11751
+ use="default arrow"
11752
+ style primary extends arrow stroke=accent sw=1.4 use="the main path; at most two per diagram"
11753
+ style link extends arrow stroke=link use="an HTTP or API request crossing a boundary"
11754
+ style return extends arrow dash=5,4 use="a response, or something optional or asynchronous"
11755
+ style relation extends relation label.font=mono label.size=8 label.spacing=0.08
11756
+ style lifeline line head=none stroke=ink/0.22 sw=1 dash=3,3 route=straight use="sequence diagram lifeline"
11757
+ style rule line head=none stroke=ink/0.10 sw=0.8 route=straight use="thin separator, e.g. above a legend"
11758
+
11759
+ // ---- text -----------------------------------------------------------------
11760
+ style h1 text font=serif size=28 color=ink use="diagram title"
11761
+ style kicker text font=mono size=9 color=accent spacing=0.18 caps=1 use="optional: a short category above the title, e.g. PROCESS"
11762
+ style dek text font=sans size=14 color=muted use="optional: one line under the title saying what the diagram shows"
11763
+ style eyebrow text font=mono size=8 color=muted spacing=0.18 caps=1 use="small caps label, e.g. LEGEND"
11764
+ style caption text font=sans size=8.5 color=muted use="legend entry"
11765
+ style legend extends legend title.size=7.5 item.font=sans item.size=8.5
11766
+ style note text font=serif italic=1 size=14 color=muted use="a short editorial aside; at most two"
11767
+ style small text font=mono size=9 color=muted use="technical detail: a port, path or command"
11768
+
11676
11769
  guidance "focal, terminal-focal and primary are the accent. Use the accent on at most two things in one diagram."
11677
11770
  guidance "tag= is a 3 or 4 letter type marker in the corner of a box (EXT, EDGE, API, DB). Use it on architecture boxes, not flowchart shapes."
11678
11771
  guidance "sub= is for technical detail in mono type: a product name, path, port or protocol. Names of things go in the main text."
@@ -11684,6 +11777,9 @@ guidance "Finish with a legend: one statement, 'legend at x,y' followed by style
11684
11777
 
11685
11778
  canvas paper=paper
11686
11779
 
11780
+ // the look the dark theme and "fastdraw render --dark" draw this look with
11781
+ dark shade-dark
11782
+
11687
11783
  color paper #f5f5f5
11688
11784
  color card #ffffff
11689
11785
  color ink #2d3142
@@ -11749,6 +11845,87 @@ style legend extends legend rule=ink/0.12 title.font=mono item.size=9.5
11749
11845
  style note text font=serif italic=1 size=16 color=ink use="a short aside; at most two"
11750
11846
  style small text font=mono size=9 color=muted use="technical detail: a port, path or command"
11751
11847
 
11848
+ guidance "focal, terminal-focal and primary are the accent. Use the accent on at most two things in one diagram."
11849
+ guidance "Never fill a shape with ink to make it stand out; use focal."
11850
+ guidance "tag= is a 3 or 4 letter type marker in the corner of a box (EXT, EDGE, API, DB). Use it on architecture boxes, not flowchart shapes."
11851
+ guidance "sub= is a short second line of detail: a product name, path, port or protocol. Names of things go in the main text."
11852
+ guidance "kicker and dek are optional. Add a kicker only when the diagram belongs to a named category, and a dek only when there is one clear message; most diagrams need neither."
11853
+ guidance "Finish with a legend: one statement, 'legend at x,y' followed by style=\\"what it means\\" for each style you used."
11854
+ `,
11855
+ "shade-dark": `// Shade dark: Shade on a dark page. Hairline cards on charcoal, each casting a shadow of fine drawn lines,
11856
+ // the tall serif title, typewriter capitals for technical labels, one bright indigo for the subject.
11857
+ // Same styles and sizes as Shade, so a diagram moves between them without changes.
11858
+
11859
+ canvas paper=paper
11860
+
11861
+ // already dark, so "fastdraw render --dark" and the dark theme draw this look too
11862
+ dark shade-dark
11863
+
11864
+ color paper #16171c
11865
+ color card #1f2129
11866
+ color ink #e3e5ec
11867
+ color muted #a4abbd
11868
+ color soft #6f768a
11869
+ color accent #8f88ff
11870
+ color tint #29274f
11871
+ color link #7ea6ec
11872
+ color teal #2dd4bf
11873
+ color amber #f0b45a
11874
+ color rose #fb8c5c
11875
+ color violet #a78bfa
11876
+
11877
+ font sans "Geist"
11878
+ font mono "Geist Mono"
11879
+ font serif "Instrument Serif"
11880
+
11881
+ // ---- boxes -----------------------------------------------------------------
11882
+ style node shape=rect radius=2 size=144x64 fill=card stroke=ink sw=1 shade=ink/0.7 sub.font=mono sub.color=muted
11883
+ tag.color=muted tag.border=ink/0.3 tag.font=mono icon.color=ink use="default box: a backend, service, component or step"
11884
+ style focal extends node fill=tint stroke=accent shade=accent shade.sw=0.8 sub.color=accent
11885
+ tag.color=accent tag.border=accent/0.5 icon.color=accent ghost.color=accent/0.12 use="the one or two elements the diagram is about"
11886
+ style store extends node shape=path path="M0,0.1 C0,-0.035 1,-0.035 1,0.1 L1,0.9 C1,1.035 0,1.035 0,0.9 Z M0,0.1 C0,0.235 1,0.235 1,0.1 C1,0.235 0,0.235 0,0.1" use="something that holds data or state"
11887
+ style cloud extends node stroke=link shade=link/0.8 icon.color=link tag.color=link tag.border=link/0.5 use="a hosted or third-party platform"
11888
+ style external extends node fill=paper stroke=ink/0.5 dash=4,3 shade=none icon.color=muted use="a person or system outside what you own"
11889
+ style optional extends node fill=paper stroke=ink/0.4 dash=2,3 shade=none tag.color=soft tag.border=ink/0.2 use="optional or asynchronous participant"
11890
+ style sticky extends node radius=0 size=120x120 fill=#3b3418 stroke=ink/0.35 shade=ink/0.45 tag.color=ink tag.border=ink/0.3 use="a yellow sticky note: an idea, comment or open question"
11891
+ style sticky-orange extends sticky fill=#40261e use="an orange sticky note: a risk or issue"
11892
+ style sticky-violet extends sticky fill=#2a2547 use="a violet sticky note: a decision or note"
11893
+
11894
+ // ---- flowchart shapes ------------------------------------------------------
11895
+ style step extends node size=160x48 use="flowchart action"
11896
+ style terminal extends node radius=24 size=160x48 use="flowchart start or end"
11897
+ style terminal-focal extends terminal fill=tint stroke=accent shade=accent shade.sw=0.8 use="the flowchart outcome that matters most"
11898
+ style decision shape=diamond size=200x96 fill=card stroke=ink sw=1 shade=ink/0.7 use="flowchart yes/no question; put the text on two short lines"
11899
+
11900
+ // ---- regions and markers ---------------------------------------------------
11901
+ style zone shape=rect radius=0 fill=none hatch=ink/0.1 hatch.gap=6 hatch.sw=0.4 stroke=#3c3f48 sw=1 layer=back
11902
+ title.pos=top title.dy=-10 title.align=left title.font=mono title.size=8 title.weight=500 title.color=soft title.spacing=0.18 title.caps=1 use="a labelled region drawn behind a group of boxes; always give WxH"
11903
+ style bar shape=rect radius=0 size=8x80 fill=tint stroke=accent sw=1 use="sequence diagram activation bar, centred on a lifeline; always give WxH"
11904
+ style table shape=table radius=2 fill=card stroke=ink sw=1 shade=ink/0.7 head.fill=ink/0.06 rule=ink/0.1
11905
+ cell.font=mono cell.size=10 detail.color=muted use="an entity, class or database table: a header and rows. One line per row: | id \\"name\\" \\"type\\" \\"key\\". Arrows can end on a row: orders.user_id -> users.id"
11906
+ style matrix extends table align=center grid=1 cell.font=sans use="a grid of values: first row with |= for the column headings, first cell of each row is its name"
11907
+ style chart shape=chart fill=none stroke=ink/0.6 sw=1 mask=0 bar.radius=0 grid.color=ink/0.08
11908
+ tick.font=mono tick.size=9 tick.color=muted use="axes with your numbers drawn for you: chart at x,y WxH x=\\"Q1,Q2,Q3\\" y=0..100, then a line per series: | bars \\"Revenue\\" 42 61 75"
11909
+
11910
+ // ---- lines -----------------------------------------------------------------
11911
+ style arrow line stroke=muted sw=1 route=ortho radius=8 label.font=mono label.size=8 label.color=muted label.spacing=0.06 use="default arrow"
11912
+ style primary extends arrow stroke=accent sw=1.6 label.color=accent use="the main path; at most two per diagram"
11913
+ style link extends arrow stroke=link label.color=link use="an HTTP or API request crossing a boundary"
11914
+ style return extends arrow dash=5,4 use="a response, or something optional or asynchronous"
11915
+ style relation extends relation stroke=ink/0.7 label.font=mono label.size=8
11916
+ style lifeline line head=none stroke=ink/0.3 sw=1 dash=4,4 route=straight use="sequence diagram lifeline"
11917
+ style rule line head=none stroke=#3c3f48 sw=1 route=straight use="thin separator, e.g. above a legend"
11918
+
11919
+ // ---- text ------------------------------------------------------------------
11920
+ style h1 text font=serif size=36 weight=400 color=ink use="diagram title"
11921
+ style kicker text font=mono size=9 weight=500 color=accent spacing=0.14 caps=1 use="optional: a short category above the title, e.g. PROCESS"
11922
+ style dek text font=sans size=13 color=muted use="optional: one line under the title saying what the diagram shows"
11923
+ style eyebrow text font=mono size=8 color=soft spacing=0.16 caps=1 use="small caps label, e.g. LEGEND"
11924
+ style caption text font=sans size=9.5 color=muted use="small explanatory text"
11925
+ style legend extends legend rule=ink/0.12 title.font=mono item.size=9.5
11926
+ style note text font=serif italic=1 size=16 color=ink use="a short aside; at most two"
11927
+ style small text font=mono size=9 color=muted use="technical detail: a port, path or command"
11928
+
11752
11929
  guidance "focal, terminal-focal and primary are the accent. Use the accent on at most two things in one diagram."
11753
11930
  guidance "Never fill a shape with ink to make it stand out; use focal."
11754
11931
  guidance "tag= is a 3 or 4 letter type marker in the corner of a box (EXT, EDGE, API, DB). Use it on architecture boxes, not flowchart shapes."
@@ -11761,6 +11938,9 @@ guidance "Finish with a legend: one statement, 'legend at x,y' followed by style
11761
11938
  // hatching for the subject. White page, near-black ink, one blue for what the diagram is about.
11762
11939
 
11763
11940
  canvas paper=paper sketch=1
11941
+
11942
+ // the look the dark theme and "fastdraw render --dark" draw this look with
11943
+ dark sketch-dark
11764
11944
  fontdir "./fonts"
11765
11945
 
11766
11946
  color paper #ffffff
@@ -11848,6 +12028,107 @@ style legend extends legend title.font=sans title.size=13 title.caps=0 title.spa
11848
12028
  style note text font=sans size=16 color=accent use="a short handwritten aside; at most two"
11849
12029
  style small text font=mono size=10 color=muted use="technical detail: a port, path or command"
11850
12030
 
12031
+ guidance "Everything is drawn by hand (canvas sketch=1). Keep diagrams loose and roomy: the handwriting is wider than a normal sans, so give boxes a little more width."
12032
+ guidance "focal, terminal-focal and primary are the accent blue. Use the accent on at most two things in one diagram."
12033
+ guidance "Colour by meaning with the pastel fills: fill=sky/0.5, fill=mint/0.7, fill=butter, fill=rose/0.6. Never fill a shape with ink."
12034
+ guidance "hatch=colour fills a shape with pencil hatching; hatch.gap spaces the lines."
12035
+ guidance "Finish with a legend: one statement, 'legend at x,y' followed by style=\\"what it means\\" for each style you used."
12036
+ `,
12037
+ "sketch-dark": `// Sketch dark: Sketch on a dark page, like a whiteboard tool's dark mode. Marker-weight outlines that
12038
+ // wobble, the handwritten font, deep pastel fills and pencil hatching for the subject. Near-black page,
12039
+ // near-white ink, one bright blue for what the diagram is about. Same styles and sizes as Sketch.
12040
+
12041
+ canvas paper=paper sketch=1
12042
+
12043
+ // already dark, so "fastdraw render --dark" and the dark theme draw this look too
12044
+ dark sketch-dark
12045
+ fontdir "./fonts"
12046
+
12047
+ color paper #121316
12048
+ color ink #e6e6ea
12049
+ color muted #b0b4bb
12050
+ color soft #7c828b
12051
+ color accent #4dabf7
12052
+ color sky #1f4f78
12053
+ color mint #2c5c38
12054
+ color leaf #69db7c
12055
+ color butter #5a4c17
12056
+ color amber #ffa94d
12057
+ color rose #6e2f35
12058
+ color link #9775fa
12059
+
12060
+ font sans "Sketch Hand"
12061
+ font serif "Sketch Hand"
12062
+ font mono "Geist Mono"
12063
+
12064
+ // ---- boxes ----------------------------------------------------------------
12065
+ style node shape=rect radius=10 size=144x64 fill=paper stroke=ink sw=2
12066
+ title.font=sans title.size=14 title.weight=400 title.color=ink sub.font=sans sub.size=10.5 sub.color=muted
12067
+ tag.font=sans tag.size=9 tag.color=muted tag.border=ink/0.35
12068
+ use="default box: a backend, service, component or step"
12069
+ style focal extends node fill=sky/0.35 hatch=accent/0.5 hatch.gap=8 hatch.sw=1.2 stroke=accent
12070
+ title.color=ink tag.color=accent tag.border=accent/0.6 ghost.color=accent/0.12
12071
+ use="the one or two elements the diagram is about"
12072
+ style store extends node size=144x72
12073
+ path="M0,0.1 C0,-0.035 1,-0.035 1,0.1 L1,0.9 C1,1.035 0,1.035 0,0.9 Z M0,0.1 C0,0.235 1,0.235 1,0.1 C1,0.235 0,0.235 0,0.1"
12074
+ shape=path fill=butter stroke=ink
12075
+ use="something that holds data or state"
12076
+ style cloud extends node fill=mint/0.7 stroke=leaf tag.color=leaf tag.border=leaf/0.5
12077
+ use="a hosted or third-party platform"
12078
+ style external extends node fill=paper stroke=muted dash=8,7 tag.color=soft
12079
+ use="a person or system outside what you own"
12080
+ style optional extends node fill=paper stroke=soft dash=2,6 tag.color=soft
12081
+ use="optional or asynchronous participant"
12082
+ style sticky extends node size=128x128 radius=4 fill=butter stroke=ink sw=1.5
12083
+ use="a yellow sticky note: an idea, comment or open question"
12084
+ style sticky-orange extends sticky fill=#5c3a17 use="an orange sticky note: a risk or issue"
12085
+ style sticky-violet extends sticky fill=#3c3166 use="a violet sticky note: a decision or note"
12086
+
12087
+ // ---- flowchart shapes -----------------------------------------------------
12088
+ style step extends node size=160x56 use="flowchart action"
12089
+ style terminal extends node shape=ellipse size=168x60 fill=rose/0.6
12090
+ use="flowchart start or end"
12091
+ style terminal-focal extends terminal fill=sky/0.35 hatch=accent/0.5 hatch.gap=8 hatch.sw=1.2 stroke=accent
12092
+ use="the flowchart outcome that matters most"
12093
+ style decision extends node shape=diamond size=208x104 fill=butter/0.8
12094
+ use="flowchart yes/no question; put the text on two short lines"
12095
+
12096
+ // ---- other shapes ---------------------------------------------------------
12097
+ style zone shape=rect radius=12 fill=none stroke=soft sw=1.5 dash=10,8 layer=back
12098
+ title.pos=top title.font=sans title.size=13 title.weight=400 title.color=muted
12099
+ use="a labelled region drawn behind a group of boxes; always give WxH"
12100
+ style bar shape=rect size=10x80 fill=sky/0.5 stroke=ink sw=1.5
12101
+ use="sequence diagram activation bar, centred on a lifeline; always give WxH"
12102
+
12103
+ style table shape=table radius=6 fill=paper stroke=ink sw=2 head.fill=sky/0.45 rule=ink/0.2
12104
+ title.font=sans title.size=14 title.weight=400 cell.font=sans cell.size=12 detail.color=muted
12105
+ use="an entity, class or database table: a header and rows. One line per row: | id \\"name\\" \\"type\\" \\"key\\". Arrows can end on a row: orders.user_id -> users.id"
12106
+ style matrix extends table align=center grid=1
12107
+ use="a grid of values: first row with |= for the column headings, first cell of each row is its name"
12108
+ style chart shape=chart fill=none stroke=ink sw=1.5 mask=0 bar.radius=3 grid.color=ink/0.1
12109
+ tick.font=sans tick.size=11 tick.color=muted
12110
+ use="axes with your numbers drawn for you: chart at x,y WxH x=\\"Q1,Q2,Q3\\" y=0..100, then a line per series: | bars \\"Revenue\\" 42 61 75"
12111
+
12112
+ // ---- lines ----------------------------------------------------------------
12113
+ style arrow line stroke=ink sw=2 route=ortho radius=14 label.font=sans label.size=12 label.spacing=0 label.caps=0 label.color=muted
12114
+ use="default arrow"
12115
+ style primary extends arrow stroke=accent sw=2.5 label.color=accent use="the main path; at most two per diagram"
12116
+ style link extends arrow stroke=link label.color=link use="an HTTP or API request crossing a boundary"
12117
+ style return extends arrow stroke=muted dash=8,7 use="a response, or something optional or asynchronous"
12118
+ style relation extends relation sw=1.8 label.font=sans label.size=12 label.spacing=0 label.caps=0
12119
+ style lifeline line head=none stroke=soft sw=1.5 dash=6,6 route=straight use="sequence diagram lifeline"
12120
+ style rule line head=none stroke=ink/0.25 sw=1.5 route=straight use="thin separator, e.g. above a legend"
12121
+
12122
+ // ---- text -----------------------------------------------------------------
12123
+ style h1 text font=sans size=30 weight=400 color=ink use="diagram title"
12124
+ style kicker text font=sans size=13 color=accent use="optional: a short category above the title"
12125
+ style dek text font=sans size=16 color=muted use="optional: one line under the title saying what the diagram shows"
12126
+ style eyebrow text font=sans size=12 color=muted use="small heading, e.g. Legend"
12127
+ style caption text font=sans size=11 color=muted use="small explanatory text"
12128
+ style legend extends legend title.font=sans title.size=13 title.caps=0 title.spacing=0 item.font=sans item.size=12
12129
+ style note text font=sans size=16 color=accent use="a short handwritten aside; at most two"
12130
+ style small text font=mono size=10 color=muted use="technical detail: a port, path or command"
12131
+
11851
12132
  guidance "Everything is drawn by hand (canvas sketch=1). Keep diagrams loose and roomy: the handwriting is wider than a normal sans, so give boxes a little more width."
11852
12133
  guidance "focal, terminal-focal and primary are the accent blue. Use the accent on at most two things in one diagram."
11853
12134
  guidance "Colour by meaning with the pastel fills: fill=sky/0.5, fill=mint/0.7, fill=butter, fill=rose/0.6. Never fill a shape with ink."
@@ -11860,6 +12141,9 @@ guidance "Finish with a legend: one statement, 'legend at x,y' followed by style
11860
12141
 
11861
12142
  canvas paper=paper dots=ink/0.14 dotgap=24
11862
12143
 
12144
+ // the look the dark theme and "fastdraw render --dark" draw this look with
12145
+ dark whiteboard-dark
12146
+
11863
12147
  color paper #fafafb
11864
12148
  color ink #1a1b25
11865
12149
  color muted #4b4d5c
@@ -11951,6 +12235,112 @@ style legend extends legend title.font=sans item.font=sans item.size=10
11951
12235
  style note text font=sans size=13 color=muted use="a short aside; at most two"
11952
12236
  style small text font=mono size=9.5 color=muted use="technical detail: a port, path or command"
11953
12237
 
12238
+ guidance "focal, terminal-focal and primary are the blue accent. Use the accent on at most two things in one diagram."
12239
+ guidance "store, cloud and external are sticky notes (blue, green, pink). sticky, sticky-orange and sticky-violet are free notes for ideas, risks and decisions; keep their text short."
12240
+ guidance "Never fill a shape with ink to make it stand out; use the accent."
12241
+ guidance "tag= is a 3 or 4 letter type marker in the corner of a box (EXT, EDGE, API, DB). Use it on architecture boxes, not flowchart shapes."
12242
+ guidance "Finish with a legend: one statement, 'legend at x,y' followed by style=\\"what it means\\" for each style you used."
12243
+ `,
12244
+ "whiteboard-dark": `// Whiteboard dark: Whiteboard on a dark board. A charcoal board with a faint dot grid, raised dark shapes
12245
+ // with a light outline, deep sticky notes for the kinds of thing, curved light connectors, one bright blue
12246
+ // for the subject and the main path, and sans type throughout. Same styles and sizes as Whiteboard.
12247
+
12248
+ canvas paper=paper dots=ink/0.14 dotgap=24
12249
+
12250
+ // already dark, so "fastdraw render --dark" and the dark theme draw this look too
12251
+ dark whiteboard-dark
12252
+
12253
+ color paper #1b1c23
12254
+ color ink #ececf1
12255
+ color muted #b1b3c0
12256
+ color soft #7e808d
12257
+ color accent #6b84ff
12258
+ color link #4fb8b2
12259
+
12260
+ // sticky-note pastels
12261
+ color yellow #57501f
12262
+ color blue #1f3d5e
12263
+ color green #2d4b22
12264
+ color pink #582a40
12265
+ color orange #5b3a1d
12266
+ color violet #3a305f
12267
+
12268
+ font sans "Geist"
12269
+ font mono "Geist Mono"
12270
+ font serif "Newsreader"
12271
+
12272
+ // ---- boxes ----------------------------------------------------------------
12273
+ // plain boards shapes are white with a dark outline; stickies have no outline
12274
+ style node shape=rect radius=10 size=144x64 fill=#262832 stroke=ink sw=1.6
12275
+ title.font=sans title.weight=500 title.color=ink sub.font=sans sub.color=muted
12276
+ tag.color=ink tag.border=ink/0.35
12277
+ use="default box: a backend, service, component or step"
12278
+ style focal extends node fill=accent/0.10 stroke=accent sw=2.2
12279
+ title.color=accent tag.color=accent tag.border=accent/0.5 ghost.color=accent/0.12
12280
+ use="the one or two elements the diagram is about"
12281
+ style store extends node radius=3 fill=blue stroke=none sw=0 tag.color=ink tag.border=ink/0.3
12282
+ use="something that holds data or state (blue sticky)"
12283
+ style cloud extends node radius=3 fill=green stroke=none sw=0 tag.color=ink tag.border=ink/0.3
12284
+ use="a hosted or third-party platform (green sticky)"
12285
+ style external extends node radius=3 fill=pink stroke=none sw=0 tag.color=ink tag.border=ink/0.3
12286
+ use="a person or system outside what you own (pink sticky)"
12287
+ style optional extends node fill=#262832 stroke=soft sw=1.4 dash=6,4 tag.color=soft tag.border=soft/0.5
12288
+ title.color=muted
12289
+ use="optional or asynchronous participant"
12290
+ style sticky extends node radius=3 size=120x120 fill=yellow stroke=none sw=0 title.weight=400
12291
+ tag.color=ink tag.border=ink/0.3
12292
+ use="a yellow sticky note: an idea, comment or open question"
12293
+ style sticky-orange extends sticky fill=orange use="an orange sticky note: a risk or issue"
12294
+ style sticky-violet extends sticky fill=violet use="a violet sticky note: a decision or note"
12295
+
12296
+ // ---- flowchart shapes -----------------------------------------------------
12297
+ style step extends node size=160x48 use="flowchart action"
12298
+ style terminal shape=rect radius=24 size=160x48 fill=#262832 stroke=ink sw=1.6 title.weight=500
12299
+ sub.font=sans sub.color=muted tag.color=ink tag.border=ink/0.35
12300
+ use="flowchart start or end"
12301
+ style terminal-focal extends terminal fill=accent stroke=accent title.color=#ffffff
12302
+ sub.color=#ffffff/0.85 tag.color=#ffffff tag.border=#ffffff/0.6
12303
+ use="the flowchart outcome that matters most"
12304
+ style decision shape=diamond size=200x96 fill=yellow stroke=ink sw=1.6 title.weight=500
12305
+ use="flowchart yes/no question; put the text on two short lines"
12306
+
12307
+ // ---- other shapes ---------------------------------------------------------
12308
+ // a zone is a board frame: white sheet, light outline, plain sans name
12309
+ style zone shape=rect radius=6 fill=#262832/0.7 stroke=ink/0.16 sw=1 layer=back
12310
+ title.pos=top title.font=sans title.size=11 title.weight=500 title.color=muted title.spacing=0 title.caps=0
12311
+ use="a labelled region drawn behind a group of boxes; always give WxH"
12312
+ style bar shape=rect radius=2 size=8x80 fill=accent/0.14 stroke=accent sw=1
12313
+ use="sequence diagram activation bar, centred on a lifeline; always give WxH"
12314
+
12315
+ style table shape=table radius=8 fill=#262832 stroke=ink sw=1.4 head.fill=blue rule=ink/0.1
12316
+ cell.font=sans cell.size=10.5 detail.color=muted
12317
+ use="an entity, class or database table: a header and rows. One line per row: | id \\"name\\" \\"type\\" \\"key\\". Arrows can end on a row: orders.user_id -> users.id"
12318
+ style matrix extends table align=center grid=1 cell.font=sans
12319
+ use="a grid of values: first row with |= for the column headings, first cell of each row is its name"
12320
+ style chart shape=chart fill=none stroke=ink/0.6 sw=1.2 mask=0 bar.radius=3 grid.color=ink/0.08
12321
+ tick.font=sans tick.size=10 tick.color=muted
12322
+ use="axes with your numbers drawn for you: chart at x,y WxH x=\\"Q1,Q2,Q3\\" y=0..100, then a line per series: | bars \\"Revenue\\" 42 61 75"
12323
+
12324
+ // ---- lines ----------------------------------------------------------------
12325
+ style arrow line stroke=ink sw=1.6 route=curve radius=10 label.font=sans label.size=10.5 label.color=muted label.spacing=0 label.caps=0
12326
+ use="default connector"
12327
+ style primary extends arrow stroke=accent sw=2.2 use="the main path; at most two per diagram"
12328
+ style link extends arrow stroke=link use="an HTTP or API request crossing a boundary"
12329
+ style return extends arrow stroke=muted dash=6,4 use="a response, or something optional or asynchronous"
12330
+ style relation extends relation label.font=sans label.size=10.5 label.spacing=0 label.caps=0
12331
+ style lifeline line head=none stroke=ink/0.25 sw=1.2 dash=4,4 route=straight use="sequence diagram lifeline"
12332
+ style rule line head=none stroke=ink/0.12 sw=1 route=straight use="thin separator, e.g. above a legend"
12333
+
12334
+ // ---- text -----------------------------------------------------------------
12335
+ style h1 text font=sans size=28 weight=600 color=ink use="diagram title"
12336
+ style kicker text font=sans size=11 weight=600 color=accent spacing=0.06 caps=1 use="optional: a short category above the title, e.g. PROCESS"
12337
+ style dek text font=sans size=14 color=muted use="optional: one line under the title saying what the diagram shows"
12338
+ style eyebrow text font=sans size=9 weight=600 color=muted spacing=0.08 caps=1 use="small caps label, e.g. LEGEND"
12339
+ style caption text font=sans size=10 color=muted use="small explanatory text"
12340
+ style legend extends legend title.font=sans item.font=sans item.size=10
12341
+ style note text font=sans size=13 color=muted use="a short aside; at most two"
12342
+ style small text font=mono size=9.5 color=muted use="technical detail: a port, path or command"
12343
+
11954
12344
  guidance "focal, terminal-focal and primary are the blue accent. Use the accent on at most two things in one diagram."
11955
12345
  guidance "store, cloud and external are sticky notes (blue, green, pink). sticky, sticky-orange and sticky-violet are free notes for ideas, risks and decisions; keep their text short."
11956
12346
  guidance "Never fill a shape with ink to make it stand out; use the accent."
@@ -12226,7 +12616,7 @@ function backdrop(look, v) {
12226
12616
  if (!top || !page) return top;
12227
12617
  return [0, 1, 2].map((i) => top[i] * a + page[i] * (1 - a));
12228
12618
  }
12229
- var SHIPPED_FAMILIES = ["Geist", "Geist Mono", "Newsreader", "Libre Franklin", "Instrument Serif", "Sketch Hand"];
12619
+ var SHIPPED_FAMILIES = ["Geist", "Geist Mono", "Newsreader", "Libre Franklin", "Instrument Serif", "Libre Caslon Display", "Sketch Hand"];
12230
12620
  var SYSTEM_FAMILIES = ["sans-serif", "serif", "monospace", "helvetica"];
12231
12621
  var isShippedFamily = (fam2) => [...SHIPPED_FAMILIES, ...SYSTEM_FAMILIES].some((f) => f.toLowerCase() === fam2.toLowerCase());
12232
12622
  var fallbackFamily = (role, fam2) => role === "mono" || /mono/i.test(fam2) ? "Geist Mono" : role === "serif" ? "Newsreader" : "Geist";
@@ -12480,15 +12870,35 @@ var FONT_WIDTHS = {
12480
12870
  "instrument serif": {
12481
12871
  400: [17, 24, 37, 64, 42, 59, 58, 23, 34, 34, 44, 53, 22, 43, 21, 26, 46, 25, 40, 37, 39, 38, 40, 36, 43, 40, 21, 22, 53, 53, 53, 32, 66, 46, 48, 48, 53, 45, 41, 52, 55, 25, 25, 50, 41, 67, 54, 54, 47, 54, 51, 41, 46, 54, 46, 65, 55, 48, 43, 33, 26, 33, 43, 38, 35, 40, 44, 34, 46, 36, 29, 40, 47, 22, 22, 45, 22, 70, 47, 41, 44, 44, 32, 31, 26, 45, 39, 60, 39, 40, 35, 32, 25, 32, 53, 11, 51, 72, 53, -1, -1, -1, -1, 30, 53, 17, 17, 32, 32]
12482
12872
  },
12873
+ "libre caslon display": {
12874
+ 400: [24, 24, 26, 60, 52, 58, 83, 17, 27, 27, 41, 45, 23, 36, 23, 33, 62, 34, 51, 52, 51, 50, 51, 43, 53, 51, 23, 25, 42, 48, 42, 36, 75, 66, 62, 68, 70, 61, 55, 70, 73, 32, 33, 66, 58, 87, 73, 73, 57, 73, 61, 55, 67, 67, 66, 95, 72, 61, 59, 31, 33, 31, 36, 40, 19, 39, 47, 41, 47, 42, 26, 40, 45, 23, 22, 46, 22, 65, 46, 48, 47, 47, 32, 34, 27, 44, 45, 62, 46, 45, 39, 31, 21, 31, 44, 23, 50, 68, 66, -1, -1, -1, -1, 32, 47, 19, 19, 30, 30]
12875
+ },
12483
12876
  "sketch hand": {
12484
12877
  400: [50, 30, 33, 80, 80, 94, 72, 27, 42, 34, 52, 63, 26, 41, 27, 50, 69, 27, 71, 68, 64, 62, 64, 54, 77, 61, 24, 26, 61, 62, 49, 47, 81, 66, 73, 64, 78, 67, 57, 79, 55, 55, 63, 61, 60, 77, 64, 73, 66, 71, 68, 61, 80, 71, 52, 75, 60, 52, 80, 49, 50, 50, 54, 83, 44, 67, 51, 50, 57, 55, 49, 50, 49, 22, 33, 49, 26, 63, 47, 55, 49, 55, 43, 54, 56, 57, 52, 61, 56, 47, 57, 57, 17, 50, 84, 31, 69, 91, 68, 87, 92, -1, -1, 32, 45, 41, 49, 49, 51]
12485
12878
  }
12486
12879
  };
12487
12880
 
12488
12881
  // src/scene.ts
12882
+ function wrapLines(text, w, measure) {
12883
+ const out = [];
12884
+ for (const line of text.split("\n")) {
12885
+ const words = line.split(" ");
12886
+ let cur = words[0];
12887
+ for (const word of words.slice(1)) {
12888
+ const next = cur + " " + word;
12889
+ if (measure(next) <= w) cur = next;
12890
+ else {
12891
+ out.push(cur);
12892
+ cur = word;
12893
+ }
12894
+ }
12895
+ out.push(cur);
12896
+ }
12897
+ return out;
12898
+ }
12489
12899
  var SERIES = ["bars", "line", "area", "dots"];
12490
12900
  var CANVAS_KEYS = ["paper", "dots", "dotgap", "grid", "gridgap", "lines", "linegap", "cross", "crossgap", "iso", "isogap", "bars", "bargap", "diag", "diaggap", "graph", "graphgap", "hex", "hexgap"];
12491
- var MARKERS = ["none", "arrow", "open", "triangle", "diamond", "diamond-solid", "dot", "circle", "stop", "one", "only-one", "many", "one-many", "zero-one", "zero-many"];
12901
+ var MARKERS = ["none", "arrow", "open", "stealth", "double", "half", "triangle", "diamond", "diamond-solid", "square", "square-solid", "dot", "circle", "bar", "cross", "stop", "one", "only-one", "many", "one-many", "zero-one", "zero-many"];
12492
12902
  var DIRS = { top: { x: 0, y: -1 }, bottom: { x: 0, y: 1 }, left: { x: -1, y: 0 }, right: { x: 1, y: 0 } };
12493
12903
  var num = (v, d) => v === void 0 || v === "" || isNaN(+v) ? d : +v;
12494
12904
  function textWidth(text, size, font, weight, spacing) {
@@ -12515,6 +12925,29 @@ function measureText(look, text, size, role, weight, spacing) {
12515
12925
  var cx = (b) => b.x + b.w / 2;
12516
12926
  var cy = (b) => b.y + b.h / 2;
12517
12927
  var within = (v, lo, hi) => v >= lo && v <= hi;
12928
+ function turnOf(p) {
12929
+ const r = num(p.rotate, 0) % 360;
12930
+ return Number.isFinite(r) && r !== 0 ? r : 0;
12931
+ }
12932
+ function cosSin(deg) {
12933
+ if (deg % 90 === 0) return [[1, 0], [0, 1], [-1, 0], [0, -1]][(deg / 90 % 4 + 4) % 4];
12934
+ const a = deg * Math.PI / 180;
12935
+ return [Math.cos(a), Math.sin(a)];
12936
+ }
12937
+ function turnPt(p, c, deg) {
12938
+ const [co, si] = cosSin(deg), dx = p.x - c.x, dy = p.y - c.y;
12939
+ return { x: c.x + dx * co - dy * si, y: c.y + dx * si + dy * co };
12940
+ }
12941
+ function turnedBox(b, c, deg) {
12942
+ const q = [{ x: b.x, y: b.y }, { x: b.x + b.w, y: b.y }, { x: b.x, y: b.y + b.h }, { x: b.x + b.w, y: b.y + b.h }].map((p) => turnPt(p, c, deg));
12943
+ const x0 = Math.min(...q.map((p) => p.x)), y0 = Math.min(...q.map((p) => p.y));
12944
+ return { x: x0, y: y0, w: Math.max(...q.map((p) => p.x)) - x0, h: Math.max(...q.map((p) => p.y)) - y0 };
12945
+ }
12946
+ var mid = (b) => ({ x: cx(b), y: cy(b) });
12947
+ function footprint(s) {
12948
+ const t = turnOf(s.p);
12949
+ return t ? turnedBox(s, mid(s), t) : s;
12950
+ }
12518
12951
  function autoSides(A, B) {
12519
12952
  if (within(cx(A), B.x, B.x + B.w) || within(cx(B), A.x, A.x + A.w)) return cy(A) <= cy(B) ? ["bottom", "top"] : ["top", "bottom"];
12520
12953
  if (within(cy(A), B.y, B.y + B.h) || within(cy(B), A.y, A.y + A.h)) return cx(A) <= cx(B) ? ["right", "left"] : ["left", "right"];
@@ -12767,16 +13200,16 @@ function withLook(src, look) {
12767
13200
  });
12768
13201
  return lines.join("\n");
12769
13202
  }
12770
- function buildScene(src, lookIn, file = "") {
13203
+ function buildScene(src, lookIn, file = "", drawIn) {
12771
13204
  const issues = [];
12772
13205
  const err = (line, msg) => issues.push({ line, level: "error", msg });
12773
13206
  const warn = (line, msg) => issues.push({ line, level: "warn", msg });
12774
13207
  const stmts = parseStatements(src);
12775
13208
  const lookStmt = stmts.find((s) => s.toks[0]?.v === "look" && s.toks[0].t === "word");
12776
13209
  const named = bundledLook(lookStmt?.toks[1]?.v ?? "");
12777
- let look = named ?? lookIn ?? (lookStmt ? emptyLook() : defaultLook());
13210
+ let look = drawIn ?? named ?? lookIn ?? (lookStmt ? emptyLook() : defaultLook());
12778
13211
  const baseCanvas = look.canvas;
12779
- if (lookStmt) {
13212
+ if (lookStmt && !drawIn) {
12780
13213
  const p = lookStmt.toks[1]?.v;
12781
13214
  if (!p) err(lookStmt.line, `look needs a name or a path, e.g. look sketch or look "./team.look" (named looks: ${BUNDLED_LOOK_NAMES.join(", ")})`);
12782
13215
  else if (!named && !lookIn) err(lookStmt.line, isWebLook(p) ? `the look at ${p} could not be fetched` : movedLookUrl(p) ? `the ${p} look no longer ships with FastDraw; it is in ${LOOKS_REPO} on GitHub: look "${movedLookUrl(p)}"` : /[\\/]|\.look$/i.test(p) ? `look file not found: ${p}` : `no look named ${p}; named looks: ${BUNDLED_LOOK_NAMES.join(", ")}, or give a path to a .look file`);
@@ -12843,6 +13276,7 @@ function buildScene(src, lookIn, file = "") {
12843
13276
  }
12844
13277
  const p2 = { ...style2.props, ...over3 };
12845
13278
  if (p2.route && !["ortho", "straight", "curve"].includes(p2.route)) err(st.line, `route=${p2.route} is not a route; use ortho, straight or curve`);
13279
+ if (over3.rotate !== void 0) warn(st.line, "rotate= does nothing on a line; it follows the things it joins");
12846
13280
  const styleHead = style2.props.head && style2.props.head !== "none" ? style2.props.head : "arrow";
12847
13281
  const plain = style2.props.head === "none" && styleName2 !== "line";
12848
13282
  const headM = over3.head ?? (op === "--" || plain ? "none" : styleHead);
@@ -12925,17 +13359,32 @@ function buildScene(src, lookIn, file = "") {
12925
13359
  continue;
12926
13360
  }
12927
13361
  const fs = num(p.size, 12);
12928
- const lines = (text ?? "").split("\n");
13362
+ let lines = (text ?? "").split("\n");
12929
13363
  const t2 = p.caps === "1" ? (text ?? "").toUpperCase() : text ?? "";
12930
- const w = Math.max(...lines.map((l) => textWidth(l, fs, p.font ?? "sans", num(p.weight, 400), num(p.spacing, 0))));
12931
- const anchor = p.anchor ?? "start";
13364
+ const measure = (l) => textWidth(l, fs, p.font ?? "sans", num(p.weight, 400), num(p.spacing, 0));
13365
+ let w = Math.max(...lines.map(measure));
13366
+ const box = num(p.width, 0) > 0 ? num(p.width, 0) : 0;
13367
+ let wrapped;
13368
+ if (p.width !== void 0 && !box) err(st.line, `width=${p.width}: a text box's width is a number of pixels, e.g. width=240`);
13369
+ if (p.align !== void 0 && !["left", "center", "right"].includes(p.align)) err(st.line, `align=${p.align}: a text lines up left, center or right`);
13370
+ const drawn = (l) => measureText(look, l, fs, p.font ?? "sans", num(p.weight, 400), num(p.spacing, 0));
13371
+ if (box) {
13372
+ wrapped = wrapLines(t2, box, drawn);
13373
+ lines = wrapped;
13374
+ w = box;
13375
+ } else if (p.align !== void 0 && p.align !== "left") warn(st.line, `align= lines a text up inside its box; give it a width (width=240), or move its at point with anchor=${p.align === "center" ? "middle" : "end"}`);
13376
+ if (box && p.anchor !== void 0 && p.anchor !== "start") warn(st.line, `anchor= does nothing on a text box (width=): its at point is the left end; use align=${p.anchor === "middle" ? "center" : "right"}`);
13377
+ const anchor = box ? "start" : p.anchor ?? "start";
12932
13378
  const x = anchor === "middle" ? at.x - w / 2 : anchor === "end" ? at.x - w : at.x;
12933
13379
  const th = fs * 1.3 * lines.length;
13380
+ if (p.rotate !== void 0 && !isFinite(+p.rotate)) err(st.line, `rotate=${p.rotate}: an angle in degrees, turning clockwise (rotate=-90 reads upwards)`);
12934
13381
  const rot = num(p.rotate, 0);
12935
- if (p.rotate !== void 0 && ![0, 90, -90].includes(rot)) err(st.line, `rotate=${p.rotate}: text can be turned by 90 (reading down) or -90 (reading up)`);
12936
13382
  const dx = x - at.x;
12937
- const box = rot === -90 ? { x: at.x - fs, y: at.y - dx - w, w: th, h: w } : rot === 90 ? { x: at.x - th + fs, y: at.y + dx, w: th, h: w } : { x, y: at.y - fs, w, h: th };
12938
- texts.push({ id: register("text", "t"), line: st.line, style: styleName, p, text: t2, ax: at.x, ay: at.y, ...box });
13383
+ if (p.dy !== void 0 && !isFinite(+p.dy)) err(st.line, `dy=${p.dy}: how many pixels lower the text is drawn, e.g. dy=6`);
13384
+ const drop = num(p.dy, 0);
13385
+ const flat = { x, y: at.y - fs + drop, w, h: th };
13386
+ const bx = rot === -90 ? { x: at.x - fs + drop, y: at.y - dx - w, w: th, h: w } : rot === 90 ? { x: at.x - th + fs - drop, y: at.y + dx, w: th, h: w } : turnOf(p) ? turnedBox(flat, at, turnOf(p)) : flat;
13387
+ texts.push({ id: register("text", "t"), line: st.line, style: styleName, p, text: t2, ax: at.x, ay: at.y, ...bx, ...wrapped ? { lines: wrapped } : {}, ...turnOf(p) ? { frame: flat } : {} });
12939
13388
  continue;
12940
13389
  }
12941
13390
  if (!size && p.size) {
@@ -12971,6 +13420,7 @@ function buildScene(src, lookIn, file = "") {
12971
13420
  if (p["icon.style"] !== void 0 && !["outline", "solid", "duotone"].includes(p["icon.style"])) err(st.line, `icon.style=${p["icon.style"]}: an icon is drawn as an outline (the default), filled in one colour (icon.style=solid), or as an outline over a light tint (icon.style=duotone)`);
12972
13421
  else if ((p["icon.style"] === "solid" || p["icon.style"] === "duotone") && p.icon && p.icon !== "none" && (look.icons.has(p.icon) || look.images.has(p.icon)) && !isBuiltIn(look, p.icon)) warn(st.line, `icon ${p.icon} is the look's own, with no ${p["icon.style"]} version (only the built-in icons have one), so it is drawn as it is; drop icon.style=${p["icon.style"]}`);
12973
13422
  if (p["icon.pos"] && !["left", "top", "corner"].includes(p["icon.pos"])) err(st.line, `icon.pos=${p["icon.pos"]}: an icon sits left of the text, on top of it, or in the top-left corner as a tab (icon.pos=left, icon.pos=top or icon.pos=corner)`);
13423
+ if (p.rotate !== void 0 && !isFinite(+p.rotate)) err(st.line, `rotate=${p.rotate}: an angle in degrees; the shape turns clockwise about its middle (e.g. rotate=45)`);
12974
13424
  for (const k of ["color", "weight", "font", "italic"]) if (over2[k] !== void 0) warn(st.line, `${k}= does nothing on a shape; its text is set with title.${k}= (and sub.${k}= for the second line)`);
12975
13425
  if (sh.shape === "polygon") {
12976
13426
  const rel = (p.points ?? "").split(";").filter(Boolean).map((q) => {
@@ -13081,6 +13531,7 @@ function buildScene(src, lookIn, file = "") {
13081
13531
  }
13082
13532
  const shapeById = /* @__PURE__ */ new Map();
13083
13533
  for (const s of shapes) shapeById.set(s.id, s);
13534
+ const turnById = new Map(shapes.filter((s) => turnOf(s.p)).map((s) => [s.id, turnOf(s.p)]));
13084
13535
  for (const t of texts) shapeById.set(t.id, { x: t.x - 4, y: t.y - 2, w: t.w + 8, h: t.h + 4 });
13085
13536
  const connById = new Map(conns.map((c) => [c.id, c]));
13086
13537
  const rowsById = new Map(shapes.filter((s) => s.rows).map((s) => [s.id, s.rows]));
@@ -13090,6 +13541,20 @@ function buildScene(src, lookIn, file = "") {
13090
13541
  return r ? { x: S.x, y: r.y, w: S.w, h: r.h } : S;
13091
13542
  };
13092
13543
  const sideKey = (e) => `${e.id}${e.row ? "." + e.row : ""}|${e.side}`;
13544
+ const turnAt = (e) => {
13545
+ const deg = e.kind === "shape" ? turnById.get(e.id) : void 0;
13546
+ return deg ? { c: mid(shapeById.get(e.id)), deg } : null;
13547
+ };
13548
+ const turnBack = (e, r) => {
13549
+ const t = turnAt(e);
13550
+ return t ? turnPt(r, { x: 0, y: 0 }, -t.deg) : r;
13551
+ };
13552
+ const seenFrom = (e, b) => {
13553
+ const t = turnAt(e);
13554
+ if (!t || !b) return b;
13555
+ const m = turnPt(mid(b), t.c, -t.deg);
13556
+ return { x: m.x - b.w / 2, y: m.y - b.h / 2, w: b.w, h: b.h };
13557
+ };
13093
13558
  const done = /* @__PURE__ */ new Set();
13094
13559
  const bad = /* @__PURE__ */ new Set();
13095
13560
  for (const c of conns) for (const e of [c.a, c.b]) {
@@ -13134,12 +13599,13 @@ function buildScene(src, lookIn, file = "") {
13134
13599
  const relSide = (r) => Math.abs(r.y) >= Math.abs(r.x) ? r.y >= 0 ? "bottom" : "top" : r.x >= 0 ? "right" : "left";
13135
13600
  const rowSide = (me, other, rel) => (other ? cx(other) >= cx(me) : rel.x >= 0) ? "right" : "left";
13136
13601
  if (c.a.kind === "shape" && !c.a.side) {
13137
- c.a.side = c.a.row ? rowSide(ba, bb, c.b.rel ?? { x: 0, y: 0 }) : bb ? autoSides(ba, bb)[0] : relSide(c.b.rel);
13602
+ const ob = seenFrom(c.a, bb), rel = c.b.rel && turnBack(c.a, c.b.rel);
13603
+ c.a.side = c.a.row ? rowSide(ba, ob, rel ?? { x: 0, y: 0 }) : ob ? autoSides(ba, ob)[0] : relSide(rel);
13138
13604
  c.a.fanned = true;
13139
13605
  }
13140
13606
  if (c.b.kind === "shape" && !c.b.side) {
13141
- const back = c.a.rel ? { x: -c.a.rel.x, y: -c.a.rel.y } : { x: 0, y: 0 };
13142
- c.b.side = c.b.row ? rowSide(bb, ba, back) : ba ? autoSides(ba, bb)[1] : relSide(back);
13607
+ const back = turnBack(c.b, c.a.rel ? { x: -c.a.rel.x, y: -c.a.rel.y } : { x: 0, y: 0 }), ob = seenFrom(c.b, ba);
13608
+ c.b.side = c.b.row ? rowSide(bb, ob, back) : ob ? autoSides(ob, bb)[1] : relSide(back);
13143
13609
  c.b.fanned = true;
13144
13610
  }
13145
13611
  }
@@ -13154,8 +13620,8 @@ function buildScene(src, lookIn, file = "") {
13154
13620
  const single = /* @__PURE__ */ new Set();
13155
13621
  for (const [k, g] of groups) {
13156
13622
  const horiz = k.endsWith("top") || k.endsWith("bottom");
13157
- const ref = (o) => {
13158
- const b = boxOf(o);
13623
+ const ref = (e, o) => {
13624
+ const b = seenFrom(e, boxOf(o));
13159
13625
  return b ? horiz ? cx(b) : cy(b) : 0;
13160
13626
  };
13161
13627
  if (g.length === 1) {
@@ -13163,7 +13629,7 @@ function buildScene(src, lookIn, file = "") {
13163
13629
  single.add(g[0].e);
13164
13630
  continue;
13165
13631
  }
13166
- const order = g.map((m, idx) => ({ m, idx, r: ref(m.o) })).sort((p, q) => byNumber(p.r, q.r) || p.idx - q.idx);
13632
+ const order = g.map((m, idx) => ({ m, idx, r: ref(m.e, m.o) })).sort((p, q) => byNumber(p.r, q.r) || p.idx - q.idx);
13167
13633
  order.forEach((o, n) => frac.set(o.m.e, (n + 1) / (g.length + 1)));
13168
13634
  }
13169
13635
  for (const c of batch) {
@@ -13177,11 +13643,18 @@ function buildScene(src, lookIn, file = "") {
13177
13643
  const lo = horiz ? S.x : S.y, hi = horiz ? S.x + S.w : S.y + S.h;
13178
13644
  if (e.v < lo || e.v > hi) warn(c.line, `${e.raw}: ${e.v} is outside the ${e.side} side of ${e.id}, which runs from ${lo} to ${hi}; the end was moved to the nearest point`);
13179
13645
  }
13646
+ const t = turnAt(e);
13647
+ if (t) {
13648
+ const q = turnPt(e.pt, t.c, t.deg), d = turnPt(e.dir, { x: 0, y: 0 }, t.deg);
13649
+ e.pt = { x: Math.round(q.x), y: Math.round(q.y) };
13650
+ const ax = Math.abs(Math.round(d.x * 1e6)), ay = Math.abs(Math.round(d.y * 1e6));
13651
+ e.dir = !c.ortho ? d : ax >= ay ? { x: Math.sign(d.x), y: 0 } : { x: 0, y: Math.sign(d.y) };
13652
+ }
13180
13653
  }
13181
13654
  }
13182
13655
  const a = c.a, b = c.b;
13183
13656
  const opposing = a.dir && b.dir && a.dir.x === -b.dir.x && a.dir.y === -b.dir.y;
13184
- if (a.kind === "shape" && b.kind === "shape" && opposing) {
13657
+ if (a.kind === "shape" && b.kind === "shape" && opposing && !turnAt(a) && !turnAt(b)) {
13185
13658
  const A = tgt(a), B = tgt(b);
13186
13659
  const horiz = a.side === "top" || a.side === "bottom";
13187
13660
  const lo = horiz ? Math.max(A.x, B.x) : Math.max(A.y, B.y);
@@ -13205,7 +13678,7 @@ function buildScene(src, lookIn, file = "") {
13205
13678
  }
13206
13679
  }
13207
13680
  for (const [e, o] of [[a, b], [b, a]]) {
13208
- if (e.kind !== "shape" || !single.has(e) || o.kind !== "point" && o.kind !== "conn") continue;
13681
+ if (e.kind !== "shape" || !single.has(e) || o.kind !== "point" && o.kind !== "conn" || turnAt(e)) continue;
13209
13682
  const S = tgt(e);
13210
13683
  const horiz = e.side === "top" || e.side === "bottom";
13211
13684
  const pos = horiz ? o.pt.x : o.pt.y;
@@ -13228,9 +13701,9 @@ function buildScene(src, lookIn, file = "") {
13228
13701
  c.pts = c.curve ? curvePts(a.pt, a.dir, b.pt, b.dir, via, num(c.p.bend, NaN)) : route(c, via);
13229
13702
  if (c.ortho && !via.length && !c.ushape) {
13230
13703
  const strictlyIn = (o, p) => p.x > o.x + 1 && p.x < o.x + o.w - 1 && p.y > o.y + 1 && p.y < o.y + o.h - 1;
13231
- const obs = shapes.filter((o) => !o.back && o.shape !== "legend" && !(o.poly && o.p.open === "1") && Math.min(o.w, o.h) > 12 && !strictlyIn(o, a.pt) && !strictlyIn(o, b.pt));
13704
+ const obs = shapes.filter((o) => !o.back && o.shape !== "legend" && !(o.poly && o.p.open === "1") && Math.min(o.w, o.h) > 12 && !strictlyIn(footprint(o), a.pt) && !strictlyIn(footprint(o), b.pt)).map(footprint);
13232
13705
  for (const o of shapes) {
13233
- const cb = o.id !== c.a.id && o.id !== c.b.id ? captionBox(o) : null;
13706
+ const cb = o.id !== c.a.id && o.id !== c.b.id ? captionFootprint(o) : null;
13234
13707
  if (cb) obs.push({ x: cb.x - 4, y: cb.y - 2, w: cb.w + 8, h: cb.h + 4 });
13235
13708
  }
13236
13709
  if (crosses(c.pts, obs)) {
@@ -13239,7 +13712,7 @@ function buildScene(src, lookIn, file = "") {
13239
13712
  }
13240
13713
  }
13241
13714
  if (c.ortho) for (let i = 0; i < c.pts.length - 1; i++) taken.push([c.pts[i], c.pts[i + 1]]);
13242
- c.label = makeLabel(c, shapes.filter((o) => !o.back && o.shape !== "legend"));
13715
+ c.label = makeLabel(c, shapes.filter((o) => !o.back && o.shape !== "legend").map(footprint));
13243
13716
  done.add(c);
13244
13717
  }
13245
13718
  };
@@ -13255,7 +13728,7 @@ function buildScene(src, lookIn, file = "") {
13255
13728
  }
13256
13729
  resolvePass(second.filter((c) => !bad.has(c)));
13257
13730
  const finalConns = conns.filter((c) => done.has(c));
13258
- const ext = extent([...shapes, ...shapes.map(captionBox).filter((b) => !!b)], texts, finalConns);
13731
+ const ext = extent([...shapes.map(footprint), ...shapes.map(captionFootprint).filter((b) => !!b)], texts, finalConns);
13259
13732
  return { file, ...ext, look, canvasLine, canvasSize, baseCanvas, shapes, texts, conns: finalConns, issues };
13260
13733
  }
13261
13734
  var ICON_CAPTION_GAP = 6;
@@ -13267,6 +13740,10 @@ function captionBox(s) {
13267
13740
  const h = lines.length * Math.round(size * 1.17) + (subs.length ? 2 + subs.length * Math.round(sub * 1.3) : 0);
13268
13741
  return { x: s.x + s.w / 2 - w / 2, y: s.y + s.h + ICON_CAPTION_GAP, w, h };
13269
13742
  }
13743
+ function captionFootprint(s) {
13744
+ const b = captionBox(s), t = turnOf(s.p);
13745
+ return b && t ? turnedBox(b, mid(s), t) : b;
13746
+ }
13270
13747
  var MARGIN = 40;
13271
13748
  function extent(shapes, texts, conns) {
13272
13749
  const boxes = [...shapes, ...texts, ...conns.flatMap((c) => [...c.pts.map((p) => ({ x: p.x, y: p.y, w: 0, h: 0 })), ...c.label ? [c.label] : []])];
@@ -13803,10 +14280,10 @@ var range = (v) => {
13803
14280
  const m = /^(-?[\d.]+)\.\.(-?[\d.]+)$/.exec(v ?? "");
13804
14281
  return m && Math.abs(+m[1]) < 1e15 && Math.abs(+m[2]) < 1e15 && +m[2] > +m[1] ? [+m[1], +m[2]] : null;
13805
14282
  };
13806
- function drawChart(look, s) {
13807
- const p = s.p, rows = (s.rows ?? []).filter((r) => r.id && r.vals.length), out = [];
14283
+ var pairs = (v) => v === "_" ? [] : v.split(",").map(Number);
14284
+ function plot(s) {
14285
+ const p = s.p, rows = (s.rows ?? []).filter((r) => r.id && r.vals.length);
13808
14286
  const { x, y, w, h } = s;
13809
- const pairs = (v) => v === "_" ? [] : v.split(",").map(Number);
13810
14287
  const xr = range(p.x), cats = !xr && p.x ? p.x.split(",").map((c) => c.trim()) : [];
13811
14288
  const n = xr ? 0 : Math.max(cats.length, ...rows.map((r) => r.vals.length), 1);
13812
14289
  const finite = (v) => Number.isFinite(v);
@@ -13828,6 +14305,43 @@ function drawChart(look, s) {
13828
14305
  const X = (i) => r2(x + bw * (i + 0.5));
13829
14306
  const XV = (v) => xr ? r2(x + (v - xr[0]) / (xr[1] - xr[0]) * w) : 0;
13830
14307
  const base = Y(Math.min(Math.max(0, y0), y1));
14308
+ const bars = rows.filter((r) => r.id === "bars");
14309
+ const group = bw * num2(p["bar.width"], 0.64), each = stacked || !bars.length ? group : group / bars.length;
14310
+ const tops = [];
14311
+ const barBoxes = bars.flatMap((r, k) => r.vals.flatMap((raw, i) => {
14312
+ const q = pairs(raw);
14313
+ if (!q.length) return [];
14314
+ let lo = q.length === 2 ? q[0] : 0, hi = q.length === 2 ? q[1] : q[0];
14315
+ if (stacked && q.length === 1) {
14316
+ lo = tops[i] ?? 0;
14317
+ hi = lo + q[0];
14318
+ tops[i] = hi;
14319
+ }
14320
+ const top = Math.min(Y(lo), Y(hi)), bh = Math.abs(Y(lo) - Y(hi));
14321
+ const bx = r2(X(i) - group / 2 + (stacked ? 0 : k * each) + (each > 6 ? 1 : 0)), ww = r2(each - (each > 6 ? 2 : 0));
14322
+ return [{ r, i, q, lo, hi, top, bh, bx, ww }];
14323
+ }));
14324
+ const points = rows.filter((r) => r.id !== "bars").map((r) => ({ r, pts: r.vals.map((raw, i) => ({ raw, i })).filter((e) => e.raw !== "_").map(({ raw, i }) => {
14325
+ const q = pairs(raw);
14326
+ return q.length >= 2 && xr ? { x: XV(q[0]), y: Y(q[1]), v: q[1], r: q[2] ?? 0, i } : { x: X(i), y: Y(q[0]), v: q[0], r: q[1] ?? 0, i };
14327
+ }) }));
14328
+ return { p, rows, x, y, w, h, xr, cats, n, y0, y1, step, Y, X, XV, bw, base, stacked, barBoxes, points };
14329
+ }
14330
+ function chartMarks(s) {
14331
+ const { barBoxes, points } = plot(s);
14332
+ const marks = barBoxes.map((b) => ({ x: b.bx, y: b.top, w: b.ww, h: Math.max(b.bh, 0.5) }));
14333
+ for (const { r, pts } of points) {
14334
+ if (r.id !== "dots" && r.p.dots !== "1") continue;
14335
+ for (const q of pts) {
14336
+ const rad = r.id === "dots" ? num2(r.p.r, q.r || 4) : 3;
14337
+ marks.push({ x: q.x - rad, y: q.y - rad, w: 2 * rad, h: 2 * rad });
14338
+ }
14339
+ }
14340
+ return marks;
14341
+ }
14342
+ function drawChart(look, s) {
14343
+ const { p, rows, x, y, w, h, xr, cats, n, y0, y1, step, Y, X, XV, bw, base, stacked, barBoxes, points } = plot(s);
14344
+ const out = [];
13831
14345
  const tick = textAttrs(look, p, "tick.", { font: "mono", size: 9, weight: 400, color: "muted" });
13832
14346
  const axis = col(look, p.stroke ?? "ink/0.5"), grid = col(look, p["grid.color"] ?? "ink/0.08"), sw = num2(p.sw, 1);
13833
14347
  const unit = p.unit ?? "", pre = p.prefix ?? "";
@@ -13850,35 +14364,15 @@ function drawChart(look, s) {
13850
14364
  const lab = textAttrs(look, p, "value.", { font: "mono", size: 9, weight: 400, color: "ink" });
13851
14365
  const labels = p.labels === "1";
13852
14366
  const value = (cx2, cy2, v, plus = false) => labels && out.push(`<text x="${cx2}" y="${r2(cy2)}" text-anchor="middle" ${lab.a}>${esc((plus ? "+" : "") + pre + fmt(v) + unit)}</text>`);
13853
- const bars = rows.filter((r) => r.id === "bars");
13854
14367
  const colour = (r, k) => r.p[k] ?? r.p.fill ?? r.p.stroke ?? PALETTE[rows.indexOf(r) % PALETTE.length];
13855
- const group = bw * num2(p["bar.width"], 0.64), each = stacked || !bars.length ? group : group / bars.length;
13856
- const tops = [];
13857
- bars.forEach((r, k) => {
13858
- const rad = num2(p["bar.radius"], 2);
14368
+ const rad = num2(p["bar.radius"], 2);
14369
+ for (const { r, i, q, lo, hi, top, bh, bx, ww } of barBoxes) {
13859
14370
  const outline2 = r.p.stroke && r.p.fill ? ` stroke="${col(look, r.p.stroke)}" stroke-width="${num2(r.p.sw, 1)}"` : "";
13860
- r.vals.forEach((raw, i) => {
13861
- const q = pairs(raw);
13862
- if (!q.length) return;
13863
- let lo = q.length === 2 ? q[0] : 0, hi = q.length === 2 ? q[1] : q[0];
13864
- if (stacked && q.length === 1) {
13865
- lo = tops[i] ?? 0;
13866
- hi = lo + q[0];
13867
- tops[i] = hi;
13868
- }
13869
- const top = Math.min(Y(lo), Y(hi)), bh = Math.abs(Y(lo) - Y(hi));
13870
- const bx = r2(X(i) - group / 2 + (stacked ? 0 : k * each) + (each > 6 ? 1 : 0)), ww = r2(each - (each > 6 ? 2 : 0));
13871
- out.push(`<rect x="${bx}" y="${top}" width="${ww}" height="${r2(Math.max(bh, 0.5))}"${rad && bh > rad * 2 && !stacked ? ` rx="${rad}"` : ""} fill="${col(look, r.p[`fill.${i + 1}`] ?? colour(r, "fill"))}"${outline2}/>`);
13872
- value(r2(bx + ww / 2), hi >= lo ? top - 4 : top + bh + lab.size + 2, q.length === 2 ? hi - lo : q[0], q.length === 2 && lo !== 0 && hi > lo);
13873
- });
13874
- });
13875
- for (const r of rows) {
13876
- if (r.id === "bars") continue;
14371
+ out.push(`<rect x="${bx}" y="${top}" width="${ww}" height="${r2(Math.max(bh, 0.5))}"${rad && bh > rad * 2 && !stacked ? ` rx="${rad}"` : ""} fill="${col(look, r.p[`fill.${i + 1}`] ?? colour(r, "fill"))}"${outline2}/>`);
14372
+ value(r2(bx + ww / 2), hi >= lo ? top - 4 : top + bh + lab.size + 2, q.length === 2 ? hi - lo : q[0], q.length === 2 && lo !== 0 && hi > lo);
14373
+ }
14374
+ for (const { r, pts } of points) {
13877
14375
  const stroke = col(look, colour(r, "stroke")), lw = num2(r.p.sw, 2);
13878
- const pts = r.vals.map((raw, i) => ({ raw, i })).filter((e) => e.raw !== "_").map(({ raw, i }) => {
13879
- const q = pairs(raw);
13880
- return q.length >= 2 && xr ? { x: XV(q[0]), y: Y(q[1]), v: q[1], r: q[2] ?? 0, i } : { x: X(i), y: Y(q[0]), v: q[0], r: q[1] ?? 0, i };
13881
- });
13882
14376
  if (!pts.length) continue;
13883
14377
  const d = pts.map((q) => `${q.x},${q.y}`).join(" ");
13884
14378
  if (r.id === "area") out.push(`<polygon points="${pts[0].x},${base} ${d} ${pts[pts.length - 1].x},${base}" fill="${col(look, r.p.fill ?? colour(r, "stroke") + (/\/[\d.]+$/.test(colour(r, "stroke")) ? "" : "/0.1"))}"/>`);
@@ -14024,6 +14518,14 @@ function hatchDefs() {
14024
14518
  }
14025
14519
  var BLEND = ' style="mix-blend-mode:multiply"';
14026
14520
  var blendOf = (p) => p.blend === "multiply" ? BLEND : "";
14521
+ function faded(p, svg) {
14522
+ const o = Math.min(1, Math.max(0, num2(p.opacity, 1)));
14523
+ return o < 1 ? `<g opacity="${r2(o)}">${svg}</g>` : svg;
14524
+ }
14525
+ function turned(s, svg) {
14526
+ const t = turnOf(s.p);
14527
+ return t ? `<g transform="rotate(${r2(t)} ${r2(s.x + s.w / 2)} ${r2(s.y + s.h / 2)})">${svg}</g>` : svg;
14528
+ }
14027
14529
  var shifted = (s, dx, dy) => ({ ...s, x: s.x + dx, y: s.y + dy, poly: s.poly?.map((q) => ({ x: q.x + dx, y: q.y + dy })) });
14028
14530
  var boxy = (s) => s.shape !== "polygon" && s.shape !== "arc";
14029
14531
  var SHADOW_STEPS = 6;
@@ -14170,8 +14672,8 @@ function outlinePlain(s, attrs) {
14170
14672
  const cx0 = x + w / 2, cy0 = y + h / 2;
14171
14673
  const pt = (deg, k) => `${r2(cx0 + w / 2 * k * Math.sin(deg * Math.PI / 180))},${r2(cy0 - h / 2 * k * Math.cos(deg * Math.PI / 180))}`;
14172
14674
  const sweep = (k, f, t) => {
14173
- const mid = (f + t) / 2, dir = t > f ? 1 : 0, r = `${r2(w / 2 * k)} ${r2(h / 2 * k)}`;
14174
- return `A ${r} 0 0 ${dir} ${pt(mid, k)} A ${r} 0 0 ${dir} ${pt(t, k)}`;
14675
+ const mid2 = (f + t) / 2, dir = t > f ? 1 : 0, r = `${r2(w / 2 * k)} ${r2(h / 2 * k)}`;
14676
+ return `A ${r} 0 0 ${dir} ${pt(mid2, k)} A ${r} 0 0 ${dir} ${pt(t, k)}`;
14175
14677
  };
14176
14678
  const full = Math.abs(a1 - a0) >= 360;
14177
14679
  let d = `M ${pt(a0, 1)} ${sweep(1, a0, a1)}`;
@@ -14256,8 +14758,8 @@ function drawTable(look, s) {
14256
14758
  if (cell === "") return;
14257
14759
  const base = row.kind === "head" ? strong : j === 0 ? first : rest;
14258
14760
  const a = cc ? { ...base, a: base.a.replace(/fill="[^"]*"/, () => `fill="${col(look, cc)}"`) } : base;
14259
- const mid = center && j > 0;
14260
- out.push(`<text x="${r2(s.x + c.x + (mid ? c.w / 2 : 0))}" y="${r2(row.y + row.h / 2 + a.size * 0.36)}"${mid ? ' text-anchor="middle"' : ""} ${a.a}>${esc(cell)}</text>`);
14761
+ const mid2 = center && j > 0;
14762
+ out.push(`<text x="${r2(s.x + c.x + (mid2 ? c.w / 2 : 0))}" y="${r2(row.y + row.h / 2 + a.size * 0.36)}"${mid2 ? ' text-anchor="middle"' : ""} ${a.a}>${esc(cell)}</text>`);
14261
14763
  });
14262
14764
  });
14263
14765
  if (p.grid === "1" && rows.length) for (const c of cols.slice(1)) {
@@ -14380,9 +14882,9 @@ function drawShape(look, s) {
14380
14882
  }
14381
14883
  }
14382
14884
  if (s.shape === "arc" && Math.abs(num2(p.to, 360) - num2(p.from, 0)) < 360) {
14383
- const mid = (num2(p.from, 0) + num2(p.to, 360)) / 2 * (Math.PI / 180), inner = num2(p.inner, 0), k = inner > 0 ? (1 + inner) / 2 : 0.62;
14384
- cxm = r2(cxm + s.w / 2 * k * Math.sin(mid));
14385
- cym = r2(cym - s.h / 2 * k * Math.cos(mid));
14885
+ const mid2 = (num2(p.from, 0) + num2(p.to, 360)) / 2 * (Math.PI / 180), inner = num2(p.inner, 0), k = inner > 0 ? (1 + inner) / 2 : 0.62;
14886
+ cxm = r2(cxm + s.w / 2 * k * Math.sin(mid2));
14887
+ cym = r2(cym - s.h / 2 * k * Math.cos(mid2));
14386
14888
  }
14387
14889
  if (p.ghost) {
14388
14890
  const t = textAttrs(look, p, "ghost.", { font: "mono", size: 32, weight: 600, color: "ink/0.06" });
@@ -14412,16 +14914,16 @@ function drawShape(look, s) {
14412
14914
  if (s.text && p["title.pos"] === "top") {
14413
14915
  const txt = p["title.caps"] === "1" ? s.text.toUpperCase() : s.text;
14414
14916
  const tw = Math.ceil(measureText(look, txt, title.size, title.font, title.weight, title.spacing) + 12);
14415
- const al = p["title.align"], mid = al === "left" ? s.x + 12 + tagRoom + tw / 2 : al === "right" ? s.x + s.w - 12 - tw / 2 : cxm;
14917
+ const al = p["title.align"], mid2 = al === "left" ? s.x + 12 + tagRoom + tw / 2 : al === "right" ? s.x + s.w - 12 - tw / 2 : cxm;
14416
14918
  const own = p["title.dy"] !== void 0 || p["title.fill"] !== void 0;
14417
14919
  const ty = s.y + num2(p["title.dy"], 0), th = own ? Math.max(12, Math.ceil(title.size + 4)) : 12;
14418
14920
  if (p["title.fill"] !== "none") {
14419
- const rect = (fill) => `<rect x="${r2(mid - tw / 2)}" y="${ty + 4}" width="${tw}" height="${th}" rx="2" fill="${fill}"/>`;
14921
+ const rect = (fill) => `<rect x="${r2(mid2 - tw / 2)}" y="${ty + 4}" width="${tw}" height="${th}" rx="2" fill="${fill}"/>`;
14420
14922
  out.push(rect(col(look, p["title.fill"] ?? look.canvas.paper ?? "paper")));
14421
14923
  const inside3 = p["title.fill"] === void 0 && ty + 4 >= s.y + num2(p.sw, 1) / 2 && !p.offset && !blendOf(p);
14422
14924
  if (inside3 && p.fill && p.fill !== "none") out.push(rect(col(look, p.fill)));
14423
14925
  }
14424
- out.push(`<text x="${mid}" y="${own ? r2(ty + 4 + th / 2 + title.size * 0.36) : s.y + 13}" text-anchor="middle" ${title.a}>${esc(txt)}</text>`);
14926
+ out.push(`<text x="${mid2}" y="${own ? r2(ty + 4 + th / 2 + title.size * 0.36) : s.y + 13}" text-anchor="middle" ${title.a}>${esc(txt)}</text>`);
14425
14927
  } else if (s.text || p.sub) {
14426
14928
  const lines = s.text ? (p["title.caps"] === "1" ? s.text.toUpperCase() : s.text).split("\n") : [];
14427
14929
  const lh = Math.round(title.size * 1.17);
@@ -14597,6 +15099,25 @@ function marker(kind, tip, from, sw, stroke, paper, k = 1, ring2 = stroke) {
14597
15099
  return { svg: "", trim: 0 };
14598
15100
  case "open":
14599
15101
  return { svg: `<path d="M ${at(10 * k, 5 * k)} L ${at(0, 0)} L ${at(10 * k, -5 * k)}" ${line}/>`, trim: 0 };
15102
+ // swept back, with a notch where the line goes in
15103
+ case "stealth":
15104
+ return { svg: `<polygon points="${at(0, 0)} ${at(12 * k, 5 * k)} ${at(8 * k, 0)} ${at(12 * k, -5 * k)}" fill="${stroke}"/>`, trim: 8 * k };
15105
+ // two heads one behind the other
15106
+ case "double":
15107
+ return { svg: `<polygon points="${at(0, 0)} ${at(10 * k, 4 * k)} ${at(10 * k, -4 * k)}" fill="${stroke}"/><polygon points="${at(7 * k, 0)} ${at(17 * k, 4 * k)} ${at(17 * k, -4 * k)}" fill="${stroke}"/>`, trim: 14 * k };
15108
+ // a harpoon: one barb, on the left of the way the line runs
15109
+ case "half":
15110
+ return { svg: `<path d="M ${at(10 * k, -5 * k)} L ${at(0, 0)}" ${line}/>`, trim: 0 };
15111
+ case "square":
15112
+ return { svg: `<polygon points="${at(0, 4.5 * k)} ${at(9 * k, 4.5 * k)} ${at(9 * k, -4.5 * k)} ${at(0, -4.5 * k)}" ${hollow}/>`, trim: 9 * k };
15113
+ case "square-solid":
15114
+ return { svg: `<polygon points="${at(0, 4.5 * k)} ${at(9 * k, 4.5 * k)} ${at(9 * k, -4.5 * k)} ${at(0, -4.5 * k)}" fill="${stroke}" stroke="${stroke}" stroke-width="${sw}" stroke-linejoin="round"/>`, trim: 9 * k };
15115
+ // a bar across the very end: the line stops here (blocks, inhibits)
15116
+ case "bar":
15117
+ return { svg: `<path d="M ${at(0, 6 * k)} L ${at(0, -6 * k)}" ${line}/>`, trim: 0 };
15118
+ // an X over the end: cancelled, destroyed
15119
+ case "cross":
15120
+ return { svg: `<path d="M ${at(0, 4.5 * k)} L ${at(9 * k, -4.5 * k)} M ${at(0, -4.5 * k)} L ${at(9 * k, 4.5 * k)}" ${line}/>`, trim: 0 };
14600
15121
  case "triangle":
14601
15122
  return { svg: `<polygon points="${at(0, 0)} ${at(11 * k, 6 * k)} ${at(11 * k, -6 * k)}" ${hollow}/>`, trim: 11 * k };
14602
15123
  // a stop on a route: a ring the line runs into, in the colour of the boxes' outline
@@ -14647,23 +15168,32 @@ function cutEnd(pts, dist) {
14647
15168
  }
14648
15169
  return pts.slice(0, 2);
14649
15170
  }
15171
+ function seeThrough(c) {
15172
+ if (!c.startsWith("rgba(") || !c.endsWith(")")) return null;
15173
+ const v = c.slice(5, -1).split(",").map((x) => x.trim());
15174
+ if (v.length !== 4 || v.some((x) => x === "" || isNaN(+x))) return null;
15175
+ const a = +v[3];
15176
+ return a < 1 ? { solid: `rgb(${v[0]},${v[1]},${v[2]})`, a } : null;
15177
+ }
14650
15178
  function drawConn(look, c) {
14651
15179
  if (c.pts.length < 2) return "";
14652
15180
  const p = c.p, sw = num2(p.sw, 1.2), stroke = col(look, p.stroke ?? "muted");
14653
15181
  const n = c.pts.length, paper = col(look, look.canvas.paper ?? "paper");
14654
15182
  const hFrom = c.curve ? backAlong(c.pts, 10) : c.pts[n - 2], tFrom = c.curve ? backAlong([...c.pts].reverse(), 10) : c.pts[1];
14655
- const hk = Math.max(0.5, Math.min(num2(p["head.size"], 1), 4)), ringCol = col(look, p["stop.color"] ?? p.stroke ?? "muted");
14656
- const head = marker(c.headM, c.pts[n - 1], hFrom, sw, stroke, paper, hk, ringCol), tail = marker(c.tailM, c.pts[0], tFrom, sw, stroke, paper, hk, ringCol);
15183
+ const see = seeThrough(stroke), ink = see ? see.solid : stroke;
15184
+ const hk = Math.max(0.5, Math.min(num2(p["head.size"], 1), 4)), ringCol = p["stop.color"] ? col(look, p["stop.color"]) : ink;
15185
+ const head = marker(c.headM, c.pts[n - 1], hFrom, sw, ink, paper, hk, ringCol), tail = marker(c.tailM, c.pts[0], tFrom, sw, ink, paper, hk, ringCol);
14657
15186
  const d = c.curve ? pathD(cutEnd([...cutEnd(c.pts, head.trim)].reverse(), tail.trim).reverse(), 0, 0, 0) : pathD(c.pts, c.ortho ? num2(p.radius, 8) : 0, head.trim, tail.trim);
14658
15187
  const cap = p.cap === "round" ? ' stroke-linecap="round" stroke-linejoin="round"' : "";
14659
- const a = `fill="none" stroke="${stroke}" stroke-width="${sw}"${p.dash && p.dash !== "none" ? ` stroke-dasharray="${esc(p.dash)}"` : ""}${cap}${blendOf(p)}`;
15188
+ const a = `fill="none" stroke="${ink}" stroke-width="${sw}"${p.dash && p.dash !== "none" ? ` stroke-dasharray="${esc(p.dash)}"` : ""}${cap}${see ? "" : blendOf(p)}`;
14660
15189
  let s = roughOf(p) ? sketchSvg(d, a, roughOf(p)) : `<path d="${d}" ${a}/>`;
14661
- if (p.casing && p.casing !== "none") s = `<path d="${d}" fill="none" stroke="${col(look, p.casing)}" stroke-width="${r2(sw + 2 * num2(p["casing.width"], 2.5))}"${cap}/>
14662
- ` + s;
14663
15190
  if (p.double && p.double !== "none") s += `
14664
15191
  <path d="${d}" fill="none" stroke="${col(look, p.double)}" stroke-width="${num2(p["double.sw"], r2(sw * 0.42))}"${cap}/>`;
14665
15192
  if (head.svg) s += "\n" + head.svg;
14666
15193
  if (tail.svg) s += "\n" + tail.svg;
15194
+ if (see) s = `<g opacity="${see.a}"${blendOf(p)}>${s}</g>`;
15195
+ if (p.casing && p.casing !== "none") s = `<path d="${d}" fill="none" stroke="${col(look, p.casing)}" stroke-width="${r2(sw + 2 * num2(p["casing.width"], 2.5))}"${cap}/>
15196
+ ` + s;
14667
15197
  return s;
14668
15198
  }
14669
15199
  function drawLabel(look, c) {
@@ -14679,15 +15209,18 @@ function drawLabel(look, c) {
14679
15209
  }
14680
15210
  function drawText(look, t) {
14681
15211
  const a = textAttrs(look, t.p, "", { font: "sans", size: 12, weight: 400, color: "ink" });
14682
- const anchor = t.p.anchor && t.p.anchor !== "start" ? ` text-anchor="${esc(t.p.anchor)}"` : "";
14683
- const rot = num2(t.p.rotate, 0);
14684
- const lines = t.text.split("\n"), blend = blendOf(t.p);
14685
- let body = lines.map((l, i) => `<text x="${t.ax}" y="${r2(t.ay + i * a.size * 1.3)}"${anchor} ${a.a}${blend}>${esc(l)}</text>`).join("\n");
15212
+ const boxed = !!t.lines, al = t.p.align, bw = num2(t.p.width, 0);
15213
+ const ta = boxed ? al === "center" ? "middle" : al === "right" ? "end" : "start" : t.p.anchor;
15214
+ const anchor = ta && ta !== "start" ? ` text-anchor="${esc(ta)}"` : "";
15215
+ const x0 = boxed ? t.ax + (al === "center" ? bw / 2 : al === "right" ? bw : 0) : t.ax;
15216
+ const rot = turnOf(t.p);
15217
+ const lines = t.lines ?? t.text.split("\n"), blend = blendOf(t.p), y0 = t.ay + num2(t.p.dy, 0);
15218
+ let body = lines.map((l, i) => `<text x="${x0}" y="${r2(y0 + i * a.size * 1.3)}"${anchor} ${a.a}${blend}>${esc(l)}</text>`).join("\n");
14686
15219
  if (t.p.echo && t.p.echo !== "none") {
14687
15220
  const dx = num2(t.p["echo.dx"], 3), dy = num2(t.p["echo.dy"], 3), ea = a.a.replace(/fill="[^"]*"/, () => `fill="${col(look, t.p.echo)}"`);
14688
- body = lines.map((l, i) => `<text x="${t.ax + dx}" y="${r2(t.ay + dy + i * a.size * 1.3)}"${anchor} ${ea}>${esc(l)}</text>`).join("\n") + "\n" + body;
15221
+ body = lines.map((l, i) => `<text x="${x0 + dx}" y="${r2(y0 + dy + i * a.size * 1.3)}"${anchor} ${ea}>${esc(l)}</text>`).join("\n") + "\n" + body;
14689
15222
  }
14690
- return rot === 90 || rot === -90 ? `<g transform="rotate(${rot} ${t.ax} ${t.ay})">${body}</g>` : body;
15223
+ return rot ? `<g transform="rotate(${r2(rot)} ${t.ax} ${t.ay})">${body}</g>` : body;
14691
15224
  }
14692
15225
  function rgbOf(look, v, over2) {
14693
15226
  const c = color(look, v);
@@ -14762,7 +15295,7 @@ function footed(c, shapes) {
14762
15295
  if (Math.abs(q.x - n.x) > 0.5 || n.y < q.y) continue;
14763
15296
  for (const s of shapes) {
14764
15297
  const d = num2(s.p.depth, 0);
14765
- if (d > 0 && !s.back && Math.abs(q.y - (s.y + s.h)) < 1 && q.x > s.x && q.x < s.x + s.w && n.y - q.y > d + 6) {
15298
+ if (d > 0 && !s.back && !turnOf(s.p) && Math.abs(q.y - (s.y + s.h)) < 1 && q.x > s.x && q.x < s.x + s.w && n.y - q.y > d + 6) {
14766
15299
  q.y += d;
14767
15300
  moved = true;
14768
15301
  break;
@@ -14772,9 +15305,24 @@ function footed(c, shapes) {
14772
15305
  return moved ? { ...c, pts } : c;
14773
15306
  }
14774
15307
  var TEXT_STYLE = "font-variant-ligatures:none;text-rendering:geometricPrecision";
15308
+ var PAGE_MARKS = ["dots", "grid", "lines", "cross", "iso", "diag", "graph", "hex", "bars", "feed"];
15309
+ function pageMarks(look) {
15310
+ const cv = { ...look.canvas }, paper = rgbOf(look, cv.paper ?? "paper");
15311
+ if (!paper) return cv;
15312
+ for (const k of PAGE_MARKS) {
15313
+ const v = cv[k];
15314
+ if (!v || v === "none") continue;
15315
+ const i = v.lastIndexOf("/");
15316
+ if (i <= 0) continue;
15317
+ const rgb = rgbOf(look, v.slice(0, i));
15318
+ if (!rgb || contrast(rgb, paper) >= 3) continue;
15319
+ cv[k] = (contrast([255, 255, 255], paper) >= contrast([0, 0, 0], paper) ? "#ffffff" : "#000000") + v.slice(i);
15320
+ }
15321
+ return cv;
15322
+ }
14775
15323
  function renderBody(sc, background = true) {
14776
15324
  sc = legible(sc);
14777
- const look = sc.look, cv = look.canvas;
15325
+ const look = sc.look, cv = pageMarks(look);
14778
15326
  const out = [];
14779
15327
  R = { amt: Math.max(0, Math.min(num2(cv.sketch, 0), 4)), defs: /* @__PURE__ */ new Map() };
14780
15328
  if (background) out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" fill="${col(look, cv.paper ?? "paper")}"/>`);
@@ -14832,15 +15380,15 @@ function renderBody(sc, background = true) {
14832
15380
  out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="26" height="${sc.h}" fill="url(#fd-feed-l)"/><rect class="fd-page" x="${sc.x + sc.w - 26}" y="${sc.y}" width="26" height="${sc.h}" fill="url(#fd-feed-r)"/>`);
14833
15381
  out.push(`<path class="fd-page" d="M ${sc.x + 26},${sc.y} v ${sc.h} M ${sc.x + sc.w - 26},${sc.y} v ${sc.h}" stroke="${c}" stroke-width="1" stroke-dasharray="2 3" fill="none"/>`);
14834
15382
  }
14835
- for (const s of sc.shapes) if (s.back) out.push(drawShape(look, s));
15383
+ for (const s of sc.shapes) if (s.back) out.push(faded(s.p, turned(s, drawShape(look, s))));
14836
15384
  const conns = sc.shapes.some((s) => num2(s.p.depth, 0) > 0) ? sc.conns.map((c) => footed(c, sc.shapes)) : sc.conns;
14837
15385
  const under = conns.filter((c) => c.p.layer !== "front"), over2 = conns.filter((c) => c.p.layer === "front");
14838
- for (const c of under) out.push(drawConn(look, c));
14839
- for (const c of under) if (c.label) out.push(drawLabel(look, c));
14840
- for (const s of sc.shapes) if (!s.back) out.push(drawShape(look, s));
14841
- for (const c of over2) out.push(drawConn(look, c));
14842
- for (const c of over2) if (c.label) out.push(drawLabel(look, c));
14843
- for (const t of sc.texts) out.push(drawText(look, t));
15386
+ for (const c of under) out.push(faded(c.p, drawConn(look, c)));
15387
+ for (const c of under) if (c.label) out.push(faded(c.p, drawLabel(look, c)));
15388
+ for (const s of sc.shapes) if (!s.back) out.push(faded(s.p, turned(s, drawShape(look, s))));
15389
+ for (const c of over2) out.push(faded(c.p, drawConn(look, c)));
15390
+ for (const c of over2) if (c.label) out.push(faded(c.p, drawLabel(look, c)));
15391
+ for (const t of sc.texts) out.push(faded(t.p, drawText(look, t)));
14844
15392
  if (background && num2(cv.grain, 0) > 0) {
14845
15393
  out.push(`<defs><filter id="fd-grain" x="0" y="0" width="100%" height="100%"><feTurbulence type="fractalNoise" baseFrequency="1.1" numOctaves="2" seed="4"/><feColorMatrix values="0 0 0 0 .25 0 0 0 0 .22 0 0 0 0 .2 0 0 0 .5 -.2"/></filter></defs>`);
14846
15394
  out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" filter="url(#fd-grain)" opacity="${Math.min(1, num2(cv.grain, 0))}" pointer-events="none"/>`);
@@ -14863,6 +15411,29 @@ var hasPt = (b, p) => p.x >= b.x && p.x <= b.x + b.w && p.y >= b.y && p.y <= b.y
14863
15411
  var inset = (b, n) => ({ x: b.x + n, y: b.y + n, w: b.w - 2 * n, h: b.h - 2 * n });
14864
15412
  var name = (c) => c.id.startsWith("_") ? `${c.a.raw} ${c.head ? "->" : "--"} ${c.b.raw}` : c.id;
14865
15413
  var tiny = (s) => Math.min(s.w, s.h) <= 12;
15414
+ var turned2 = (s) => turnOf(s.p) !== 0;
15415
+ var local = (s, p) => turned2(s) ? turnPt(p, { x: s.x + s.w / 2, y: s.y + s.h / 2 }, -turnOf(s.p)) : p;
15416
+ var corners = (b, turn = 0) => {
15417
+ const q = [{ x: b.x, y: b.y }, { x: b.x + b.w, y: b.y }, { x: b.x + b.w, y: b.y + b.h }, { x: b.x, y: b.y + b.h }];
15418
+ return turn ? q.map((p) => turnPt(p, { x: b.x + b.w / 2, y: b.y + b.h / 2 }, turn)) : q;
15419
+ };
15420
+ function meets(b, bTurn, s, pad) {
15421
+ if (!bTurn && !turned2(s)) return inter(b, s, pad);
15422
+ const P = corners(inset(b, pad), bTurn), Q = corners(s, turnOf(s.p));
15423
+ for (const [A, B] of [[P[0], P[1]], [P[1], P[2]], [Q[0], Q[1]], [Q[1], Q[2]]]) {
15424
+ const ax = B.x - A.x, ay = B.y - A.y, along = (p2) => p2.x * ax + p2.y * ay;
15425
+ const p = P.map(along), q = Q.map(along);
15426
+ if (Math.max(...p) <= Math.min(...q) || Math.max(...q) <= Math.min(...p)) return false;
15427
+ }
15428
+ return true;
15429
+ }
15430
+ var hasPtIn = (s, p) => hasPt(s, local(s, p));
15431
+ function textFrame(t) {
15432
+ const f = t.frame, turn = turnOf(t.p);
15433
+ if (!f) return [t, 0];
15434
+ const m = turnPt({ x: f.x + f.w / 2, y: f.y + f.h / 2 }, { x: t.ax, y: t.ay }, turn);
15435
+ return [{ x: m.x - f.w / 2, y: m.y - f.h / 2, w: f.w, h: f.h }, turn];
15436
+ }
14866
15437
  var isLine = (s) => !!s.poly && s.p.open === "1";
14867
15438
  function rgba(look, v) {
14868
15439
  const c = color(look, v);
@@ -14895,7 +15466,12 @@ function check(sc) {
14895
15466
  const front = sc.shapes.filter((s) => !s.back);
14896
15467
  for (let i = 0; i < front.length; i++) for (let j = i + 1; j < front.length; j++) {
14897
15468
  const a = front[i], b = front[j];
14898
- if (!inter(a, b, 0.5) || contains(a, b) || contains(b, a) || a.p.overlap === "ok" || b.p.overlap === "ok") continue;
15469
+ if (a.p.overlap === "ok" || b.p.overlap === "ok") continue;
15470
+ if (turned2(a) || turned2(b)) {
15471
+ if (meets(a, turnOf(a.p), b, 0.5) && !corners(b, turnOf(b.p)).every((p) => hasPtIn(a, p)) && !corners(a, turnOf(a.p)).every((p) => hasPtIn(b, p))) warn(b.line, `${b.id} overlaps ${a.id}; move one of them`);
15472
+ continue;
15473
+ }
15474
+ if (!inter(a, b, 0.5) || contains(a, b) && a.shape !== "chart" || contains(b, a) && b.shape !== "chart") continue;
14899
15475
  const ox = Math.min(a.x + a.w, b.x + b.w) - Math.max(a.x, b.x), oy = Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y);
14900
15476
  warn(b.line, `${b.id} overlaps ${a.id} by ${Math.round(Math.min(ox, oy))}px; move one of them`);
14901
15477
  }
@@ -14904,7 +15480,7 @@ function check(sc) {
14904
15480
  for (const s of front) {
14905
15481
  if (s.rows || s.shape === "legend" || s.shape === "chart" || s.p["title.pos"] === "top") continue;
14906
15482
  const cxs = s.x + s.w / 2, cys = s.y + s.h / 2, at = sc.shapes.indexOf(s);
14907
- const below = fillOf(s) ? void 0 : sc.shapes.slice(0, at).reverse().find((o) => !o.back && !o.rows && fillOf(o) && cxs >= o.x && cxs <= o.x + o.w && cys >= o.y && cys <= o.y + o.h);
15483
+ const below = fillOf(s) ? void 0 : sc.shapes.slice(0, at).reverse().find((o) => !o.back && !o.rows && fillOf(o) && hasPtIn(o, { x: cxs, y: cys }));
14908
15484
  const bg = fillOf(s) ?? (below ? fillOf(below) : paperRgb);
14909
15485
  for (const [what, has, key, dflt] of [["text", s.text, "title.color", "ink"], ["second line", s.p.sub, "sub.color", "muted"]]) {
14910
15486
  const fg = rgba(sc.look, s.p[key] ?? dflt);
@@ -14913,7 +15489,7 @@ function check(sc) {
14913
15489
  }
14914
15490
  for (const t of sc.texts) {
14915
15491
  const mx = t.x + t.w / 2, my = t.y + t.h / 2;
14916
- const under = [...sc.shapes].reverse().find((s) => !s.rows && s.shape !== "legend" && s.shape !== "chart" && fillOf(s) && mx >= s.x && mx <= s.x + s.w && my >= s.y && my <= s.y + s.h);
15492
+ const under = [...sc.shapes].reverse().find((s) => !s.rows && s.shape !== "legend" && s.shape !== "chart" && fillOf(s) && hasPtIn(s, { x: mx, y: my }));
14917
15493
  const fg = rgba(sc.look, t.p.color ?? "ink");
14918
15494
  if (!fg || fg[3] <= 0.3) continue;
14919
15495
  const bg = under ? fillOf(under) : paperRgb;
@@ -14953,14 +15529,14 @@ function check(sc) {
14953
15529
  const seen = /* @__PURE__ */ new Set();
14954
15530
  for (let i = 0; i < front.length; i++) for (let j = i + 1; j < front.length; j++) {
14955
15531
  const a = front[i], b = front[j];
14956
- if (tiny(a) || tiny(b) || contains(a, b) || contains(b, a) || a.p.overlap === "ok" || b.p.overlap === "ok") continue;
14957
- const pairs = [
15532
+ if (tiny(a) || tiny(b) || turned2(a) || turned2(b) || contains(a, b) || contains(b, a) || a.p.overlap === "ok" || b.p.overlap === "ok") continue;
15533
+ const pairs2 = [
14958
15534
  ["top edges", a.y, b.y],
14959
15535
  ["vertical centres", a.y + a.h / 2, b.y + b.h / 2],
14960
15536
  ["left edges", a.x, b.x],
14961
15537
  ["horizontal centres", a.x + a.w / 2, b.x + b.w / 2]
14962
15538
  ];
14963
- for (const [what, va, vb] of pairs) {
15539
+ for (const [what, va, vb] of pairs2) {
14964
15540
  const d = Math.abs(va - vb);
14965
15541
  if (d > 0 && d <= 3 && !seen.has(a.id + b.id)) {
14966
15542
  seen.add(a.id + b.id);
@@ -14976,8 +15552,8 @@ function check(sc) {
14976
15552
  for (const s of front) {
14977
15553
  if (c.p.layer === "back" || c.p.layer === "front") break;
14978
15554
  if (s.id === c.a.id || s.id === c.b.id || tiny(s) || hit.has(s.id) || isLine(s)) continue;
14979
- if (hasPt(s, c.pts[0]) || hasPt(s, c.pts[c.pts.length - 1])) continue;
14980
- if (segHits(A2, B, inset(s, 1))) {
15555
+ if (hasPtIn(s, c.pts[0]) || hasPtIn(s, c.pts[c.pts.length - 1])) continue;
15556
+ if (segHits(local(s, A2), local(s, B), inset(s, 1))) {
14981
15557
  hit.add(s.id);
14982
15558
  warn(c.line, `${name(c)} passes through ${s.id}; route around it with from=/to= sides or via=x,y`);
14983
15559
  }
@@ -14986,9 +15562,9 @@ function check(sc) {
14986
15562
  const first = c.pts[0], last = c.pts[c.pts.length - 1];
14987
15563
  const l = c.label;
14988
15564
  if (!l) continue;
14989
- for (const s of front) if (!tiny(s) && !isLine(s) && inter(l, s, 1)) warn(c.line, `label "${l.text}" of ${name(c)} collides with ${s.id}; shorten it, move things apart, or place it with lpos=x,y or lside=below|left`);
15565
+ for (const s of front) if (!tiny(s) && !isLine(s) && meets(l, 0, s, 1)) warn(c.line, `label "${l.text}" of ${name(c)} collides with ${s.id}; shorten it, move things apart, or place it with lpos=x,y or lside=below|left`);
14990
15566
  for (const z of sc.shapes) {
14991
- if (!z.back || !inter(l, z, 0) || contains(z, l)) continue;
15567
+ if (!z.back || !meets(l, 0, z, 0) || corners(l).every((p) => hasPtIn(z, p))) continue;
14992
15568
  warn(c.line, `label "${l.text}" of ${name(c)} sits on the border of ${z.id}; place it on a clear stretch of the line with lpos=x,y`);
14993
15569
  }
14994
15570
  for (let i = 0; i < c.pts.length - 1; i++) {
@@ -15038,7 +15614,9 @@ function check(sc) {
15038
15614
  }
15039
15615
  }
15040
15616
  for (const t of sc.texts) {
15041
- for (const s of front) if (!tiny(s) && s.shape !== "chart" && s.p.overlap !== "ok" && t.p.overlap !== "ok" && inter(t, s, 1) && !contains(s, t)) warn(t.line, `text ${t.id} overlaps ${s.id}`);
15617
+ const [tb, tt] = textFrame(t), tc = corners(tb, tt);
15618
+ for (const s of front) if (!tiny(s) && s.shape !== "chart" && s.p.overlap !== "ok" && t.p.overlap !== "ok" && meets(tb, tt, s, 1) && !tc.every((p) => hasPtIn(s, p))) warn(t.line, `text ${t.id} overlaps ${s.id}`);
15619
+ for (const s of front) if (s.shape === "chart" && !turned2(s) && s.p.overlap !== "ok" && t.p.overlap !== "ok" && chartMarks(s).some((m) => meets(tb, tt, { ...s, ...m, p: {} }, 1))) warn(t.line, `text ${t.id} sits on the bars or dots of chart ${s.id}; move it to a clear part of the chart or outside it`);
15042
15620
  for (const o of sc.texts) if (o.line > t.line && inter(t, o, 1) && t.p.overlap !== "ok" && o.p.overlap !== "ok") warn(o.line, `text ${o.id} overlaps text ${t.id}`);
15043
15621
  }
15044
15622
  if (sc.canvasSize && sc.canvasLine) hint(sc.canvasLine, "the canvas has no size any more: the picture is as big as what is drawn, plus a margin; remove WxH from this line");
@@ -15384,10 +15962,10 @@ function skillNotes(root2, dir, home = homedir2()) {
15384
15962
  const version = packageVersion(root2), found = installedSkills(dir, home), notes = [];
15385
15963
  const from = (fs) => [...new Set(fs.map((f) => f.version || "0.2.0 or earlier"))].join(", ");
15386
15964
  const old = found.filter((f) => !f.version || compareVersions(f.version, version) < 0);
15387
- const local = old.filter((f) => !f.global), global = old.filter((f) => f.global);
15388
- if (local.length) {
15389
- const files = local.map((f) => relative2(resolve3(dir), f.file) || f.file).join(", ");
15390
- notes.push(`Note: this repository's FastDraw instructions (${files}) are from version ${from(local)}; this fastdraw is ${version}. Tell the person, and to update them run in the repository: npx fastdraw@latest setup ${[...new Set(local.map((f) => f.target))].join(" ")}`);
15965
+ const local2 = old.filter((f) => !f.global), global = old.filter((f) => f.global);
15966
+ if (local2.length) {
15967
+ const files = local2.map((f) => relative2(resolve3(dir), f.file) || f.file).join(", ");
15968
+ notes.push(`Note: this repository's FastDraw instructions (${files}) are from version ${from(local2)}; this fastdraw is ${version}. Tell the person, and to update them run in the repository: npx fastdraw@latest setup ${[...new Set(local2.map((f) => f.target))].join(" ")}`);
15391
15969
  }
15392
15970
  if (global.length) {
15393
15971
  notes.push(`Note: the FastDraw skill in ${global[0].file.replace(home, "~")} is from version ${from(global)}; this fastdraw is ${version}. Tell the person, and to update it run: npx fastdraw@latest setup claude --global`);