Skip to content

Commit

Permalink
Remove Luxor (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschumacher authored Sep 10, 2024
1 parent 2f99312 commit bc9ad8c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ version = "0.1.7"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
Luxor = "ae8d54c2-7ccd-5906-9d76-62fc9837b5bc"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

Expand All @@ -17,7 +16,6 @@ DocStringExtensions = "0.8, 0.9"
Documenter = "0.27"
FileIO = "1"
Images = "0.23, 0.24, 0.25, 0.26"
Luxor = "3"
MacroTools = "0.5"
Pkg = "1"
Test = "1"
Expand Down
1 change: 0 additions & 1 deletion src/MPITestImages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module MPITestImages
using DocStringExtensions
using Pkg.Artifacts
using FileIO
using Luxor
using Images
using MacroTools

Expand Down
45 changes: 23 additions & 22 deletions src/OnTheFly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -500,20 +500,18 @@ end
https://en.wikipedia.org/wiki/Siemens_star
"""
@testimage_gen function siemens_star(size::Tuple{Integer, Integer} = (81, 81); numSpokes::Integer = 8)
radius = minimum(size) / 2
Drawing(size..., :image)
origin()
background("black")
sethue("white")

spokeAngle = π / numSpokes
for spokeIdx 1:numSpokes
Luxor.pie(radius, (2 * spokeIdx - 1) * spokeAngle, (2 * spokeIdx) * spokeAngle, action = :fill)
image = zeros(size)

anglecheck = ϕ -> iseven(div(round(Int64, ϕ*100000), round(Int64, 2π/numSpokes/2*100000)))
for (i, j) Tuple.(CartesianIndices(image))
i_rel, j_rel = (i, j) .- ceil.(size ./ 2)
length_ = (i_rel^2 + j_rel^2)
angle_ = angle(i_rel - im*j_rel) + π
if length_ <= minimum(size)/2 && (anglecheck(angle_) || length_ < 2) # Fixes the missing pixels in the center
image[i, j] = 1
end
end

image = Float32.(Gray.(image_as_matrix()))
finish()

return image
end

Expand All @@ -522,16 +520,19 @@ end
numTurns::Real = 4,
thickness::Real = 2,
)
radius = minimum(size) / 2
Drawing(size..., :image)
origin()
background("black")
sethue("white")
setline(thickness)
Luxor.spiral(radius / numTurns / (2π) * 0.95, 1; log = false, period = numTurns * 2π, action = :stroke)

image = Float32.(Gray.(image_as_matrix()))
finish()
image = zeros(size)

numSteps = round(Int64, maximum(size)*numTurns)
angles = range(0, stop=2π*numTurns, length=numSteps)
distances = range(0, stop=minimum(size)/2, length=numSteps)

for (i, ϕ) enumerate(angles)
x = size[1]/2 + cos(ϕ)*distances[i]
y = size[2]/2 + sin(ϕ)*distances[i]

pixels = [pos for pos CartesianIndices(image) if sqrt(sum((Tuple(pos) .- [x, y]).^2)) <= thickness/2]
image[pixels] .= 1
end

return image
end
Expand Down

0 comments on commit bc9ad8c

Please sign in to comment.