Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add colorwheel generator #520

Open
johnnychen94 opened this issue Jan 2, 2022 · 1 comment
Open

add colorwheel generator #520

johnnychen94 opened this issue Jan 2, 2022 · 1 comment

Comments

@johnnychen94
Copy link
Member

johnnychen94 commented Jan 2, 2022

using ImageCore
using OffsetArrays

function colorwheel(sz::Dims{2}, v=1)
    # H, S
    canvas = OffsetArrays.centered(fill(ARGB(0, 0, 0, 0), sz))

    for I in CartesianIndices(canvas)
        x, y = I.I ./ (size(canvas)  2)
        r = sqrt(x*x+y*y)
        if r < 1
            h = atand(x, y) + 90
            canvas[I] = RGB(HSV(h, r, v))
        end
    end
    return canvas
end
colorwheel((1024, 1024))

This generates the widely used color wheel https://commons.wikimedia.org/wiki/File:Color_circle_(RGB).svg

preview.png

I use this for visualization test purposes. I'm wondering if this should be put here or TestImages.

@kimikage
Copy link
Collaborator

kimikage commented Apr 13, 2024

One main concern is that Colors.jl does not have the ability to display images. We need ImageShow.jl etc.

Another concern is that user preferences may be diverse.
For example, whether to set 0° to the right or top, clockwise or counterclockwise, what background color, how many margins, etc.
I don't think it is necessary to address all of them, but it is better to be able to extend the wheel with kwargs.

So, how about adding a ColorWheel type that only holds settings, and rendering the instance when display-ed or show-ed, as we do in the Colors.jl documentation?

https://github.com/JuliaGraphics/Colors.jl/blob/f0a508bce74a3c6a15bb01a5ab52bc9b9ba81f73/docs/crosssectionalcharts.jl

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

No branches or pull requests

2 participants