Hi there. I’m currently trying to render a colour wheel in roblox (draw it from scratch). Currently, it’s going not terrible BUT not how I wanted it to go.
local rs = game:GetService("RunService")
local h, s, v = 0, 0, 1
function polar(v)
return math.atan2(v.y, v.x), v.magnitude
end
function toDeg(x)
return (x * (180 / math.pi))
end
local pixels = 1
local rows = wheel.Size.Y.Offset
for i = 0, rows, pixels do
for j = 0, wheel.Size.X.Offset, pixels do
local new_colour = Instance.new("Frame", wheel)
new_colour.BorderSizePixel = 0
new_colour.Size = UDim2.new(0, pixels, 0, pixels)
new_colour.Position = UDim2.new(0, j, 0, i)
local r = wheel.AbsoluteSize.X / 2
local d = Vector2.new(new_colour.AbsolutePosition.X, new_colour.AbsolutePosition.Y) - wheel.AbsolutePosition - wheel.AbsoluteSize/2
if (d:Dot(d) > r * r) then
d = d.unit * r
end
print(r, d)
local phi, len = polar(d * Vector2.new(1, -1))
h, s = toDeg(phi)/360, len / r
new_colour.BackgroundColor3 = Color3.fromHSV(h, s, v)
rs.Heartbeat:Wait()
end
end
I am not sure why but the wheel looks a bit like a block rather than a thin cylinder tipped on its side as in wheel shaped. Wont fix your script but will make the view appear to be in line with it.