I have a color wheel, that gives me an hsv color value. I then use this to get a Color3 object.
However, when I start with a color3, I am lost as to how to convert it to hsv.
And even if I did find how to convert color3 to hsv, how would I map the h, s, onto a color wheel, as the v is just the darkness slider?
Any help is appreciated, thanks
function WheelMath(input)
local r = Wheel.AbsoluteSize.x/2
local d = Vector2.new(input.Position.x, input.Position.y) - Wheel.AbsolutePosition - Wheel.AbsoluteSize/2
if (d:Dot(d) > r*r) then
d = d.unit * r
end
WheelMarker.Position = UDim2.new(.5, d.x, .5, d.y)
GetColor()
end
local function GetColor()
local wheelCenter = Vector2.new(
Wheel.AbsolutePosition.X + (Wheel.AbsoluteSize.X/2),
Wheel.AbsolutePosition.Y + (Wheel.AbsoluteSize.Y/2))
local markerCentre = Vector2.new(
WheelMarker.AbsolutePosition.X + (WheelMarker.AbsoluteSize.X/2),
WheelMarker.AbsolutePosition.Y + (WheelMarker.AbsoluteSize.Y/2))
local h = (math.pi - math.atan2(markerCentre.Y - wheelCenter.Y, markerCentre.X - wheelCenter.X)) / (math.pi * 2)
local s = (wheelCenter - markerCentre).Magnitude / (Wheel.AbsoluteSize.X/2)
Slider.UIGradient.Color = ColorSequence.new{
ColorSequenceKeypoint.new(0, Color3.fromHSV(math.clamp(h, 0, 1), math.clamp(s, 0, 1), 1)),
ColorSequenceKeypoint.new(1, Color3.new(0, 0, 0))
}
local color = Color3.fromHSV(math.clamp(h, 0, 1), math.clamp(s, 0, 1), math.clamp(Value, 0, 1))
Swatch.BackgroundColor3 = color
Result.Value = color
end