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: customizable arrowheads on both ends + new arrowhead styles #1140

Merged
merged 18 commits into from
Nov 16, 2022

Conversation

wodeni
Copy link
Member

@wodeni wodeni commented Nov 10, 2022

Description

Related issue/PR: #255, #1057

This PR introduces a few arrowhead styles inspired by quiver. The names for the arrowhead styles are still tentative. We also refactor the arrowhead properties for both Line and Path:

  • changed startArrowhead and endArrowhead from booleans to strings and just remove arrowheadStyle
  • remove arrowheadSize and add startArrowheadSize and endArrowheadSize

This PR also helps with the effort on the Lean side with @Vtec234 : leanprover-community/mathlib4#363

Implementation strategy and design decisions

  • Continued to use the same data structure for storing arrowhead templates, which is a bit low-level and repetitive
  • Because the new styles are stroked not filled, added a flag indicating the fill pattern
  • Added a new design template in the registry to test out arrow behaviors and provide a reference to arrow styles
  • Standardized the naming convention in the codebase
  • Fixed bug in makeRoomForArrows

Examples with steps to reproduce them

Design file can be found in example registry arrows-arrows:

Untitled Diagram(19)

A demo of different arrowhead settings per end:
https://arrow-styles.penrose-72l.pages.dev/try/?gist=ae798b3e7e7d14cfb09229aeedb981a9

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

Open questions

  • Adding an arrowhead style is kind of a pain. Haven't figured out the relationship among viewbox, refX/Y, and width/height. How we can make it simpler than the current API?

@wodeni wodeni self-assigned this Nov 10, 2022
@wodeni wodeni marked this pull request as draft November 10, 2022 05:12
@codecov
Copy link

codecov bot commented Nov 10, 2022

Codecov Report

Merging #1140 (0eb5911) into main (95b7f3e) will decrease coverage by 0.23%.
The diff coverage is 6.25%.

@@            Coverage Diff             @@
##             main    #1140      +/-   ##
==========================================
- Coverage   64.80%   64.56%   -0.24%     
==========================================
  Files          59       59              
  Lines        7600     7629      +29     
  Branches     1697     1709      +12     
==========================================
+ Hits         4925     4926       +1     
- Misses       2574     2598      +24     
- Partials      101      105       +4     
Impacted Files Coverage Δ
packages/core/src/shapes/Line.ts 100.00% <ø> (ø)
packages/core/src/shapes/Path.ts 100.00% <ø> (ø)
packages/core/src/renderer/Line.ts 5.45% <2.32%> (-1.22%) ⬇️
packages/core/src/renderer/Path.ts 9.52% <6.25%> (-0.61%) ⬇️
packages/core/src/utils/Util.ts 61.02% <40.00%> (-0.40%) ⬇️

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 Nov 10, 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                  ▝▞▖
arrowheads-arrowheads                   ▝▀▞▖
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         ▝▀▞▖
vector-wedge-exterior-algebra           ▝▀▚▚
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 Nov 10, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0eb5911
Status: ✅  Deploy successful!
Preview URL: https://c45c9f9b.penrose-72l.pages.dev
Branch Preview URL: https://arrow-styles.penrose-72l.pages.dev

View logs

@wodeni wodeni changed the title feat: add arrowhead styles for Line feat: add new arrowhead styles Nov 10, 2022
@wodeni wodeni changed the title feat: add new arrowhead styles feat: customizable arrowheads on both ends + new arrowhead styles Nov 10, 2022
@wodeni wodeni marked this pull request as ready for review November 10, 2022 23:09
@wodeni wodeni requested a review from samestep November 11, 2022 19:52
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.

Looks great, thanks for doing this!

@wodeni wodeni merged commit 0f60f05 into main Nov 16, 2022
@wodeni wodeni deleted the arrow-styles branch November 16, 2022 22:14
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