Skip to content

Commit a5fa670

Browse files
authored
[MakieExt] allow plotting diamonds as image (#48)
* [MakieExt] allow plotting diamonds as image This is much more efficient for large diamonds * bump version * add test * fixup
1 parent d657568 commit a5fa670

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "AztecDiamonds"
22
uuid = "8762d9c5-fcab-4007-8fd1-c6de73397726"
33
authors = ["Simeon David Schaub <[email protected]> and contributors"]
4-
version = "0.2.7"
4+
version = "0.2.8"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

ext/MakieExtension.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ using GeometryBasics: Vec2f, Point2f, Rect2f
55
using Colors
66
using Adapt: adapt
77

8-
using AztecDiamonds: Tiling, faces, UP, RIGHT
8+
using AztecDiamonds: Tiling, faces, UP, RIGHT, to_img
99
import AztecDiamonds: tilingplot, tilingplot!
1010

1111
function prepare_plot(t::Tiling, pad = 0.1f0)
@@ -54,4 +54,6 @@ function Makie.plot!(x::TilingPlot{<:Tuple{Tiling}})
5454
return x
5555
end
5656

57+
Makie.convert_arguments(::Type{<:Image}, t::Tiling) = (Makie.EndPoints(-t.N, t.N), Makie.EndPoints(-t.N, t.N), parent(to_img(t)))
58+
5759
end

test/makie.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
D = diamond(100)
55

66
f = Figure()
7-
ax = Axis(f[1, 1]; aspect = 1)
7+
ax = Axis(f[1, 1]; autolimitaspect = 1)
88
plot!(ax, D; domino_padding = 0.05f0, domino_stroke = 1, show_arrows = true)
9+
image(f[1, 2], D; axis = (; autolimitaspect = 1))
910

1011
path = tempname() * ".png"
1112
save(path, f)
1213
@test isfile(path)
13-
@test filesize(path) > 1024 # 1 kiB
14+
@test filesize(path) > 100 * 1024 # 100 kiB
1415

1516
using JET
1617
@test_opt Base.get_extension(AztecDiamonds, :MakieExtension).prepare_plot(D)

0 commit comments

Comments
 (0)