Story 023's three stem themes drawn: trellis, tendril and garland, the boxes kept and the lines regrown as stems of the flora (#132)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
9368e5a84d
commit
922c70927f
11 changed files with 632 additions and 76 deletions
|
|
@ -103,7 +103,9 @@ are to items the same person holds; another's is shown as a bare id.
|
|||
| Generation | One row of a chart, numbered from the subject: −1 parents, +1 children |
|
||||
| Brief name | The shortest form a chart may call someone: the record's `short`, else `names.Brief` of the name, the name before any comma or bracket cut to its first word and surname (story 017) |
|
||||
| Size | How much of a name a chart's boxes carry: `brief` or `full` (`genealogy -size`) |
|
||||
| Theme | One drawing of a chart (`genealogy -theme`): `boxes`, the drop-line chart, or `vine` |
|
||||
| Theme | One drawing of a chart (`genealogy -theme`): `boxes`, the drop-line chart; `vine`; or a stem theme, `trellis`, `tendril` or `garland` (story 023) |
|
||||
| Stem tie | An edge of the chart drawn as a stem of the flora, masked in the link ink as the margin is, in place of the straight drop line: `trellis` draws every line so, a leaf or two along the longer ones; `tendril` curls each stem where it meets a box; `garland` ends a child's stem in a bud and a spouse's in a blossom |
|
||||
| Decoration | A small motif from the flora on a box, never over its text: `tendril`'s sprig from the top-right corner, `garland`'s quarter-flower at the top-left clipped to the box as a tile's corner is |
|
||||
| Width | The widest the boxes drawing may be, in px (`genealogy -width`; the pages give the column's width): a chart that would be wider is cut to it, never scaled down (story 024) |
|
||||
| Cut | A reduction of the hourglass to its width, one notch at a time: a generation of descendants below the children, then siblings from the longer side, then the youngest children, then a generation of ancestors above the parents; what is cut is counted in a more box. Nothing left to cut, the chart is drawn as it is |
|
||||
| More box | A box standing for the people a cut took off a row, hung where they would hang: its count, "+4", over their kind, *older siblings*, *younger siblings* or *children*; no link, no id |
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ tasks:
|
|||
vars:
|
||||
IDS: '{{.IDS | default "0 1 2 3 4 5 6"}}'
|
||||
cmds:
|
||||
- go run ./cmd/genealogy -archive {{.MIRROR}} -out charts {{.IDS}}
|
||||
- go run ./cmd/genealogy -archive {{.MIRROR}} -theme boxes,trellis,tendril,garland -out charts {{.IDS}}
|
||||
- cmd: xdg-open charts/review.html
|
||||
ignore_error: true
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ tasks:
|
|||
- go run ./cmd/life-weaver brand docs/brand
|
||||
- cp docs/brand/favicon.svg docs/favicon.svg
|
||||
- task-plus md2html --file docs/brand.md --dst docs
|
||||
- go run ./cmd/genealogy -people internal/chart/testdata/people -theme boxes,vine -out docs/research/charts 0 3 7
|
||||
- go run ./cmd/genealogy -people internal/chart/testdata/people -theme boxes,vine,trellis,tendril,garland -out docs/research/charts 0 3 7
|
||||
- go run ./cmd/genealogy -people internal/chart/testdata/people -theme boxes -size full -out docs/research/charts/full 7
|
||||
- go run ./cmd/genealogy -people internal/chart/testdata/people -theme boxes,vine -up 1 -down 1 -out docs/research/charts/near 3
|
||||
- task-plus md2html --file research/charts.md --dst docs/research
|
||||
|
|
|
|||
1
changes/132.added.md
Normal file
1
changes/132.added.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
The three stem themes of story 023 (#132), drawn: `genealogy -theme trellis,tendril,garland`, each the drop-line chart with its boxes kept byte for byte and its lines regrown as stems of the flora by `ornament.Grow`, masked in the link ink as the margin is. `trellis`: every bar, rail, spouse tie and influence a stem as wide as its line, a leaf or two along the longer ones; `tendril`: each stem curling where it meets a box, an influence a tendril at both ends, a sprig from each box's corner; `garland`: a bud where a stem reaches a child, a blossom where the tie reaches a spouse, a quarter-flower at each box's corner as the tiles have. Side by side with `boxes` on the review page, in `task genealogy:demo` and in `research/charts.md`, to be ranked by eye
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// genealogy draws charts of the kin around people in the register, to a
|
||||
// directory, with a page laying them out to judge by eye (story 014).
|
||||
//
|
||||
// genealogy [-archive DIR | -people DIR] [-up N] [-down N] [-size brief|full] [-theme boxes|vine[,…]] [-out DIR] ID...
|
||||
// genealogy [-archive DIR | -people DIR] [-up N] [-down N] [-size brief|full] [-theme boxes|vine|trellis|tendril|garland[,…]] [-out DIR] ID...
|
||||
//
|
||||
// The hourglass chart of each subject, ancestors up generations above and
|
||||
// descendants down generations below, in each theme named, as
|
||||
|
|
@ -47,7 +47,7 @@ func run(args []string, stdout io.Writer) error {
|
|||
up := fs.Int("up", 2, "generations of ancestors")
|
||||
down := fs.Int("down", 2, "generations of descendants")
|
||||
size := fs.String("size", string(chart.Brief), "how much of a name a box carries: brief or full")
|
||||
theme := fs.String("theme", "boxes", "the drawings, comma-separated: boxes, vine")
|
||||
theme := fs.String("theme", "boxes", "the drawings, comma-separated: boxes, vine, trellis, tendril, garland")
|
||||
width := fs.Int("width", 0, "the widest the boxes drawing may be, px: a wider chart is cut to it; 0 unbounded")
|
||||
out := fs.String("out", "charts", "output directory")
|
||||
if err := fs.Parse(args); err != nil {
|
||||
|
|
@ -64,7 +64,7 @@ func run(args []string, stdout io.Writer) error {
|
|||
for _, name := range strings.Split(*theme, ",") {
|
||||
fn, ok := themes[name]
|
||||
if !ok {
|
||||
return fmt.Errorf("theme %q: want boxes or vine", name)
|
||||
return fmt.Errorf("theme %q: want boxes, vine, trellis, tendril or garland", name)
|
||||
}
|
||||
if !slices.ContainsFunc(draw, func(d drawing) bool { return d.name == name }) {
|
||||
draw = append(draw, drawing{name, fn})
|
||||
|
|
@ -132,7 +132,10 @@ type drawing struct {
|
|||
fn func(chart.Chart) []byte
|
||||
}
|
||||
|
||||
var themes = map[string]func(chart.Chart) []byte{"boxes": chart.SVG, "vine": chart.Vine}
|
||||
var themes = map[string]func(chart.Chart) []byte{
|
||||
"boxes": chart.SVG, "vine": chart.Vine,
|
||||
"trellis": chart.Trellis, "tendril": chart.Tendril, "garland": chart.Garland, // story 023
|
||||
}
|
||||
|
||||
type reviewed struct {
|
||||
Name, Years string
|
||||
|
|
|
|||
|
|
@ -59,6 +59,27 @@ func TestRunRefusesAnUnknownThemeOrSizeBeforeWriting(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// The three stem themes of story 023 draw beside boxes, each its own file.
|
||||
func TestRunDrawsTheStemThemes(t *testing.T) {
|
||||
out := filepath.Join(t.TempDir(), "charts")
|
||||
if err := run([]string{"-people", fixtures, "-out", out, "-theme", "boxes,trellis,tendril,garland", "0"}, &bytes.Buffer{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, name := range []string{"trellis", "tendril", "garland"} {
|
||||
svg, err := os.ReadFile(filepath.Join(out, "0-hourglass-"+name+".svg"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(string(svg), "<mask") || !strings.Contains(string(svg), `class="box self`) {
|
||||
t.Errorf("%s: want the boxes and a mask of stems", name)
|
||||
}
|
||||
}
|
||||
review, _ := os.ReadFile(filepath.Join(out, "review.html"))
|
||||
if strings.Count(string(review), "<figure>") != 4 {
|
||||
t.Errorf("review page lays out %d figures, want 4", strings.Count(string(review), "<figure>"))
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunDrawsEachThemeOnce(t *testing.T) {
|
||||
out := filepath.Join(t.TempDir(), "charts")
|
||||
if err := run([]string{"-people", fixtures, "-out", out, "-theme", "boxes,boxes", "-size", "full", "8"}, &bytes.Buffer{}); err != nil {
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ Ann, who married Robert; Bea, Victoria's nanny, an influence at 0.6,
|
|||
and Edith her grandmother at 0.3. Victoria, Geraldine, Jean and Edith
|
||||
are recorded female, Malcolm and Robert male, Walter other, the rest
|
||||
unknown. The Drummond family from the mirror is <code>task genealogy:demo</code>.</p>
|
||||
<p><strong>Date</strong>: 2026-11-03
|
||||
<p><strong>Date</strong>: 2026-11-04
|
||||
<strong>Stories</strong>: 014 (the model and the boxes), 016 (gender), 017 (brief
|
||||
names, sizes, themes), 018 (the vine)</p>
|
||||
names, sizes, themes), 018 (the vine), 023 (the stem themes)</p>
|
||||
<h2 id="the-hourglass-chart">The hourglass chart</h2>
|
||||
<p>Ancestors above the subject, descendants below, the subject's own row
|
||||
with siblings in birth order and spouses beside them. The model is one:
|
||||
|
|
@ -91,6 +91,31 @@ written in the ink beside each motif.</p>
|
|||
<p><img src="charts/0-hourglass-vine.svg" alt="Victoria, vine"></p>
|
||||
<p><img src="charts/3-hourglass-vine.svg" alt="Jean, vine"></p>
|
||||
<p><img src="charts/7-hourglass-vine.svg" alt="Ann, vine"></p>
|
||||
<h3 id="stem-themes">Stem themes</h3>
|
||||
<p>The boxes kept, byte for byte, and the lines between them redrawn as
|
||||
stems of the flora, masked in the link ink as the margin is (story
|
||||
023). Three variations, to be ranked by eye against the boxes; the
|
||||
ranked one is what the site's charts adopt next.</p>
|
||||
<p><strong>Trellis</strong>: every line a stem, as wide as the line was, a rail
|
||||
widest at the bar and tapering to the child; a leaf or two along the
|
||||
longer stems, placed by the subject's seed.</p>
|
||||
<p><img src="charts/0-hourglass-trellis.svg" alt="Victoria, trellis"></p>
|
||||
<p><img src="charts/3-hourglass-trellis.svg" alt="Jean, trellis"></p>
|
||||
<p><img src="charts/7-hourglass-trellis.svg" alt="Ann, trellis"></p>
|
||||
<p><strong>Tendril</strong>: as trellis, and each stem curls where it meets a box,
|
||||
the way a tendril takes hold: a rail at its child, the spouse's tie
|
||||
at both ends, an influence at both; a sprig from the top-right corner
|
||||
of each box.</p>
|
||||
<p><img src="charts/0-hourglass-tendril.svg" alt="Victoria, tendril"></p>
|
||||
<p><img src="charts/3-hourglass-tendril.svg" alt="Jean, tendril"></p>
|
||||
<p><img src="charts/7-hourglass-tendril.svg" alt="Ann, tendril"></p>
|
||||
<p><strong>Garland</strong>: as trellis, with a bud where a stem reaches a child and
|
||||
a blossom where the tie reaches a spouse; a quarter-flower at the
|
||||
top-left corner of each box, as the tiles have at theirs.</p>
|
||||
<p><img src="charts/0-hourglass-garland.svg" alt="Victoria, garland"></p>
|
||||
<p><img src="charts/3-hourglass-garland.svg" alt="Jean, garland"></p>
|
||||
<p><img src="charts/7-hourglass-garland.svg" alt="Ann, garland"></p>
|
||||
<p><strong>Ranking</strong>: not yet made.</p>
|
||||
<h2 id="sizes">Sizes</h2>
|
||||
<p>Brief is the default: the record's <code>short</code>, else the name before any
|
||||
comma or bracket cut to first word and surname. Full is the <code>short</code>,
|
||||
|
|
|
|||
|
|
@ -81,11 +81,23 @@ tints and the self box's copper stroke stay as they are:
|
|||
- The boxes' SVG is reused, not redrawn: the themes share `boxes`'
|
||||
layout so the only difference on the page is the lines, which is the
|
||||
question being asked.
|
||||
- The flora's strokes are absolute, in the page's millimetres, tuned
|
||||
for a margin seen at about 34 px to the cm; against 44 px boxes they
|
||||
came out as blobs. A chart maps a centimetre of the flora to 18 px,
|
||||
so the ink is finer, and sizes its motifs in those centimetres
|
||||
(`internal/chart/stems.go`).
|
||||
- The quarter-flower is at each box's top-left corner, clipped to the
|
||||
box as a tile's corners are to the tile, drawn over the box after
|
||||
it; boxes meeting at a bar do not share one. Two compositions are
|
||||
grown, the stems under the boxes and the decorations over them, each
|
||||
its own mask with its own ids.
|
||||
- Where a stem meets a box is the stem's end; the curl, bud or
|
||||
blossom sits on the box's edge there, outside it.
|
||||
|
||||
## Done when
|
||||
|
||||
- [ ] tests express the acceptance tables and pass
|
||||
- [ ] README: vocabulary (Stem tie, Decoration); Theme lists the three
|
||||
- [ ] `research/charts.md` shows the three, with the ranking line
|
||||
- [ ] changelog entry
|
||||
- [x] tests express the acceptance tables and pass
|
||||
- [x] README: vocabulary (Stem tie, Decoration); Theme lists the three
|
||||
- [x] `research/charts.md` shows the three, with the ranking line
|
||||
- [x] changelog entry
|
||||
- [ ] issue closed with a link to the release
|
||||
|
|
|
|||
245
internal/chart/stems.go
Normal file
245
internal/chart/stems.go
Normal file
|
|
@ -0,0 +1,245 @@
|
|||
package chart
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"math"
|
||||
"regexp"
|
||||
|
||||
"git.bytestone.uk/hum3/life-weaver/internal/ornament"
|
||||
)
|
||||
|
||||
// The stem themes (story 023): the boxes drawing with its lines redrawn
|
||||
// as stems of the flora, grown by ornament.Grow and masked in the link
|
||||
// colour as the margin is, the boxes kept. The flora works in page
|
||||
// centimetres with y up; the drawing is px with y down.
|
||||
// The flora's strokes are absolute, in the page's millimetres, tuned for
|
||||
// a margin seen at about 34 px to the cm; the chart maps a centimetre to
|
||||
// fewer px so the ink comes out finer against its 44 px boxes, and sizes
|
||||
// its motifs in those larger centimetres.
|
||||
const (
|
||||
pxPerCm = 18 // a centimetre of the flora, in px of the drawing
|
||||
step = 0.5 // cm between the points a straight line is given as, so a stem follows it closely
|
||||
leafFrom = 5.0 // cm: a stem this long gets a leaf, twice as long two
|
||||
)
|
||||
|
||||
// Stem widths, cm: a rail is widest at the bar and tapers to the child,
|
||||
// a bar is even, a spouse's tie thin, an influence the thinnest by its
|
||||
// weight. None under 0.025, where the canvas strokes rather than ribbons.
|
||||
const (
|
||||
railW0, railW1 = 0.14, 0.07
|
||||
barW = 0.1
|
||||
tieW = 0.07
|
||||
influenceW = 0.05
|
||||
)
|
||||
|
||||
// Motif sizes, cm.
|
||||
const (
|
||||
leafSize = 1.0
|
||||
curlSize = 0.8 // a tendril where a stem meets a box
|
||||
budSize = 0.8
|
||||
blossomSize = 0.8
|
||||
sprigSize = 1.3
|
||||
flowerSize = 1.1 // the quarter-flower at a box's corner
|
||||
)
|
||||
|
||||
// A stemTheme is one of the three variations: what a stem carries where
|
||||
// it meets a box, and what decorates each box.
|
||||
type stemTheme struct {
|
||||
name string
|
||||
curl bool // a tendril where a stem meets a box: a rail's child, both ends of a spouse's tie and of an influence
|
||||
buds bool // a bud where a rail reaches its child, a blossom where a spouse's tie reaches the spouse
|
||||
corner string // a motif at a corner of every box: "sprig" sprouting from the top right, "flower" a quarter-flower at the top left clipped to the box as a tile's is; "" none
|
||||
}
|
||||
|
||||
var (
|
||||
trellis = stemTheme{name: "trellis"}
|
||||
tendril = stemTheme{name: "tendril", curl: true, corner: "sprig"}
|
||||
garland = stemTheme{name: "garland", buds: true, corner: "flower"}
|
||||
)
|
||||
|
||||
// Trellis draws every line of the boxes drawing as a stem: the couples'
|
||||
// bars, the rails to their children, the spouse's thin tie and the
|
||||
// influence's thinnest, a leaf or two along the longer ones by the seed.
|
||||
func Trellis(c Chart) []byte { return draw(c, nil, &trellis) }
|
||||
|
||||
// Tendril is Trellis with each stem curling where it meets a box, the way
|
||||
// a tendril takes hold, an influence a tendril its whole length, and a
|
||||
// sprig at a corner of each box.
|
||||
func Tendril(c Chart) []byte { return draw(c, nil, &tendril) }
|
||||
|
||||
// Garland is Trellis with a bud where a stem reaches a child and a
|
||||
// blossom where the tie reaches a spouse, and a quarter-flower at a corner
|
||||
// of each box as the tiles have.
|
||||
func Garland(c Chart) []byte { return draw(c, nil, &garland) }
|
||||
|
||||
// A composition is what a stem theme grows: the stems with their motifs,
|
||||
// and the boxes' decorations, grown apart so they can be clipped to the
|
||||
// boxes and drawn over them.
|
||||
type composition struct {
|
||||
vine, corners ornament.Vine
|
||||
}
|
||||
|
||||
// compose grows the theme's stems and motifs from the chart's layout.
|
||||
func compose(c Chart, t stemTheme) composition {
|
||||
l := plan(c)
|
||||
cm := func(p point) ornament.Pt { return ornament.Pt{X: p.x / pxPerCm, Y: (l.height - p.y) / pxPerCm} }
|
||||
size := ornament.Vine{Width: l.width / pxPerCm, Height: l.height / pxPerCm}
|
||||
v := composition{vine: size, corners: size}
|
||||
seed := uint32(c.Subject)*2654435761 + 12345
|
||||
side := func() float64 { // which way the next leaf leans
|
||||
seed = seed*1664525 + 1013904223
|
||||
if seed&0x10000 != 0 {
|
||||
return 1
|
||||
}
|
||||
return -1
|
||||
}
|
||||
roles := map[any]Role{}
|
||||
for _, b := range l.boxes {
|
||||
if b.Role != More {
|
||||
roles[b.ID] = b.Role
|
||||
}
|
||||
}
|
||||
|
||||
for _, ln := range l.lines {
|
||||
var pts []ornament.Pt
|
||||
var w0, w1 float64
|
||||
switch ln.kind {
|
||||
case rail: // from the bar down to the child, so it tapers towards the child
|
||||
for i := len(ln.pts) - 1; i >= 0; i-- {
|
||||
pts = append(pts, cm(ln.pts[i]))
|
||||
}
|
||||
pts, w0, w1 = along(pts), railW0, railW1
|
||||
case bar, spouseTie:
|
||||
for _, p := range ln.pts {
|
||||
pts = append(pts, cm(p))
|
||||
}
|
||||
pts = along(pts)
|
||||
w0, w1 = barW, barW
|
||||
if ln.kind == spouseTie {
|
||||
w0, w1 = tieW, tieW
|
||||
}
|
||||
case influence:
|
||||
p := ln.pts
|
||||
pts = append(pts, curve(cm(p[0]), cm(p[1]), cm(p[2]), cm(p[3]))...)
|
||||
w0 = influenceW + 0.06*ln.weight
|
||||
w1 = w0
|
||||
}
|
||||
v.vine.Stems = append(v.vine.Stems, ornament.Stem{Pts: pts, W0: w0, W1: w1})
|
||||
v.vine.Motifs = append(v.vine.Motifs, leaves(pts, side)...)
|
||||
|
||||
first, last := pts[0], pts[len(pts)-1]
|
||||
back := func(a, b ornament.Pt) float64 { return math.Atan2(b.Y-a.Y, b.X-a.X) * 180 / math.Pi } // the heading from a towards b
|
||||
switch ln.kind {
|
||||
case rail:
|
||||
if t.curl {
|
||||
v.vine.Motifs = append(v.vine.Motifs, ornament.Motif{Kind: "tendril", X: last.X, Y: last.Y, Angle: 90, Size: curlSize})
|
||||
}
|
||||
if t.buds {
|
||||
v.vine.Motifs = append(v.vine.Motifs, ornament.Motif{Kind: "bud", X: last.X, Y: last.Y, Angle: 90, Size: budSize})
|
||||
}
|
||||
case spouseTie:
|
||||
if t.curl {
|
||||
v.vine.Motifs = append(v.vine.Motifs,
|
||||
ornament.Motif{Kind: "tendril", X: first.X, Y: first.Y, Angle: back(first, pts[1]), Size: curlSize},
|
||||
ornament.Motif{Kind: "tendril", X: last.X, Y: last.Y, Angle: back(last, pts[len(pts)-2]), Size: curlSize})
|
||||
}
|
||||
if t.buds {
|
||||
at, towards := last, pts[len(pts)-2]
|
||||
if roles[ln.ends[0]] == Spouse {
|
||||
at, towards = first, pts[1]
|
||||
}
|
||||
v.vine.Motifs = append(v.vine.Motifs, ornament.Motif{Kind: "blossoms", X: at.X, Y: at.Y, Angle: back(at, towards), Size: blossomSize})
|
||||
}
|
||||
case influence:
|
||||
if t.curl {
|
||||
v.vine.Motifs = append(v.vine.Motifs,
|
||||
ornament.Motif{Kind: "tendril", X: first.X, Y: first.Y, Angle: 90, Size: curlSize},
|
||||
ornament.Motif{Kind: "tendril", X: last.X, Y: last.Y, Angle: 270, Size: curlSize})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, b := range l.boxes {
|
||||
switch t.corner {
|
||||
case "sprig":
|
||||
p := cm(point{b.at.x + l.boxW, b.at.y})
|
||||
v.corners.Motifs = append(v.corners.Motifs, ornament.Motif{Kind: "sprig", X: p.X, Y: p.Y, Angle: 35, Size: sprigSize})
|
||||
case "flower":
|
||||
p := cm(b.at)
|
||||
v.corners.Motifs = append(v.corners.Motifs, ornament.Motif{Kind: "flower", X: p.X, Y: p.Y, Angle: 90, Size: flowerSize})
|
||||
}
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// along gives a polyline point by point, a step apart, so the canvas's
|
||||
// smoothing through them keeps to the line and only rounds its corners.
|
||||
func along(pts []ornament.Pt) []ornament.Pt {
|
||||
out := []ornament.Pt{pts[0]}
|
||||
for i := 1; i < len(pts); i++ {
|
||||
a, z := pts[i-1], pts[i]
|
||||
d := math.Hypot(z.X-a.X, z.Y-a.Y)
|
||||
n := int(math.Ceil(d / step))
|
||||
for j := 1; j <= n; j++ {
|
||||
t := float64(j) / float64(n)
|
||||
out = append(out, ornament.Pt{X: a.X + (z.X-a.X)*t, Y: a.Y + (z.Y-a.Y)*t})
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// leaves places a leaf along a stem that is leafFrom long, two along one
|
||||
// twice that, each leaning off the stem to the side given.
|
||||
func leaves(pts []ornament.Pt, side func() float64) []ornament.Motif {
|
||||
length := 0.0
|
||||
for i := 1; i < len(pts); i++ {
|
||||
length += math.Hypot(pts[i].X-pts[i-1].X, pts[i].Y-pts[i-1].Y)
|
||||
}
|
||||
var at []float64 // fractions along
|
||||
switch {
|
||||
case length >= 2*leafFrom:
|
||||
at = []float64{0.3, 0.65}
|
||||
case length >= leafFrom:
|
||||
at = []float64{0.38}
|
||||
}
|
||||
var out []ornament.Motif
|
||||
for _, f := range at {
|
||||
want, run := f*length, 0.0
|
||||
for i := 1; i < len(pts); i++ {
|
||||
d := math.Hypot(pts[i].X-pts[i-1].X, pts[i].Y-pts[i-1].Y)
|
||||
if run+d >= want {
|
||||
t := (want - run) / d
|
||||
p := ornament.Pt{X: pts[i-1].X + (pts[i].X-pts[i-1].X)*t, Y: pts[i-1].Y + (pts[i].Y-pts[i-1].Y)*t}
|
||||
heading := math.Atan2(pts[i].Y-pts[i-1].Y, pts[i].X-pts[i-1].X) * 180 / math.Pi
|
||||
out = append(out, ornament.Motif{Kind: "leaf", X: p.X, Y: p.Y, Angle: heading + side()*60, Size: leafSize})
|
||||
break
|
||||
}
|
||||
run += d
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// grownIDs finds the ids Grow gives its shapes and clips, and their uses.
|
||||
var grownIDs = regexp.MustCompile(`(id="|href="#|url\(#)([pc]\d+)`)
|
||||
|
||||
// mask writes a composition as a mask over the drawing and a rect of the
|
||||
// link colour through it; clipped to the boxes given, if any.
|
||||
func mask(w *bytes.Buffer, id string, l layout, v ornament.Vine, clip []placed, seed uint32) {
|
||||
fmt.Fprintf(w, `<defs><mask id="%s" maskUnits="userSpaceOnUse" x="0" y="0" width="%g" height="%g">`+"\n", id, l.width, l.height)
|
||||
if clip != nil {
|
||||
fmt.Fprintf(w, `<clipPath id="%s-boxes">`, id)
|
||||
for _, b := range clip {
|
||||
fmt.Fprintf(w, `<rect x="%g" y="%g" width="%g" height="%d" rx="4"/>`, b.at.x, b.at.y, l.boxW, boxH)
|
||||
}
|
||||
fmt.Fprintf(w, `</clipPath><g clip-path="url(#%s-boxes)">`+"\n", id)
|
||||
}
|
||||
// Grow's shapes and clips are p1, c1 and so on: made unique to this
|
||||
// mask, since the stems' and the corners' share the file.
|
||||
w.Write(grownIDs.ReplaceAll(ornament.Grow(v, seed), []byte("${1}"+id+"-${2}")))
|
||||
if clip != nil {
|
||||
w.WriteString("</g>\n")
|
||||
}
|
||||
fmt.Fprintf(w, "</mask></defs>\n"+`<rect width="%g" height="%g" fill="var(--link)" mask="url(#%s)"/>`+"\n", l.width, l.height, id)
|
||||
}
|
||||
135
internal/chart/stems_test.go
Normal file
135
internal/chart/stems_test.go
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
package chart
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// boxElements is the boxes a drawing carries, byte for byte: the group of
|
||||
// each box's rect and text, the lines of the drawing that start one.
|
||||
func boxElements(svg []byte) string {
|
||||
var out []string
|
||||
for _, line := range strings.Split(string(svg), "\n") {
|
||||
if strings.HasPrefix(line, `<g><rect class="box`) {
|
||||
out = append(out, line)
|
||||
}
|
||||
}
|
||||
return strings.Join(out, "\n")
|
||||
}
|
||||
|
||||
// kinds counts a composition's motifs by kind.
|
||||
func kinds(v composition) map[string]int {
|
||||
out := map[string]int{}
|
||||
for _, m := range v.vine.Motifs {
|
||||
out[m.Kind]++
|
||||
}
|
||||
for _, m := range v.corners.Motifs {
|
||||
out["corner "+m.Kind]++
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Each stem theme (story 023) is the boxes drawing with its lines redrawn
|
||||
// as stems of the flora, masked in the link colour: the boxes, labels and
|
||||
// years of SVG byte for byte, no tie or influence line, the role of an
|
||||
// influence still written, the same bytes for the same subject.
|
||||
func TestStemThemesKeepTheBoxesAndMaskTheStems(t *testing.T) {
|
||||
reg := load(t)
|
||||
ch := hourglass(t, reg, 0, 2, 2)
|
||||
boxes := boxElements(SVG(ch))
|
||||
if boxes == "" {
|
||||
t.Fatal("SVG() draws no box groups")
|
||||
}
|
||||
for name, fn := range map[string]func(Chart) []byte{"trellis": Trellis, "tendril": Tendril, "garland": Garland} {
|
||||
svg := string(fn(ch))
|
||||
if !strings.HasPrefix(svg, "<svg") || !strings.HasSuffix(strings.TrimSpace(svg), "</svg>") {
|
||||
t.Errorf("%s: not an svg element:\n%.80s", name, svg)
|
||||
}
|
||||
for _, want := range []string{"<mask", `mask="url(#`, "var(--link)", "Victoria", "Bea", "nanny", "1894–1978", ".box {", "--copper"} {
|
||||
if !strings.Contains(svg, want) {
|
||||
t.Errorf("%s: lacks %q", name, want)
|
||||
}
|
||||
}
|
||||
if got := boxElements([]byte(svg)); got != boxes {
|
||||
t.Errorf("%s: boxes differ from SVG()'s:\n%s\nwant\n%s", name, got, boxes)
|
||||
}
|
||||
if strings.Contains(svg, `class="tie"`) || strings.Contains(svg, `class="influenced"`) {
|
||||
t.Errorf("%s: still draws a line; the lines are stems", name)
|
||||
}
|
||||
if string(fn(ch)) != svg {
|
||||
t.Errorf("%s: drew the same chart differently twice", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The compositions by the story's table. Jean, one generation each way:
|
||||
// her parents' bar, the rails to her and Victoria, her thin tie to Hugh,
|
||||
// the rail to Ann, no influence; six boxes. Victoria, two each way: two
|
||||
// bars, three rails, two influences; seven boxes.
|
||||
func TestStemThemesCompositions(t *testing.T) {
|
||||
reg := load(t)
|
||||
jean, victoria := hourglass(t, reg, 3, 1, 1), hourglass(t, reg, 0, 2, 2)
|
||||
for _, c := range []struct {
|
||||
name string
|
||||
theme stemTheme
|
||||
chart Chart
|
||||
stems int
|
||||
want map[string]int // motifs by kind, leaves aside
|
||||
}{
|
||||
{"trellis", trellis, jean, 5, map[string]int{}},
|
||||
{"trellis", trellis, victoria, 7, map[string]int{}},
|
||||
// a curl where each rail meets its box, at both ends of the spouse tie; a sprig per box
|
||||
{"tendril", tendril, jean, 5, map[string]int{"tendril": 5, "corner sprig": 6}},
|
||||
// an influence is a tendril its whole length: a curl at both ends
|
||||
{"tendril", tendril, victoria, 7, map[string]int{"tendril": 7, "corner sprig": 7}},
|
||||
// a bud at each child's end, a blossom at the spouse's; a quarter-flower per box
|
||||
{"garland", garland, jean, 5, map[string]int{"bud": 3, "blossoms": 1, "corner flower": 6}},
|
||||
{"garland", garland, victoria, 7, map[string]int{"bud": 3, "corner flower": 7}},
|
||||
} {
|
||||
v := compose(c.chart, c.theme)
|
||||
if got := len(v.vine.Stems); got != c.stems {
|
||||
t.Errorf("%s(%s): %d stems, want %d", c.name, c.chart.Subject, got, c.stems)
|
||||
}
|
||||
got := kinds(v)
|
||||
leaves := got["leaf"]
|
||||
delete(got, "leaf")
|
||||
if c.chart.Subject == 0 && leaves == 0 {
|
||||
t.Errorf("%s(%s): no leaf along the longer stems", c.name, c.chart.Subject)
|
||||
}
|
||||
for k, n := range c.want {
|
||||
if got[k] != n {
|
||||
t.Errorf("%s(%s): %d %s, want %d", c.name, c.chart.Subject, got[k], k, n)
|
||||
}
|
||||
}
|
||||
for k := range got {
|
||||
if _, ok := c.want[k]; !ok {
|
||||
t.Errorf("%s(%s): draws %d %s, which the table does not have", c.name, c.chart.Subject, got[k], k)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The stems take the lines' geometry: a rail as wide at the bar as a drop
|
||||
// line and tapering to the child; a spouse tie thin; an influence the
|
||||
// thinnest, by weight; nothing under the canvas's ribbon floor.
|
||||
func TestStemWidths(t *testing.T) {
|
||||
reg := load(t)
|
||||
v := compose(hourglass(t, reg, 0, 2, 2), trellis)
|
||||
var widest, thinnest float64 = 0, 1
|
||||
for _, s := range v.vine.Stems {
|
||||
for _, w := range []float64{s.W0, s.W1} {
|
||||
if w < 0.025 {
|
||||
t.Errorf("a stem %g cm wide: under the ribbon floor", w)
|
||||
}
|
||||
if w > widest {
|
||||
widest = w
|
||||
}
|
||||
if w < thinnest {
|
||||
thinnest = w
|
||||
}
|
||||
}
|
||||
}
|
||||
if widest <= thinnest {
|
||||
t.Errorf("every stem the same width, %g; want rails wider than influences", widest)
|
||||
}
|
||||
}
|
||||
|
|
@ -42,11 +42,11 @@ func CSS() string { return rules }
|
|||
// children hung from it by a rail, and each influence a dashed curve as
|
||||
// wide as its weight with the role on it. The brand's palette and the
|
||||
// rules are in the file, so it follows the scheme.
|
||||
func SVG(c Chart) []byte { return draw(c, nil) }
|
||||
func SVG(c Chart) []byte { return draw(c, nil, nil) }
|
||||
|
||||
// Inline draws the chart for a page (story 020): the same boxes, each a
|
||||
// link to href(id), with no stylesheet of its own; the page's has CSS().
|
||||
func Inline(c Chart, href func(pid.ID) string) []byte { return draw(c, href) }
|
||||
func Inline(c Chart, href func(pid.ID) string) []byte { return draw(c, href, nil) }
|
||||
|
||||
// geometry is the boxes drawing's measure of a chart: the box width, from
|
||||
// the longest label within bounds, and the drawing's width.
|
||||
|
|
@ -74,35 +74,68 @@ func extent(c Chart) float64 {
|
|||
return width
|
||||
}
|
||||
|
||||
func draw(c Chart, href func(pid.ID) string) []byte {
|
||||
// A point is a place on the boxes drawing, px, y down.
|
||||
type point struct{ x, y float64 }
|
||||
|
||||
// A line is one tie of the boxes drawing, by kind: the boxes theme draws
|
||||
// it as a line and a stem theme (story 023) grows it as a stem.
|
||||
type line struct {
|
||||
kind lineKind
|
||||
pts []point // a bar: its two ends, or four points under both; a rail: child, corner, corner, bar; an influence: its cubic's four control points
|
||||
ends [2]pid.ID // a bar: the couple, in the order of pts
|
||||
weight float64 // an influence's, above 0 and up to 1
|
||||
role string // an influence's
|
||||
at point // where an influence's role is written
|
||||
}
|
||||
|
||||
type lineKind int
|
||||
|
||||
const (
|
||||
bar lineKind = iota // a couple's bar
|
||||
spouseTie // the bar between the subject and a spouse
|
||||
rail // a child's rail up to the bar or parent it hangs from
|
||||
influence // the dashed curve from the subject up to an influence
|
||||
)
|
||||
|
||||
// A placed box is a box of the chart at its place on the drawing.
|
||||
type placed struct {
|
||||
Box
|
||||
at point // its top left
|
||||
}
|
||||
|
||||
// A layout is the boxes drawing before it is written: the measures, every
|
||||
// box placed, and the lines between them in the order drawn.
|
||||
type layout struct {
|
||||
boxW, width, height float64
|
||||
boxes []placed
|
||||
lines []line
|
||||
}
|
||||
|
||||
// plan lays the chart out as the boxes theme draws it.
|
||||
func plan(c Chart) layout {
|
||||
boxW, width := geometry(c)
|
||||
pitch := boxW + colGap
|
||||
rowPitch := float64(boxH + rowGap)
|
||||
l := layout{boxW: boxW, width: width, height: pad*2 + float64(len(c.Rows))*rowPitch - rowGap}
|
||||
|
||||
type point struct{ x, y float64 }
|
||||
xy := func(i int, b Box) point { return point{pad + b.X*pitch, pad + float64(i)*rowPitch} }
|
||||
at := map[pid.ID]point{} // each person's box's top left; a more box has none
|
||||
roles := map[pid.ID]Role{}
|
||||
for i, r := range c.Rows {
|
||||
for _, b := range r.Boxes {
|
||||
p := xy(i, b)
|
||||
l.boxes = append(l.boxes, placed{b, p})
|
||||
if b.Role != More {
|
||||
at[b.ID] = xy(i, b)
|
||||
at[b.ID], roles[b.ID] = p, b.Role
|
||||
}
|
||||
}
|
||||
}
|
||||
height := pad*2 + float64(len(c.Rows))*rowPitch - rowGap
|
||||
cx := func(id pid.ID) float64 { return at[id].x + boxW/2 }
|
||||
top := func(id pid.ID) float64 { return at[id].y }
|
||||
bottom := func(id pid.ID) float64 { return at[id].y + boxH }
|
||||
|
||||
var w bytes.Buffer
|
||||
fmt.Fprintf(&w, `<svg xmlns="http://www.w3.org/2000/svg" class="chart" width="%g" height="%g" viewBox="0 0 %g %g" font-family="system-ui, sans-serif" font-size="%d">`+"\n", width, height, width, height, fontSize)
|
||||
if href == nil {
|
||||
w.WriteString("<style>\n" + brand.CSS() + rules + "</style>\n")
|
||||
}
|
||||
|
||||
// The couples' bars, remembering where children hang from.
|
||||
type hang struct{ x, y float64 }
|
||||
bars := map[[2]pid.ID]hang{}
|
||||
bars := map[[2]pid.ID]point{}
|
||||
couple := func(a, z pid.ID) [2]pid.ID {
|
||||
if a > z {
|
||||
a, z = z, a
|
||||
|
|
@ -113,18 +146,22 @@ func draw(c Chart, href func(pid.ID) string) []byte {
|
|||
if e.Kind != MarriedTo {
|
||||
continue
|
||||
}
|
||||
l, r := e.From, e.To
|
||||
if at[l].x > at[r].x {
|
||||
l, r = r, l
|
||||
lf, rt := e.From, e.To
|
||||
if at[lf].x > at[rt].x {
|
||||
lf, rt = rt, lf
|
||||
}
|
||||
if at[r].x-at[l].x <= pitch+1e-6 { // side by side: a bar between them at mid height
|
||||
y := top(l) + boxH/2
|
||||
fmt.Fprintf(&w, `<line class="tie" x1="%g" y1="%g" x2="%g" y2="%g"/>`+"\n", at[l].x+boxW, y, at[r].x, y)
|
||||
bars[couple(l, r)] = hang{(at[l].x + boxW + at[r].x) / 2, y}
|
||||
kind := bar
|
||||
if roles[lf] == Spouse || roles[rt] == Spouse {
|
||||
kind = spouseTie
|
||||
}
|
||||
if at[rt].x-at[lf].x <= pitch+1e-6 { // side by side: a bar between them at mid height
|
||||
y := top(lf) + boxH/2
|
||||
l.lines = append(l.lines, line{kind: kind, ends: [2]pid.ID{lf, rt}, pts: []point{{at[lf].x + boxW, y}, {at[rt].x, y}}})
|
||||
bars[couple(lf, rt)] = point{(at[lf].x + boxW + at[rt].x) / 2, y}
|
||||
} else { // someone between: a bar under both
|
||||
y := bottom(l) + barDrop
|
||||
fmt.Fprintf(&w, `<path class="tie" d="M%g %g V%g H%g V%g"/>`+"\n", cx(l), bottom(l), y, cx(r), bottom(r))
|
||||
bars[couple(l, r)] = hang{(cx(l) + cx(r)) / 2, y}
|
||||
y := bottom(lf) + barDrop
|
||||
l.lines = append(l.lines, line{kind: kind, ends: [2]pid.ID{lf, rt}, pts: []point{{cx(lf), bottom(lf)}, {cx(lf), y}, {cx(rt), y}, {cx(rt), bottom(rt)}}})
|
||||
bars[couple(lf, rt)] = point{(cx(lf) + cx(rt)) / 2, y}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -136,40 +173,37 @@ func draw(c Chart, href func(pid.ID) string) []byte {
|
|||
parents[e.From] = append(parents[e.From], e.To)
|
||||
}
|
||||
}
|
||||
hangOf := func(b Box) (hang, bool) {
|
||||
hangOf := func(b Box) (point, bool) {
|
||||
if b.Role == More {
|
||||
if _, ok := at[b.Of]; !ok {
|
||||
return hang{}, false
|
||||
return point{}, false
|
||||
}
|
||||
for _, e := range c.Edges {
|
||||
if e.Kind == MarriedTo && (e.From == b.Of || e.To == b.Of) {
|
||||
return bars[couple(e.From, e.To)], true
|
||||
}
|
||||
}
|
||||
return hang{cx(b.Of), bottom(b.Of)}, true
|
||||
return point{cx(b.Of), bottom(b.Of)}, true
|
||||
}
|
||||
ps := parents[b.ID]
|
||||
if len(ps) == 0 {
|
||||
return hang{}, false
|
||||
return point{}, false
|
||||
}
|
||||
if h, ok := bars[couple(ps[0], ps[len(ps)-1])]; ok && len(ps) >= 2 {
|
||||
return h, true
|
||||
}
|
||||
return hang{cx(ps[0]), bottom(ps[0])}, true
|
||||
return point{cx(ps[0]), bottom(ps[0])}, true
|
||||
}
|
||||
for i, r := range c.Rows {
|
||||
for _, b := range r.Boxes {
|
||||
to, ok := hangOf(b)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
p := xy(i, b)
|
||||
rail := p.y - rowGap/2
|
||||
if to.y > rail {
|
||||
rail = (to.y + p.y) / 2
|
||||
}
|
||||
fmt.Fprintf(&w, `<path class="tie" d="M%g %g V%g H%g V%g"/>`+"\n", p.x+boxW/2, p.y, rail, to.x, to.y)
|
||||
for _, b := range l.boxes {
|
||||
to, ok := hangOf(b.Box)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
y := b.at.y - rowGap/2
|
||||
if to.y > y {
|
||||
y = (to.y + b.at.y) / 2
|
||||
}
|
||||
l.lines = append(l.lines, line{kind: rail, pts: []point{{b.at.x + boxW/2, b.at.y}, {b.at.x + boxW/2, y}, {to.x, y}, to}})
|
||||
}
|
||||
|
||||
// Influences: a curve from the subject's top to the influence's bottom, the role just under the influence.
|
||||
|
|
@ -179,31 +213,69 @@ func draw(c Chart, href func(pid.ID) string) []byte {
|
|||
}
|
||||
x0, y0, x1, y1 := cx(e.From), top(e.From), cx(e.To), bottom(e.To)
|
||||
my := (y0 + y1) / 2
|
||||
fmt.Fprintf(&w, `<path class="influenced" stroke-width="%.2f" d="M%g %g C%g %g %g %g %g %g"/>`+"\n",
|
||||
0.75+3*e.Weight, x0, y0, x0, my, x1, my, x1, y1)
|
||||
fmt.Fprintf(&w, `<text class="role" x="%g" y="%g">%s</text>`+"\n", x1+5, y1+14, html.EscapeString(e.Role))
|
||||
l.lines = append(l.lines, line{kind: influence, weight: e.Weight, role: e.Role, at: point{x1 + 5, y1 + 14},
|
||||
pts: []point{{x0, y0}, {x0, my}, {x1, my}, {x1, y1}}})
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
// draw writes the layout: the lines, or with a stem theme the stems grown
|
||||
// in their place and masked in the link colour, then the boxes, each a
|
||||
// link to href(id) when href is given, then the theme's decorations.
|
||||
func draw(c Chart, href func(pid.ID) string, t *stemTheme) []byte {
|
||||
l := plan(c)
|
||||
var w bytes.Buffer
|
||||
fmt.Fprintf(&w, `<svg xmlns="http://www.w3.org/2000/svg" class="chart" width="%g" height="%g" viewBox="0 0 %g %g" font-family="system-ui, sans-serif" font-size="%d">`+"\n", l.width, l.height, l.width, l.height, fontSize)
|
||||
if href == nil {
|
||||
w.WriteString("<style>\n" + brand.CSS() + rules + "</style>\n")
|
||||
}
|
||||
|
||||
for i, r := range c.Rows {
|
||||
for _, b := range r.Boxes {
|
||||
p := xy(i, b)
|
||||
linked := href != nil && b.Role != More
|
||||
if linked {
|
||||
fmt.Fprintf(&w, `<a href="%s">`, html.EscapeString(href(b.ID)))
|
||||
var v composition
|
||||
if t != nil {
|
||||
v = compose(c, *t)
|
||||
mask(&w, "stems", l, v.vine, nil, uint32(c.Subject))
|
||||
}
|
||||
for _, ln := range l.lines {
|
||||
switch {
|
||||
case ln.kind == influence:
|
||||
if t == nil {
|
||||
fmt.Fprintf(&w, `<path class="influenced" stroke-width="%.2f" d="M%g %g C%g %g %g %g %g %g"/>`+"\n",
|
||||
0.75+3*ln.weight, ln.pts[0].x, ln.pts[0].y, ln.pts[1].x, ln.pts[1].y, ln.pts[2].x, ln.pts[2].y, ln.pts[3].x, ln.pts[3].y)
|
||||
}
|
||||
fmt.Fprintf(&w, `<g><rect class="%s" x="%g" y="%g" width="%g" height="%d" rx="4"/>`,
|
||||
strings.TrimSpace(fmt.Sprintf("box %s %s", b.Role, b.Gender)), p.x, p.y, boxW, boxH)
|
||||
fmt.Fprintf(&w, `<text class="label" x="%g" y="%g" text-anchor="middle">%s</text>`, p.x+boxW/2, p.y+18, html.EscapeString(b.Label))
|
||||
if b.Years != "" {
|
||||
fmt.Fprintf(&w, `<text class="years" x="%g" y="%g" text-anchor="middle">%s</text>`, p.x+boxW/2, p.y+34, html.EscapeString(b.Years))
|
||||
}
|
||||
w.WriteString("</g>")
|
||||
if linked {
|
||||
w.WriteString("</a>")
|
||||
}
|
||||
w.WriteString("\n")
|
||||
fmt.Fprintf(&w, `<text class="role" x="%g" y="%g">%s</text>`+"\n", ln.at.x, ln.at.y, html.EscapeString(ln.role))
|
||||
case t != nil:
|
||||
case len(ln.pts) == 2:
|
||||
fmt.Fprintf(&w, `<line class="tie" x1="%g" y1="%g" x2="%g" y2="%g"/>`+"\n", ln.pts[0].x, ln.pts[0].y, ln.pts[1].x, ln.pts[1].y)
|
||||
default:
|
||||
fmt.Fprintf(&w, `<path class="tie" d="M%g %g V%g H%g V%g"/>`+"\n", ln.pts[0].x, ln.pts[0].y, ln.pts[1].y, ln.pts[2].x, ln.pts[3].y)
|
||||
}
|
||||
}
|
||||
|
||||
for _, b := range l.boxes {
|
||||
p := b.at
|
||||
linked := href != nil && b.Role != More
|
||||
if linked {
|
||||
fmt.Fprintf(&w, `<a href="%s">`, html.EscapeString(href(b.ID)))
|
||||
}
|
||||
fmt.Fprintf(&w, `<g><rect class="%s" x="%g" y="%g" width="%g" height="%d" rx="4"/>`,
|
||||
strings.TrimSpace(fmt.Sprintf("box %s %s", b.Role, b.Gender)), p.x, p.y, l.boxW, boxH)
|
||||
fmt.Fprintf(&w, `<text class="label" x="%g" y="%g" text-anchor="middle">%s</text>`, p.x+l.boxW/2, p.y+18, html.EscapeString(b.Label))
|
||||
if b.Years != "" {
|
||||
fmt.Fprintf(&w, `<text class="years" x="%g" y="%g" text-anchor="middle">%s</text>`, p.x+l.boxW/2, p.y+34, html.EscapeString(b.Years))
|
||||
}
|
||||
w.WriteString("</g>")
|
||||
if linked {
|
||||
w.WriteString("</a>")
|
||||
}
|
||||
w.WriteString("\n")
|
||||
}
|
||||
if t != nil && len(v.corners.Motifs) > 0 {
|
||||
var clip []placed
|
||||
if t.corner == "flower" {
|
||||
clip = l.boxes
|
||||
}
|
||||
mask(&w, "corners", l, v.corners, clip, uint32(c.Subject)+1)
|
||||
}
|
||||
w.WriteString("</svg>\n")
|
||||
return w.Bytes()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ and Edith her grandmother at 0.3. Victoria, Geraldine, Jean and Edith
|
|||
are recorded female, Malcolm and Robert male, Walter other, the rest
|
||||
unknown. The Drummond family from the mirror is `task genealogy:demo`.
|
||||
|
||||
**Date**: 2026-11-03
|
||||
**Date**: 2026-11-04
|
||||
**Stories**: 014 (the model and the boxes), 016 (gender), 017 (brief
|
||||
names, sizes, themes), 018 (the vine)
|
||||
names, sizes, themes), 018 (the vine), 023 (the stem themes)
|
||||
|
||||
## The hourglass chart
|
||||
|
||||
|
|
@ -59,6 +59,46 @@ written in the ink beside each motif.
|
|||
|
||||

|
||||
|
||||
### Stem themes
|
||||
|
||||
The boxes kept, byte for byte, and the lines between them redrawn as
|
||||
stems of the flora, masked in the link ink as the margin is (story
|
||||
023). Three variations, to be ranked by eye against the boxes; the
|
||||
ranked one is what the site's charts adopt next.
|
||||
|
||||
**Trellis**: every line a stem, as wide as the line was, a rail
|
||||
widest at the bar and tapering to the child; a leaf or two along the
|
||||
longer stems, placed by the subject's seed.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
**Tendril**: as trellis, and each stem curls where it meets a box,
|
||||
the way a tendril takes hold: a rail at its child, the spouse's tie
|
||||
at both ends, an influence at both; a sprig from the top-right corner
|
||||
of each box.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
**Garland**: as trellis, with a bud where a stem reaches a child and
|
||||
a blossom where the tie reaches a spouse; a quarter-flower at the
|
||||
top-left corner of each box, as the tiles have at theirs.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
**Ranking**: not yet made.
|
||||
|
||||
## Sizes
|
||||
|
||||
Brief is the default: the record's `short`, else the name before any
|
||||
|
|
|
|||
Loading…
Reference in a new issue