Skip to content

Commit

Permalink
Merge branch 'web-runtime'
Browse files Browse the repository at this point in the history
  • Loading branch information
wodeni committed Oct 13, 2020
2 parents 66e1e27 + 3c3d83f commit 46564b4
Show file tree
Hide file tree
Showing 118 changed files with 39,345 additions and 17,519 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ dist-newstyle/
examples/plugins/alloy/__temp.als__
.java-version
temp.als
.*.sw*

8 changes: 8 additions & 0 deletions UserGuide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
In `penrose/react-renderer/src`, run `npm start`
In `penrose/examples/` run `runpenrose my.sub my.sty my.domain`

Shape library:
https://github.com/penrose/penrose/wiki/Shape-and-function-library

Tensor flow math operations:
https://js.tensorflow.org/api/latest/#Operations
25 changes: 12 additions & 13 deletions automator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const mathjax = require("mathjax-node");
const { propagateUpdate } = require("../react-renderer/src/PropagateUpdate");
const Canvas = require("../react-renderer/src/Canvas");
const Packets = require("../react-renderer/src/packets");
// const { loadImages } = require("../react-renderer/src/Util"); // TODO: implement image import
const ReactDOMServer = require("react-dom/server");
const { spawn } = require("child_process");
const chalk = require("chalk");
Expand Down Expand Up @@ -33,7 +32,7 @@ const nonZeroConstraints = (
) => {
const constrFns = state.constrFns;
const fnsWithVals = constrFns.map((f, i) => [f, constrVals[i]]);
const nonzeroConstr = fnsWithVals.filter(c => +c[1] > threshold);
const nonzeroConstr = fnsWithVals.filter((c) => +c[1] > threshold);
return nonzeroConstr;
};

Expand All @@ -47,10 +46,10 @@ const runPenrose = (packet: object) =>
penrose.stdin.setEncoding("utf-8");
penrose.stdin.write(JSON.stringify(packet) + "\n");
let data = "";
penrose.stdout.on("data", async d => {
penrose.stdout.on("data", async (d) => {
data += d.toString();
});
penrose.stdout.on("close", async cl => {
penrose.stdout.on("close", async (cl) => {
resolve(data);
});

Expand Down Expand Up @@ -79,7 +78,7 @@ const collectLabels = async (state: any, includeRendered: boolean) => {
svgNode: true,
useFontCache: false,
useGlobalCache: false,
ex: 12
ex: 12,
});
if (data.errors) {
console.error(
Expand Down Expand Up @@ -107,7 +106,7 @@ const collectLabels = async (state: any, includeRendered: boolean) => {

if (includeRendered) {
textGPI.rendered = {
contents: data.svgNode
contents: data.svgNode,
};
}
return [type, textGPI];
Expand All @@ -121,7 +120,7 @@ const collectLabels = async (state: any, includeRendered: boolean) => {
state.shapeOrdering
);
// update the state with newly generated labels and label dimensions
const updated = await propagateUpdate({ ...state, shapesr: sortedShapes });
const updated = await propagateUpdate({ ...state, shapes: sortedShapes });
return updated;
};

Expand All @@ -139,11 +138,11 @@ const singleProcess = async (
substanceName: sub,
styleName: sty,
domainName: dsl,
id: uniqid("instance-")
id: uniqid("instance-"),
}
) => {
// Fetch Substance, Style, and Domain files
const trio = [sub, sty, dsl].map(arg =>
const trio = [sub, sty, dsl].map((arg) =>
fs.readFileSync(`${prefix}/${arg}`, "utf8").toString()
);
console.log(`Compiling for ${out}/${sub} ...`);
Expand Down Expand Up @@ -205,15 +204,15 @@ const singleProcess = async (
compilation: convertHrtime(compileEnd).milliseconds,
labelling: convertHrtime(labelEnd).milliseconds,
optimization: convertHrtime(convergeEnd).milliseconds,
rendering: convertHrtime(reactRenderEnd).milliseconds
rendering: convertHrtime(reactRenderEnd).milliseconds,
},
violatingConstraints: constrs,
nonzeroConstraints: constrs.length > 0,
selectorMatches: optimizedState.selectorMatches,
optProblem: {
constraintCount: optimizedState.constrFns.length,
objectiveCount: optimizedState.objFns.length
}
objectiveCount: optimizedState.objFns.length,
},
};
if (!fs.existsSync(out)) {
fs.mkdirSync(out);
Expand Down Expand Up @@ -290,7 +289,7 @@ const batchProcess = async (
substanceName: name,
styleName,
domainName,
id
id,
}
);
if (folders) {
Expand Down
22 changes: 22 additions & 0 deletions examples/ThoughtsAndIssues.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Should whitespace be ignored in notation?

When a constructor's arguments are not named, the error message is cryptic

Should be possible to specify floating point numbers in any standard way (e.g., 0. instead of 0.0)

Should be possible to specify colors in hex

Should be possible to use notation in Style

Make it clearer what the canvas size is, and make it possible to set the canvas size

Maybe do automatic "upgrades" of integer to float in Style?

Shouldn't be forced to put open brace ({) on same line as block name in Style

Should allow local scoping, i.e., variables defined within a scope should be referencable within that scope without the scope name. E.g., Global { width = 1.23; height = width/2.0; }
(More generally: just think about scoping, and how we can perhaps have shorter references)

Substance should support Unicode characters

Should be possible to use arbitrary Unicode characters in notation
Loading

0 comments on commit 46564b4

Please sign in to comment.