Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Base64: Base64EncodePipe

Base.summary(io::IO, t::Tiling) = print(io, "Order-", t.N, " ", typeof(t))

function to_img(t::Tiling)
function to_img(t::Tiling{Matrix{Edge}})
img = fill(colorant"transparent", inds(t.N))
foreach(faces(t)) do (i, j, isdotted)
if t[i, j] == UP
Expand All @@ -17,6 +17,7 @@ function to_img(t::Tiling)
end
return img
end
to_img(t::Tiling) = to_img(adapt(Array, t))

function Base.show(io::IO, (; N, x)::Tiling)
print(io, "Tiling(", N)
Expand Down Expand Up @@ -82,19 +83,19 @@ Base.showable(::MIME"image/png", (; N)::Tiling) = N > 0

function Base.show(io::IO, ::MIME"image/png", t::Tiling; kw...)
io = IOContext(io, :full_fidelity => true)
img = to_img(adapt(Array, t))
img = to_img(t)
show(io, MIME("image/png"), img; kw...)
return nothing
end

Base.showable(::MIME"juliavscode/html", (; N)::Tiling) = N > 0

function Base.show(io::IO, ::MIME"juliavscode/html", t::Tiling; kw...)
img = to_img(adapt(Array, t))
img = to_img(t)
print(io, "<img src='data:image/gif;base64,")
b64_io = IOContext(Base64EncodePipe(io), :full_fidelity => true)
show(b64_io, MIME("image/png"), img; kw...)
close(b64_io)
print(io, "' style='width: 100%; max-height: 500px; object-fit: contain; image-rendering: pixelated' />")
print(io, "' style='width: 500px; max-height: 500px; object-fit: contain; image-rendering: pixelated' />")
return nothing
end
1 change: 1 addition & 0 deletions test/cuda.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
D = ka_diamond(200, CuArray)
D_cpu = adapt(Array, D)
@test verify_tiling(D_cpu)
@test AztecDiamonds.to_img(D) == AztecDiamonds.to_img(D_cpu)

@testset "$rot" for rot in (rotr90, rotl90, rot180)
D′ = rot(D)
Expand Down
Loading