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

New hcat and vcat for drawings #210

Merged
merged 3 commits into from
Mar 18, 2022
Merged

New hcat and vcat for drawings #210

merged 3 commits into from
Mar 18, 2022

Conversation

davibarreira
Copy link
Contributor

This is a small contribution, but I think it might be quite useful. It overloads the Base.hcat and Base.vcat to work with figures. So one can easily concatenate figures in Luxor.

I've implemented the two functions and a set of tests.

Here is an example.

    d1 = Drawing(200,100,:svg)
    origin()
    circle(O,60,:fill)
    finish()

    d2 = Drawing(200,200,:svg)
    rect(O,200,200,:fill)
    finish()
    hcat(d1,d2; hpad=10, valign=:top, clip = true)

@cormullion
Copy link
Member

Cool! Just SVG or any format?

@codecov
Copy link

codecov bot commented Mar 17, 2022

Codecov Report

Merging #210 (f2426d1) into master (1473624) will increase coverage by 0.19%.
The diff coverage is 92.59%.

❗ Current head f2426d1 differs from pull request most recent head e73caff. Consider uploading reports for the commit e73caff to get more accurate results

@@            Coverage Diff             @@
##           master     #210      +/-   ##
==========================================
+ Coverage   70.85%   71.05%   +0.19%     
==========================================
  Files          33       33              
  Lines        5919     5973      +54     
==========================================
+ Hits         4194     4244      +50     
- Misses       1725     1729       +4     
Impacted Files Coverage Δ
src/basics.jl 92.17% <92.59%> (+0.12%) ⬆️

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 1473624...e73caff. Read the comment docs.

@davibarreira
Copy link
Contributor Author

I've tried with d1 = Drawing(200,100,:png) and got an error saying surfacetype pngis not supported. Useimage instead.. Don't know exactly why. The function I've implemented is quite simple, and I thought it would work with png. But I guess not.

@davibarreira
Copy link
Contributor Author

@cormullion, is it possible to do a placeimage with d as png? This is what is causing the error. I don't know how to solve it, unless by saving the png as a file and using readpng as in the docs.

@cormullion
Copy link
Member

You can do that kind of thing if you have extracted the image_as_matrix before you finish().

Perhaps this PR should somehow be restricted to SVG+SVG only; otherwise it will be difficult to hcat, say, a PNG and an SVG, or a PNG and a EPS.

@davibarreira
Copy link
Contributor Author

Done! Added a new line in the code to check that the surfacetype is svg, and also specified in the docstring :)

@cormullion cormullion merged commit 27d7ac1 into JuliaGraphics:master Mar 18, 2022
@cormullion
Copy link
Member

Awesome! Thanks!

@cormullion
Copy link
Member

@davibarreira
Copy link
Contributor Author

Has this been released?

@cormullion
Copy link
Member

Not yet. Luxor's release schedule is vaguely monthly, so perhaps I should do one soon...

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

2 participants