Comments (5)
Thanks for writing this up @liangyiliang!
For a basic, non-group shape, I think this involves walking through all numerical properties of the shape, and recursively looking for ad.Var. For group shapes we need to walk through all sub-shapes too.
I think computeShapes
gives you Shape<number>[]
, so you probably can't find the ad.Var
s there. Other related functions such as genCode
also don't give you the information. You'd need to manually accumulate this info from the Style compiler. Also tagging @hsharriman for visibility.
from penrose.
Proposal
The user would first input Substance program sub1
. After Penrose generates the diagram for sub1
, the user would then provide sub2
(which would presumably be modified from sub1
). When Penrose generates the diagram for sub2
, the expected behavior is:
- shapes that are associated with both
sub1
andsub2
would be "frozen" - shapes that are associated with
sub1
but not associated withsub2
would be removed - shapes that are not associated with
sub1
but associated withsub2
would be added and allowed to freely change.
Since shapes are defined by their properties which may refer to varying values, we can't really "freeze" a shape without freezing the underlying varying values. So we actually care about the varying values that are associated with the shapes which are then associated with the Substance program.
Association between Varying Value and Shape
A shape is defined as a set of properties, each of which may refer to some varying values. Given a shape, we would need to extract the varying values that are used, by any means, in the shape. For a basic, non-group shape, I think this involves walking through all numerical properties of the shape, and recursively looking for ad.Var
. For group shapes we need to walk through all sub-shapes too.
Association between Shape and Substance
A shape is "associated with" a Substance program iff it is associated with some statement(s) in the Substance program. In this case, we are only interested in statements in the post-compilation version of the Substance program (CompiledSubProg
) where all declaration-lists (DeclList
), declaration-binds (DeclBind
), and indexed sets are flattened. Doing so allows us to only consider single object declarations (Decl
), object bindings (Bind
), and predicate applications (ApplyPredicate
).
Given a Substance statement, we thought of two ways where a shape can be associated with a Substance statement.
Association by path: If we have Substance object x
(or predicate application, since predicates can have aliases), then a shape is associated with x
iff the shape is named `x`.some_name
. This defines association as "belonging" -- `x`.some_name
belongs to x
.
Association by causation: If the shape is generated as a result of matching upon a Substance statement, then that shape is associated with the statement. As an example, if this Style program
forall Node x, y
where e := MkEdge(x, y)
with Edge e {
icon = Line { ... }
}
is activated, then the Line
shape would be associated with the Substance instances of x
, y
, e
(these are declarations), and e := MkEdge(x, y)
(as a relation).
We would preferably want both forms of associations.
Note: My intuition is that association by causation already implies association by path, since if we can define a shape with name `x`.some_name
, then we must have matched on the Substance object x
. Is that true? If so, we won't need association by path.
from penrose.
You'd need to manually accumulate this info from the Style compiler.
Doesn't State.shapes
provide you a list of Shape<ad.Num>
?
from penrose.
@eskang and @keenancrane It would be great if you can provide comments or ask questions on this issue.
from penrose.
You'd need to manually accumulate this info from the Style compiler.
Doesn't
State.shapes
provide you a list ofShape<ad.Num>
?
You're probably right. Note that State.shapes
isn't really used much, perhaps nowhere other than collectLabels
. Give it a try and see if you can match up shape properties with varying values by strict equality (===
).
Double-checking with @samestep: does this sound reasonable?
from penrose.
Related Issues (20)
- Integration with Typst project HOT 7
- Error: Style internal error: expected to be either a constructor or function, but was not found HOT 3
- NaN in polyline points leads to rust panic HOT 2
- Missing local HOT 4
- Docs missing for `repeatable`
- bboxFromPath expected pathData to be nonempty HOT 1
- Support specifying initial value to varying values.
- Style Selectors on Nonexistent Function Names
- Cannot share gists with empty programs in the IDE
- Example at https://penrose.cs.cmu.edu/docs/ref/api does not compile
- Error when parsing floating-point numbers in Substance
- Improper handling of `Prop`-typed expressions in Substance HOT 1
- Nested function calls in Substance
- Multiple bugs related to tracking state changes when saving drafts and workspaces in the editor HOT 1
- UX improvements for saving/editing in the editor
- Incorrect handling of indexed sets with flipped ranges HOT 2
- Style `toString` functionality HOT 2
- Run in non-browser environments HOT 4
- Document arrowhead types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from penrose.