From bc9ad8c4c4a531c39acd8772d7cbf2068f3479c0 Mon Sep 17 00:00:00 2001 From: Jonas Schumacher Date: Tue, 10 Sep 2024 13:37:34 +0200 Subject: [PATCH] Remove Luxor (#40) --- Project.toml | 2 -- src/MPITestImages.jl | 1 - src/OnTheFly.jl | 45 ++++++++++++++++++++++---------------------- 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/Project.toml b/Project.toml index bbddf45..4c52477 100644 --- a/Project.toml +++ b/Project.toml @@ -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" @@ -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" diff --git a/src/MPITestImages.jl b/src/MPITestImages.jl index df7fbad..f3fb899 100644 --- a/src/MPITestImages.jl +++ b/src/MPITestImages.jl @@ -3,7 +3,6 @@ module MPITestImages using DocStringExtensions using Pkg.Artifacts using FileIO -using Luxor using Images using MacroTools diff --git a/src/OnTheFly.jl b/src/OnTheFly.jl index 19494b3..b49c227 100644 --- a/src/OnTheFly.jl +++ b/src/OnTheFly.jl @@ -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 @@ -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