Skip to content

Instantly share code, notes, and snippets.

@maxkrieger
Created April 20, 2021 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxkrieger/1bf491255c51ccdca850c503a3122272 to your computer and use it in GitHub Desktop.
Save maxkrieger/1bf491255c51ccdca850c503a3122272 to your computer and use it in GitHub Desktop.
exgraph-example: a trio from https://penrose.ink
type Graph
predicate not : Graph g1
predicate and : Graph g1 * Graph g2
predicate or : Graph g1 * Graph g2
predicate if : Graph g1 * Graph g2
Graph a {
a.shape = Circle {
strokeWidth: 0
}
a.text = Text {
string: a.label
}
ensure minSize(a.shape)
ensure maxSize(a.shape)
encourage sameCenter(a.text, a.shape)
}
Graph a; Graph b
where or(a, b) {
-- make a shape for outer circle
orShape = Circle {
center: (0, 0)
}
-- a’s shape is in it
ensure contains(orShape, a.shape)
-- b’s shape is in it
ensure contains(orShape, b.shape)
-- size functions
ensure minSize(orShape)
ensure maxSize(orShape)
-- a’s shape and b’s shape don’t overlap
ensure disjoint(a.shape, b.shape)
-- a’s shape and b’s shape are the same size? are they aligned? etc.
override a.shape.r = b.shape.r
override a.shape.color = b.shape.color
}
Graph p, q
or(p, q)
AutoLabel All
{"authorship":{"madeBy":"maxkrieger","name":"exgraph-example","avatar":"https://avatars.githubusercontent.com/u/2660634?v=4"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment