Skip to content

add colorwheel generator #520

@johnnychen94

Description

@johnnychen94
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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions