Reorganize positioning
This commit is contained in:
parent
b946ffd6b4
commit
ec79d9e0c7
1 changed files with 71 additions and 54 deletions
125
git-figure.typ
125
git-figure.typ
|
|
@ -9,34 +9,47 @@
|
|||
#let thin = 0.5pt;
|
||||
#let thindotted = (thickness: thin, dash: "dotted");
|
||||
#let thindashed = (thickness: thin, dash: "dashed");
|
||||
#let commit-node(coord, hash, ..args) = node(coord, raw(hash), shape: pill, fill: commit-color.lighten(50%), stroke: thin, ..args)
|
||||
#let commit-object(coord, hash, name, ..args) = node(coord, align(left, [#text(size: 8pt, gray.darken(50%), raw(hash))\ #name]), corner-radius: 7pt, fill: commit-color.lighten(50%), stroke: none, ..args)
|
||||
#let tree-object(coord, hash, ..args) = commit-object(coord, hash, [tree], width: 2cm, fill: blue.lighten(50%), ..args)
|
||||
#let file-object(coord, hash, name, ..args) = commit-object(coord, hash, name, width: 2cm, fill: gray.lighten(50%), ..args)
|
||||
#let commit-node(coord, hash, ..args) = node(
|
||||
coord, raw(hash), shape: pill, fill: commit-color.lighten(50%), stroke: thin, ..args)
|
||||
#let commit-object(coord, hash, name, ..args) = node(
|
||||
coord, align(left, [#text(size: 8pt, gray.darken(50%), raw(hash))\ #name]),
|
||||
corner-radius: 7pt, fill: commit-color.lighten(50%), stroke: none, ..args)
|
||||
#let tree-object(coord, hash, ..args) = commit-object(coord, hash, [tree],
|
||||
width: 2cm, fill: blue.lighten(50%), ..args)
|
||||
#let file-object(coord, hash, name, ..args) = commit-object(coord, hash, name,
|
||||
width: 2cm, fill: gray.lighten(50%), ..args)
|
||||
|
||||
#diagram(debug: 1, node-stroke: 2pt, edge-stroke: 1pt,
|
||||
{
|
||||
let store = (0.6, 6.7)
|
||||
let x_0 = 2
|
||||
let x_delta = 1
|
||||
let x_1 = x_0 + 1.5
|
||||
/*let store = (2cm, 2cm)
|
||||
let (co1, co2) = {
|
||||
let x = 0.2
|
||||
let x = 2cm
|
||||
let y = store.at(1)
|
||||
((x, y+0.5), (x, y+1))
|
||||
((x, y+1.5cm), (x, y+1.5cm))
|
||||
}
|
||||
let (tree1, tree2) = {
|
||||
let x = 1.2
|
||||
let x = 3.2cm
|
||||
((x, co1.at(1)), (x, co2.at(1)))
|
||||
}
|
||||
let (f1, f2, f3) = {
|
||||
let x = 2.2;
|
||||
let x = 4.2cm;
|
||||
let y = store.at(1)
|
||||
((x, y), (x, y + 0.5), (x, y + 1))
|
||||
}
|
||||
((x, y), (x, y + 0.5cm), (x, y + 1cm))
|
||||
}*/
|
||||
let (A, B, C, D, E, F, G) = ((2, 6), (2, 5), (2, 4), (2, 3), (2, 2), (2, 1), (2, 0))
|
||||
let (B1, B2) = ((3, 4.5), (3, 3.5))
|
||||
let (E1, E2, E3) = ((3, 1.5), (3, 0.5), (3, -0.5))
|
||||
let (Br1, Br2) = ((F.at(0)-0.5, F.at(1)), (E2.at(0)-0.5, E2.at(1)))
|
||||
let (T1, T2) = ((E.at(0)-0.5, E.at(1)), (B.at(0)-0.5, B.at(1)))
|
||||
let refs = (3.5, store.at(1))
|
||||
let (Br1, Br2) = ((F.at(0)-1, F.at(1)), (E2.at(0)-1, E2.at(1)))
|
||||
let (T1, T2) = ((E.at(0)-1, E.at(1)), (B.at(0)-1, B.at(1)))
|
||||
let (Ah, Bh, Ch, Dh, Eh, Fh, Gh) = ("0a3d36", "ce2d1d", "0459b3", "b62527", "93f4ee", "7b67bd", "a6eb69")
|
||||
let (B1h, B2h) = ("2e4289", "7ed6de")
|
||||
let (E1h, E2h, E3h) = ("aa083c", "3f28d1", "2e9986")
|
||||
//e05dcdcb48cd0772313f")
|
||||
/*
|
||||
let refs = (12cm, store.at(1))
|
||||
let tags = (0.5, 3)
|
||||
let commit = (3.8, 2.5)
|
||||
let branches = (0.5, 0)
|
||||
|
|
@ -58,32 +71,43 @@
|
|||
edge(co1, tree1, "->")
|
||||
|
||||
|
||||
|
||||
node(store, stroke: thin, enclose:(co1, f3, f1))
|
||||
|
||||
commit-node(A, "A 16f299")
|
||||
commit-node(B, "B 16f299")
|
||||
commit-node(C, "C 16f299")
|
||||
commit-node(D, "D 16f299")
|
||||
commit-node(E, "E 16f299")
|
||||
commit-node(F, "F 16f299")
|
||||
*/
|
||||
commit-node(A, Ah, name: <A>)
|
||||
commit-node(B, Bh, name: <B>)
|
||||
commit-node(C, Ch, name: <C>)
|
||||
commit-node(D, Dh, name: <D>)
|
||||
commit-node(E, Eh, name: <E>)
|
||||
commit-node(F, Fh, name: <F>)
|
||||
// merge commit
|
||||
node(mc, [Merge commit\ #text(size: 8pt)[commit with two parents]], stroke: thin, corner-radius: 10pt)
|
||||
//node(mc, [Merge commit\ #text(size: 8pt)[commit with two parents]], stroke: thin, corner-radius: 10pt)
|
||||
// merged branch
|
||||
commit-node(B1, "B1 16f299")
|
||||
commit-node(B2, "B2 16f299")
|
||||
commit-node((rel: (1, -0.5), to: <B>), B1h, name: <B1>)
|
||||
commit-node((rel: (0, -1), to: <B1>), B2h, name: <B2>)
|
||||
// unmerged branch
|
||||
commit-node(E1, "E1 16f299")
|
||||
commit-node(E2, "E2 16f299")
|
||||
commit-node(E3, "E3 16f299", fill: none, stroke: thindashed)
|
||||
commit-node((rel: (1, -0.5), to: <E>), E1h, name: <E1>)
|
||||
commit-node((rel: (0, -1), to: <E1>), E2h, name: <E2>)
|
||||
commit-node((rel: (0, -1), to: <E2>), E3h, fill: none, stroke: thindashed, name: <E3>)
|
||||
// branches
|
||||
node(Br1, [main], shape: hexagon, stroke: branch-color)
|
||||
node(Br2, [hotfix], shape: hexagon, stroke: branch-color)
|
||||
node((rel: (-1, 0), to: <F>), [main], shape: hexagon, stroke: branch-color, name: <main>)
|
||||
edge(<main>, <F>, "->", stroke: thin)
|
||||
node((rel: (-2, 0), to: <E2>), [hotfix], shape: hexagon, stroke: branch-color, name: <hotfix>)
|
||||
edge(<hotfix>, <E2>, "->", stroke: thin)
|
||||
// tags
|
||||
node(T1, [v-1.0], shape: chevron, stroke: tag-color)
|
||||
node(T2, [v-1.1], shape: chevron, stroke: tag-color)
|
||||
node((rel: (-1, 0), to: <E>), [v-1.0], shape: chevron, stroke: tag-color, name: <v1>)
|
||||
edge(<v1>, <E>, "->", stroke: thin)
|
||||
node((rel: (-1, 0), to: <B>), [v-1.1], shape: chevron, stroke: tag-color, name: <v2>)
|
||||
edge(<v2>, <B>, "->", stroke: thin)
|
||||
// enclose the tree
|
||||
node((rel: (0, -1), to: <F>), [*Version history*\
|
||||
#align(left, text(size: 8pt)[
|
||||
_Directed Acyclic Graph (DAG)_ describes version history.
|
||||
Commits are nodes in DAG, while an edge connect a commit with its parent.
|
||||
])], stroke:none, width: 5cm, name: <history>)
|
||||
node(snap: false, enclose: (<A>, <history>, <E3>), stroke: thindashed, width: 3cm, fill: gray.lighten(70%))
|
||||
// refs
|
||||
node(refs, stroke: thin, inset:5pt, snap: false, enclose: (refs, (refs.at(0)+1, refs.at(1)+1)),
|
||||
/*
|
||||
node(refs, stroke: thin, inset:5pt, snap: false, enclose: (refs, (refs.at(0)+1cm, refs.at(1)+1cm)),
|
||||
align(left, [
|
||||
*References* (`.git/refs`)\ *Tags* (`.git/refs/tags`)\ `tag-1`: `8dd6d4b...`\ *Branches* (`.git/refs/heads`) \ `main`: `8dd6d4b...`\
|
||||
`feature-1`: `8dd6d4b...`\
|
||||
|
|
@ -109,34 +133,26 @@ committer MV <mv...
|
|||
Add bar.txt
|
||||
```]
|
||||
], width:5cm, stroke: thin, corner-radius: 10pt)
|
||||
node((G.at(0)+0.4, G.at(1) - 0.3), [*Version history*\
|
||||
#align(left, text(size: 8pt)[
|
||||
_Directed Acyclic Graph (DAG)_ describes version history.
|
||||
Commits are nodes in DAG, while an edge connect a commit with its parent.
|
||||
])], stroke:none, width: 5cm)
|
||||
node(A, snap: false, enclose: (A, E3), stroke: thindashed, width: 3cm, fill: gray.lighten(70%))
|
||||
let ic = (A.at(0)+0.7, A.at(1)-0.2);
|
||||
node(ic, [Initial commit], shape: pill, stroke: thin)
|
||||
edge(ic, A, stroke: thindotted)
|
||||
*/
|
||||
// history
|
||||
edge(B, A, "->")
|
||||
edge(C, B, "->")
|
||||
edge(D, C, "->")
|
||||
edge(E, D, "->")
|
||||
edge(F, E, "->")
|
||||
edge(<B>, <A>, "->")
|
||||
edge(<C>, <B>, "->")
|
||||
edge(<D>, <C>, "->")
|
||||
edge(<E>, <D>, "->")
|
||||
edge(<F>, <E>, "->")
|
||||
// merged branch
|
||||
edge(B1, B, "->", layer: 1, label: [parent of], label-angle: auto)
|
||||
edge(B2, B1, "->")
|
||||
edge(D, B2, "->")
|
||||
edge(<B1>, <B>, "->", layer: 1, label: [parent of], label-angle: auto)
|
||||
edge(<B2>, <B1>, "->")
|
||||
edge(<D>, <B2>, "->")
|
||||
// unmerged branch
|
||||
edge(E1, E, "->")
|
||||
edge(E2, E1, "->")
|
||||
edge(E3, E2, "->", stroke: (dash: "dashed"))
|
||||
edge(<E1>, <E>, "->")
|
||||
edge(<E2>, <E1>, "->")
|
||||
edge(<E3>, <E2>, "->", stroke: (dash: "dashed"))
|
||||
// refs
|
||||
edge(Br1, F)
|
||||
edge(Br2, E2)
|
||||
edge(T1, E)
|
||||
edge(T2, B)
|
||||
/*
|
||||
edge(Br1, branches, stroke: thindotted)
|
||||
edge(Br2, branches, stroke: thindotted)
|
||||
edge(T1, tags, stroke: thindotted)
|
||||
|
|
@ -145,5 +161,6 @@ Add bar.txt
|
|||
edge(stage, E3, stroke: thindotted)
|
||||
edge((-0.5, A.at(1)), (-0.5, G.at(1)), "->", label: [time], label-side: left, label-angle: 90deg)
|
||||
edge(mc, D, stroke: thindotted)
|
||||
*/
|
||||
}
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue