JuliaGraphics / Colors.jl

Color manipulation utilities for Julia
Other
200 stars 44 forks source link

colorwheel generator #519

Closed johnnychen94 closed 2 years ago

johnnychen94 commented 2 years ago
using ImageShow

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(y, x)
            canvas[I] = RGB(HSV(h, r, v))
        end
    end
    return canvas
end

This generates the widely used color wheel

colorwheel((1024, 1024))
preview.png

I'm wondering if this should be put here or TestImages.

johnnychen94 commented 2 years ago

duplicated to #520