Skip to content

Commit d413967

Browse files
authored
Merge pull request #111 from mrwunderbar666/main
add cylinder and database shapes
2 parents dcb49cf + 2b88859 commit d413967

File tree

6 files changed

+70
-0
lines changed

6 files changed

+70
-0
lines changed

docs/manual.pdf

-1.75 KB
Binary file not shown.

src/shapes.typ

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,64 @@
647647
}
648648
})
649649

650+
651+
/// A pseudo-3D cylindrical shape.
652+
///
653+
/// #diagram(
654+
/// node-stroke: green,
655+
/// node-fill: green.lighten(90%),
656+
/// node((0,0), [cylinder], shape: fletcher.shapes.cylinder),
657+
/// )
658+
///
659+
#let cylinder(node, extrude) = {
660+
let (w, h) = node.size
661+
let x = 0.5 * w
662+
let y = 0.5 * h
663+
let y_offset = 0.15 * h
664+
665+
y += extrude
666+
x += extrude
667+
668+
let obj = {
669+
draw.rect((-x, -y + y_offset), (x, y + y_offset), stroke: 0pt)
670+
draw.line((-x, -y + y_offset), (-x, y + y_offset))
671+
draw.line((x, -y + y_offset), (x, y + y_offset))
672+
draw.circle((0, y + y_offset), radius: (x, 0.2))
673+
draw.arc((x, -y+ y_offset), start: 0deg, stop: -180deg, radius: (x, 0.2))
674+
}
675+
draw.group(obj)
676+
}
677+
678+
679+
/// A database shape (stacked pseudo-3D cylindrical shape).
680+
///
681+
/// #diagram(
682+
/// node-stroke: luma(120),
683+
/// node-fill: blue.lighten(90%),
684+
/// node((0,0), [database], shape: fletcher.shapes.database),
685+
/// )
686+
///
687+
#let database(node, extrude) = {
688+
let (w, h) = node.size
689+
let y_offset = 0.25 * h
690+
let y = 0.6 * h
691+
let x = 0.5 * w
692+
693+
y += extrude
694+
x += extrude
695+
696+
let obj = {
697+
draw.rect((-x, -y + y_offset), (x, y + y_offset), stroke: (0pt))
698+
draw.line((-x, -y + y_offset), (-x, y + y_offset))
699+
draw.line((x, -y + y_offset), (x, y + y_offset))
700+
draw.arc((x, y), start: 0deg, stop: -180deg, radius: (x, 0.2))
701+
draw.circle((0, y + y_offset), radius: (x, 0.2))
702+
draw.arc((x, -y+ y_offset), start: 0deg, stop: -180deg, radius: (x, 0.2))
703+
}
704+
draw.group(obj)
705+
}
706+
707+
650708
#let ALL_SHAPES = (
651709
rect: rect,
652710
circle: circle,
@@ -663,4 +721,6 @@
663721
brace: brace,
664722
bracket: bracket,
665723
paren: paren,
724+
cylinder: cylinder,
725+
database: database,
666726
)

tests/anchors/ref/3.png

6.77 KB
Loading

tests/node/shapes/ref/3.png

3.83 KB
Loading

tests/node/shapes/ref/9.png

5.87 KB
Loading

tests/node/shapes/test.typ

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,13 @@ Fit factor
141141
}
142142
},
143143
)
144+
145+
#pagebreak()
146+
147+
#diagram(
148+
node-stroke: green,
149+
node-fill: green.lighten(90%),
150+
node((0,0), [Local], shape: shapes.cylinder, name: <cylinder-local>),
151+
node((2,0), [Remote], shape: shapes.database, name: <db-remote>),
152+
edge(<cylinder-local>, <db-remote>, ">->", [Backup])
153+
)

0 commit comments

Comments
 (0)