Skip to content

Instantly share code, notes, and snippets.

@maxkrieger
Created Apr 20, 2021
Embed
What would you like to do?
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