Currently I have a color wheel script, it returns the HSV of whatever the color picker is hovering over.
I want to move the color picker based on a predefined color, so if i wanted to position it to hover over a different color i would just type the hex or rgb.
This is the code im using to position the color picker based on mouse position:
function UpdateColor(colourWheel, darknessPicker, darknessSlider, centreOfWheel)
local colourPickerCentre = Vector2.new(
colourWheel.Picker.AbsolutePosition.X + (colourWheel.Picker.AbsoluteSize.X/2),
colourWheel.Picker.AbsolutePosition.Y + (colourWheel.Picker.AbsoluteSize.Y/2)
)
local h = (math.pi - math.atan2(colourPickerCentre.Y - centreOfWheel.Y, colourPickerCentre.X - centreOfWheel.X)) / (math.pi * 2)
local s = (centreOfWheel - colourPickerCentre).Magnitude / (colourWheel.AbsoluteSize.X/2)
local v = math.abs((darknessSlider.AbsolutePosition.Y - darknessPicker.AbsolutePosition.Y) / darknessPicker.AbsoluteSize.Y - 1)
local hsv = Color3.fromHSV(math.clamp(h, 0, 1), math.clamp(s, 0, 1), math.clamp(v, 0, 1))
darknessPicker.UIGradient.Color = ColorSequence.new{
ColorSequenceKeypoint.new(0, Color3.fromHSV(math.clamp(h, 0, 1),1,1)),
ColorSequenceKeypoint.new(1, Color3.new(0, 0, 0))
}
return hsv
end
function module.movePicker(wheelPicker, colourWheel, darknessSlider, darknessPicker, buttonDown, movingSlider)
local mousePos = uis:GetMouseLocation() - Vector2.new(0, game:GetService("GuiService"):GetGuiInset().Y)
local centreOfWheel = Vector2.new(colourWheel.AbsolutePosition.X + (colourWheel.AbsoluteSize.X/2), colourWheel.AbsolutePosition.Y + (colourWheel.AbsoluteSize.Y/2))
local distanceFromWheel = (mousePos - centreOfWheel).Magnitude
if distanceFromWheel <= colourWheel.AbsoluteSize.X/2 and buttonDown then
wheelPicker.Position = UDim2.new(0, mousePos.X - colourWheel.AbsolutePosition.X, 0, mousePos.Y - colourWheel.AbsolutePosition.Y)
elseif movingSlider then
darknessSlider.Position = UDim2.new(darknessSlider.Position.X.Scale, 0, 0,
math.clamp(
mousePos.Y - darknessPicker.AbsolutePosition.Y,
0,
darknessPicker.AbsoluteSize.Y)
)
end
local hsv = UpdateColor(colourWheel, darknessPicker, darknessSlider, centreOfWheel)
return hsv
end