-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into remove-ast-children-field
- Loading branch information
Showing
15 changed files
with
281 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require("fs"); | ||
const Handlebars = require("handlebars"); | ||
const path = require("path"); | ||
|
||
const slurp = (p) => fs.readFileSync(p).toString(); | ||
const example = (p) => slurp(path.join("packages/examples/src", p)); | ||
|
||
const sub = "tree"; | ||
const sty = "venn"; | ||
|
||
const { trios, domains, styles, substances } = JSON.parse( | ||
example("registry.json") | ||
); | ||
|
||
const matching = trios.filter( | ||
({ substance, style }) => substance === sub && style === sty | ||
); | ||
if (matching.length !== 1) { | ||
throw Error(`expected exactly one matching trio, got ${matching.length}`); | ||
} | ||
const [{ substance, style, domain, variation }] = matching; | ||
|
||
const dslURI = domains[domain].URI; | ||
const subURI = substances[substance].URI; | ||
const styURI = styles[style].URI; | ||
|
||
for (const name of ["domain", "substance", "style"]) { | ||
Handlebars.registerPartial(name, `{{{${name}}}}`); | ||
} | ||
|
||
fs.writeFileSync( | ||
"README.md", | ||
Handlebars.compile(slurp(".github/readme_template.hbs"))({ | ||
svg: `diagrams/${sub}-${sty}.svg`, | ||
variation, | ||
dsl: path.basename(dslURI), | ||
sub: path.basename(subURI), | ||
sty: path.basename(styURI), | ||
domain: example(dslURI), | ||
substance: example(subURI), | ||
style: example(styURI), | ||
}) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Penrose [![Build](https://github.com/penrose/penrose/actions/workflows/build.yml/badge.svg)](https://github.com/penrose/penrose/actions/workflows/build.yml) [![codecov](https://codecov.io/gh/penrose/penrose/branch/main/graph/badge.svg?token=opGTmY4rkK)](https://codecov.io/gh/penrose/penrose) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) [![license](https://img.shields.io/github/license/penrose/penrose)](LICENSE) [![Twitter: @UsePenrose](https://img.shields.io/twitter/follow/UsePenrose?style=social)](https://twitter.com/UsePenrose) | ||
|
||
[Penrose](https://penrose.cs.cmu.edu/) is a platform that enables people to | ||
**create beautiful diagrams just by typing mathematical notation in plain | ||
text.** The goal is to make it easy for non-experts to create and explore | ||
high-quality diagrams and provide deeper insight into challenging technical | ||
concepts. We aim to democratize the process of creating visual intuition. | ||
|
||
Check out our [SIGGRAPH '20 paper](https://penrose.cs.cmu.edu/siggraph20) and | ||
[video](https://vimeo.com/416822487) on Penrose! | ||
|
||
## Usage | ||
|
||
You can [try Penrose in your browser](https://penrose.cs.cmu.edu/try/) without | ||
any installation. For a more detailed step-by-step introduction, check out our | ||
[tutorials](https://penrose.cs.cmu.edu/docs/tutorial/welcome). Or, for more | ||
reference-style information, take a look at our | ||
[documentation](https://penrose.cs.cmu.edu/docs/ref/). | ||
|
||
## Example | ||
|
||
Here's a simple Penrose visualization in the domain of set theory. | ||
|
||
<img src="{{svg}}" width=500> | ||
|
||
It's specified by the following trio of Domain, Substance, and Style programs | ||
(with variation `{{variation}}`): | ||
|
||
- `{{dsl}}`: | ||
|
||
``` | ||
{{> domain }} | ||
``` | ||
|
||
- `{{sub}}`: | ||
|
||
``` | ||
{{> substance }} | ||
``` | ||
|
||
- `{{sty}}`: | ||
|
||
``` | ||
{{> style }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,100 @@ | ||
# Penrose [![Build](https://github.com/penrose/penrose/actions/workflows/build.yml/badge.svg)](https://github.com/penrose/penrose/actions/workflows/build.yml) [![codecov](https://codecov.io/gh/penrose/penrose/branch/main/graph/badge.svg?token=opGTmY4rkK)](https://codecov.io/gh/penrose/penrose) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) [![license](https://img.shields.io/github/license/penrose/penrose)](LICENSE) [![Twitter: @UsePenrose](https://img.shields.io/twitter/follow/UsePenrose?style=social)](https://twitter.com/UsePenrose) | ||
|
||
**Penrose is an early-stage system that is still in development.** Our system is not ready for contributions or public use yet, but hopefully will be soon. Send us an email if you're interested in collaborating. | ||
[Penrose](https://penrose.cs.cmu.edu/) is a platform that enables people to | ||
**create beautiful diagrams just by typing mathematical notation in plain | ||
text.** The goal is to make it easy for non-experts to create and explore | ||
high-quality diagrams and provide deeper insight into challenging technical | ||
concepts. We aim to democratize the process of creating visual intuition. | ||
|
||
- See [the site](http://www.penrose.ink/) for more information and examples. | ||
- See the [wiki](https://github.com/penrose/penrose/wiki) for more system-specific information on building, running, testing, and debugging the system. | ||
- For even more documentation, see Nimo Ni's [README](https://github.com/wodeni/notes-public/blob/master/penrose/archive/ramp-down.md). | ||
Check out our [SIGGRAPH '20 paper](https://penrose.cs.cmu.edu/siggraph20) and | ||
[video](https://vimeo.com/416822487) on Penrose! | ||
|
||
### Example | ||
## Usage | ||
|
||
You can [try Penrose in your browser](https://penrose.cs.cmu.edu/try/) without | ||
any installation. For a more detailed step-by-step introduction, check out our | ||
[tutorials](https://penrose.cs.cmu.edu/docs/tutorial/welcome). Or, for more | ||
reference-style information, take a look at our | ||
[documentation](https://penrose.cs.cmu.edu/docs/ref/). | ||
|
||
## Example | ||
|
||
Here's a simple Penrose visualization in the domain of set theory. | ||
|
||
<img src="https://i.imgur.com/3JHZeaX.png" width=300> | ||
<img src="diagrams/tree-venn.svg" width=500> | ||
|
||
It's specified by the following Substance and Style programs. | ||
It's specified by the following trio of Domain, Substance, and Style programs | ||
(with variation `CasalViper643`): | ||
|
||
- `setTheory.dsl`: | ||
|
||
- `tree.sub` | ||
``` | ||
Set A | ||
Set B | ||
Set C | ||
Set D | ||
Set E | ||
Set F | ||
Set G | ||
Subset B A | ||
Subset C A | ||
Subset D B | ||
Subset E B | ||
Subset F C | ||
Subset G C | ||
NoIntersect E D | ||
NoIntersect F G | ||
NoIntersect B C | ||
type Set | ||
predicate Not(Prop p1) | ||
predicate Intersecting(Set s1, Set s2) | ||
predicate IsSubset(Set s1, Set s2) | ||
``` | ||
- `venn.sty` | ||
|
||
- `tree.sub`: | ||
|
||
``` | ||
Set x { | ||
shape = Circle { } | ||
constraint contains(x, x.label) | ||
} | ||
Set A, B, C, D, E, F, G | ||
IsSubset(B, A) | ||
IsSubset(C, A) | ||
IsSubset(D, B) | ||
IsSubset(E, B) | ||
IsSubset(F, C) | ||
IsSubset(G, C) | ||
Not(Intersecting(E, D)) | ||
Not(Intersecting(F, G)) | ||
Not(Intersecting(B, C)) | ||
AutoLabel All | ||
``` | ||
|
||
Intersect x y { | ||
constraint overlapping(x, y) | ||
constraint disjoint(y.label, x) | ||
constraint disjoint(x.label, y) | ||
} | ||
- `venn.sty`: | ||
|
||
NoIntersect x y { | ||
constraint nonOverlapping(x, y) | ||
``` | ||
canvas { | ||
width = 800 | ||
height = 700 | ||
} | ||
Subset x y { | ||
constraint contains(y, x) | ||
constraint smallerThan(x, y) | ||
constraint disjoint(y.label, x) | ||
forall Set x { | ||
x.icon = Circle { | ||
strokeWidth : 0 | ||
} | ||
x.text = Equation { | ||
string : x.label | ||
fontSize : "25px" | ||
} | ||
ensure contains(x.icon, x.text) | ||
encourage sameCenter(x.text, x.icon) | ||
x.textLayering = x.text above x.icon | ||
} | ||
NoSubset x y { | ||
objective repel(x, y) | ||
constraint disjoint(x, y) | ||
constraint disjoint(y.label, x) | ||
constraint disjoint(x.label, y) | ||
constraint nonOverlapping(x, y) | ||
forall Set x; Set y | ||
where IsSubset(x, y) { | ||
ensure smallerThan(x.icon, y.icon) | ||
ensure disjoint(y.text, x.icon, 10) | ||
ensure contains(y.icon, x.icon, 5) | ||
x.icon above y.icon | ||
} | ||
forall Set x; Set y | ||
where Not(Intersecting(x, y)) { | ||
ensure disjoint(x.icon, y.icon) | ||
} | ||
forall Set x; Set y | ||
where Intersecting(x, y) { | ||
ensure overlapping(x.icon, y.icon) | ||
ensure disjoint(y.text, x.icon) | ||
ensure disjoint(x.text, y.icon) | ||
} | ||
``` | ||
|
||
Here's how the optimization looks live in the UI. | ||
|
||
<img src="https://i.imgur.com/Q27Xgbn.gif" width=500> |
Oops, something went wrong.