Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support path lists in layer expressions #1111

Merged
merged 4 commits into from Sep 27, 2022
Merged

feat: support path lists in layer expressions #1111

merged 4 commits into from Sep 27, 2022

Conversation

wodeni
Copy link
Member

@wodeni wodeni commented Sep 26, 2022

Description

Related issue/PR: N/A

There are a lot of duplicated layering statements in Style programs such as euclidean.sty. Mostly saying one thing should be below/above multiple things:

  t.PQ above P.icon
  t.QR above P.icon
  t.RP above P.icon

This PR lets layer expressions take a list of paths on the right-hand side of the layering operator. For instance, the above can be abbreviated to P.icon below t.PQ, t.QR, t.RP.

Implementation strategy and design decisions

  • The Style parser parses all layer expressions as path ("below"|"above") path_list. There's only one path allowed on the left to simplify the semantics. path_list can be a list of just one element.
    • The parser is changed to not special-case on below and above cases. In general, I try to maintain the original code structure in the AST and not do any computation (e.g. sorting below, above pairs) in the parser. This is mostly for better language services.
  • In the Style compiler, we convert the layering list expressions to individual layering pairs.

Examples with steps to reproduce them

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new ESLint warnings
  • I have reviewed any generated changes to the diagrams/ folder

@codecov
Copy link

codecov bot commented Sep 26, 2022

Codecov Report

Merging #1111 (789c837) into main (a3f8e5c) will increase coverage by 0.01%.
The diff coverage is 81.81%.

@@            Coverage Diff             @@
##             main    #1111      +/-   ##
==========================================
+ Coverage   64.73%   64.74%   +0.01%     
==========================================
  Files          59       59              
  Lines        7487     7495       +8     
  Branches     1685     1688       +3     
==========================================
+ Hits         4847     4853       +6     
- Misses       2539     2541       +2     
  Partials      101      101              
Impacted Files Coverage Δ
packages/core/src/compiler/Style.ts 67.24% <81.81%> (+0.04%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@github-actions
Copy link

github-actions bot commented Sep 26, 2022

📊 Performance

Key

Note that each bar component rounds up to the nearest 100ms, so each full bar is an overestimate by up to 400ms.

     0s   1s   2s   3s   4s   5s   6s   7s   8s   9s
     |    |    |    |    |    |    |    |    |    |
name ▝▀▀▀▀▀▀▀▀▀▀▀▚▄▄▄▄▄▄▄▄▄▞▀▀▀▀▀▀▀▀▀▀▀▀▚▄▄▄▄▄▄▄▄▄▖
      compilation labelling optimization rendering

Data

                                        0s   1s   2s   3s   4s   5s   6s   7s   8s   9s  10s  11s  12s  13s  14s  15s  16s  17s  18s  19s  20s  21s  22s  23s  24s  25s  26s  27s  28s  29s  30s  31s  32s  33s  34s  35s  36s  37s  38s  39s  40s  41s  42s  43s  44s  45s  46s  47s  48s  49s  50s  51s  52s  53s  54s  55s  56s  57s  58s  59s  60s  61s  62s  63s  64s  65s  66s  67s  68s  69s  70s  71s  72s  73s  74s  75s  76s  77s  78s  79s  80s  81s  82s  83s  84s  85s  86s  87s  88s  89s  90s  91s  92s  93s  94s  95s  96s  97s  98s  99s 100s
                                        |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |
3d-projection-fake-3d-linear-algebra    ▝▀▞▖
allShapes-dashedShapes                  ▝▞▖
circle-example-euclidean                ▝▀▀▀▀▞▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▚
collinear-euclidean                     ▝▀▀▚▀▚
congruent-triangles-euclidean           ▝▀▀▀▀▀▀▀▀▚▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▖
continuousmap-continuousmap             ▝▀▀▞▖
hypergraph-hypergraph                   ▝▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▚▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄
incenter-triangle-euclidean             ▝▀▀▀▚▀▀▀▀▚
lagrange-bases-lagrange-bases           ▝▀▚▚
midsegment-triangles-euclidean          ▝▀▀▀▞▖
non-convex-non-convex                   ▝▀▀▀▀▞▀▀▀▀▀▖
one-water-molecule-atoms-and-bonds      ▝▚▚
parallel-lines-euclidean                ▝▀▀▚▀▖
persistent-homology-persistent-homology ▝▀▀▀▀▀▀▀▀▀▞▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▘⋯
points-around-line-shape-distance       ▝▀▀▀▀▀▀▚▀▖
points-around-polyline-shape-distance   ▝▀▀▀▀▀▀▀▀▀▀▀▀▀▚▀▀▖
points-around-star-shape-distance       ▝▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▚▀▚
siggraph-teaser-euclidean-teaser        ▝▀▀▀▀▚▀▀▖
small-graph-disjoint-rect-line-horiz    ▝▀▀▀▀▀▀▀▀▀▚▀▖
small-graph-disjoint-rects              ▝▀▚▚
small-graph-disjoint-rects-large-canvas ▝▀▚▚
small-graph-disjoint-rects-small-canvas ▝▀▚▚
tree-venn                               ▝▀▀▀▀▄▀▚
tree-venn-3d                            ▝▀▀▀▀▀▞▀▀▚▄▖
two-vectors-perp-vectors-dashed         ▝▀▚▚
wet-floor-atoms-and-bonds               ▝▀▀▀▚▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▚
wos-laplace-estimator-walk-on-spheres   ▝▀▀▀▀▀▞▀▀▀▖
wos-nested-estimator-walk-on-spheres    ▝▀▀▀▀▀▀▀▞▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▚
wos-offcenter-estimator-walk-on-spheres ▝▀▀▀▀▚▀▀▀▀▀▖
wos-poisson-estimator-walk-on-spheres   ▝▀▀▀▀▞▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▚

@cloudflare-pages
Copy link

cloudflare-pages bot commented Sep 26, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 789c837
Status: ✅  Deploy successful!
Preview URL: https://6a5c6bc8.penrose-72l.pages.dev
Branch Preview URL: https://layer-list.penrose-72l.pages.dev

View logs

Copy link
Collaborator

@samestep samestep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Good to merge once we update the variation for diagrams/siggraph-teaser-euclidean-teaser.svg.

@wodeni wodeni merged commit e1340e8 into main Sep 27, 2022
@wodeni wodeni deleted the layer-list branch September 27, 2022 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants