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

Bezigon Primitive #379

Merged
merged 1 commit into from
Jan 18, 2020
Merged

Bezigon Primitive #379

merged 1 commit into from
Jan 18, 2020

Conversation

Mattriks
Copy link
Member

@Mattriks Mattriks commented Jan 4, 2020

  • I've updated the documentation to reflect these changes
  • I've built the docs and confirmed these changes don't cause new errors
  • I've added and/or updated the unit tests
  • I've run the regression tests

This PR

To do

  • Implement bezigon for the PGF backend.
  • Support quadratic beziers by transforming to cubic (for Cairo)

Example

petal = [[(0.4, 0.4), (0.4, 0.2), (0.5, 0.0)],  [(0.6, 0.2), (0.6, 0.4), (0.5, 0.5)]]
petalf::Float64) =    (context(rotation=Rotation(θ, 0.5,0.5)),
    bezigon((0.5, 0.5), petal), fill(LCHuvA(70.,50., 360*θ/2π, 0.4)) )

 theta = range/20, 2π, step=2π/10) .-π
 compose(context(), petalf.(theta)...)

petals

@Mattriks
Copy link
Member Author

Mattriks commented Jan 4, 2020

@Vectornaut please test this branch & provide feedback.

@codecov-io
Copy link

codecov-io commented Jan 4, 2020

Codecov Report

Merging #379 into master will increase coverage by 1.42%.
The diff coverage is 72.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #379      +/-   ##
==========================================
+ Coverage   40.81%   42.24%   +1.42%     
==========================================
  Files          18       18              
  Lines        3058     3151      +93     
==========================================
+ Hits         1248     1331      +83     
- Misses       1810     1820      +10
Impacted Files Coverage Δ
src/Compose.jl 31.64% <ø> (+5.39%) ⬆️
src/misc.jl 59.77% <ø> (+3.44%) ⬆️
src/pgf_backend.jl 46.21% <0%> (-3.36%) ⬇️
src/svg.jl 72.75% <100%> (+1.57%) ⬆️
src/measure.jl 49.62% <100%> (+4.16%) ⬆️
src/cairo_backends.jl 62.13% <71.42%> (+1.01%) ⬆️
src/form.jl 54.73% <80.76%> (+3.11%) ⬆️
src/container.jl 38.73% <0%> (+0.45%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 95e3458...e69a4d1. Read the comment docs.

@tlnagy
Copy link
Member

tlnagy commented Jan 4, 2020

What about using that as Compose.jl's logo? It looks really nice :)

@Mattriks
Copy link
Member Author

Now more complex shapes are possible:

spade = [[(11,20), (13,20)], [(7,20)], [(9,20), (9,15)],
    [(9,20),(0,21),(0,16)], [(0,11), (6,9), (10,0)], 
    [(14,9), (20,11), (20,16)], [(20,21), (11,20), (11,15)]
]

compose(context(units=UnitBox(0,0,20,20)), 
        (context(), bezigon((11,15), spade), fill("gray"))
)

spade

@Mattriks
Copy link
Member Author

Done. I think the Compose logo could be changed in a separate PR.

@bjarthur bjarthur merged commit 3c15da7 into GiovineItalia:master Jan 18, 2020
@Vectornaut
Copy link

@Mattriks, thank you so much for your hard work on this feature! I'm sorry I've taken so long to post feedback. The bezigon primitive works perfectly in the code I commented about in #298, which used the path primitive before. Its output is visually indistinguishable from what I had before.

I did some performance comparisons using two benchmark examples. Significant differences are in bold. Time and memory use are measured in repeated runs, ignoring the initial compilation run.

When I just replaced path with bezigon, not taking advantage of any other new features, here's what happened.

  • Run time fell by 60%.
  • Memory use fell by 40%.
  • For the first example, the PDF output file grew by 8%. For the second example, it stayed the same size.
  • For the first example, the SVG output file grew by 50%.

A big advantage of bezigon over path is that it can be vectorized! When I reorganized my code so I could use vectorized bezigon instead of ordinary bezigon, here's what happened.

  • Run time fell by 85%.
  • Memory use fell by 85%.
  • For both examples, the PDF output shrank by 1%.
  • For the first example, the SVG output stayed the same size.

The huge runtime performance gains are great for me. Now I can draw finer details and longer animations! The substantially larger SVG output file is weird, but no problem for me so far. In particular, it doesn't seem to slow down Inkscape's handling of the SVG.

Vectornaut pushed a commit to Vectornaut/whorl that referenced this pull request Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants