Skip to content

Instantly share code, notes, and snippets.

@cormullion
Last active June 14, 2023 11:09
Show Gist options
  • Save cormullion/dd500d4aed96758dd12aab2b649840d4 to your computer and use it in GitHub Desktop.
Save cormullion/dd500d4aed96758dd12aab2b649840d4 to your computer and use it in GitHub Desktop.
julia performance
using Luxor
function main()
Drawing(500, 500, "/tmp/juliaperformance.svg")
origin()
squircle(O, 245, 245, :clip, rt=0.3)
sethue("ivory")
paint()
@layer begin
translate(0, 200)
rmin = 150
rmax = 260
band = 45
setblend(blend(O - (240, 0), O + (240, 0), "white", "red"))
sector(O, rescale(4, 1, 3, rmin, rmax),
rescale(4, 1, 3, rmin, rmax) + band/2,
3π/2 - deg2rad(45), 3π/2 + deg2rad(45), :fill)
for n in 1:3
sethue([Luxor.julia_green, Luxor.julia_red,Luxor.julia_purple, Luxor.julia_blue][n])
sector(O,
rescale(n, 1, 3, rmin, rmax),
rescale(n, 1, 3, rmin, rmax) + band,
3π/2 - deg2rad(45), 3π/2 + deg2rad(45),
:fill)
end
sethue("white")
setline(25)
line(O, polar(400, deg2rad(290)), :strokepreserve)
setline(14)
sethue("black")
strokepath()
circle(O, 30, :fill)
end
squircle(O, 245, 245, :stroke, rt=0.3)
finish()
preview()
end
main()
@cormullion
Copy link
Author

juliaperformance

@gdalle
Copy link

gdalle commented Jun 13, 2023

This is awesome! As a new maintainer of BenchmarkTools I'm enthusiastic about this
Would it perhaps look better with arcs of the same width, ordered blue < green < red < violet? I'm colorblind so don't take my word for it

@cormullion
Copy link
Author

Hi @gdalle ! A necrocomment for sure... :) The code should work fine on today's Julia. The color sequence for the lower three bands is set in line 22, and it may or may not look better in a different order - who knows? :) The colour gradient of the top band is set in line 15... The thickness of top band is set in line 18 (band/2), and I made it different width because it clashed with the red a bit otherwise. Feel free to adjust it to your heart's content - have fun!

If you want alternatives or further changes, just let me know...

@gdalle
Copy link

gdalle commented Jun 14, 2023

I love a good necrocomment :) sorry for the ping, I'll experiment a bit on my side

@cormullion
Copy link
Author

No, I love a good ping. Shout if you want anything - I'll get to a real computer later ... !

@cormullion
Copy link
Author

Yes, the gradients are linear or radial, so a curved one might be tricker. Obviously you could do it by drawing small sections:

using Luxor, Colors
@draw begin
    δ = π/220
    starthue = 30
    for (n, θ) in enumerate(deg2rad(220): δ : deg2rad(320))
        sethue(HSB(starthue + n, 0.9, 0.8))
        sector(O, 150, 200, θ, θ + δ, :fillstroke)
    end 
end

or you'd have to use meshes ...

@gdalle
Copy link

gdalle commented Jun 14, 2023

Thanks, on second thought I think it's a bit overkill for our use case. I already like the way this looks: JuliaCI/BenchmarkTools.jl#316

@cormullion
Copy link
Author

Cool stuff!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment