Hello Developers,
I’ve recently created a color picker for my 2D Perlin Noise Visualizer, and rather than letting it collect dust, I’m making it open source!
It is really simple to use there are a few examples in the video.
you can find the most recent version here.
I have since updated the color picker and added an eye dropper feature.
You can still find the old version at the bottom of the post.
Documentation
Limitation of the eye dropper feature
- Because it returns
BasePart.Color
orGuiObject.BackgroundColor3
trying to pick the color of partially transparent parts or gui elements could be inaccurate. -
UIGradient
instances are not supported and will instead return it’s parent’s BackgroundColor3.
Constructor
ColorPickerModule.new(): colorPicker
Constructor to create a new ColorPicker
object.
Events
ColorPicker.Opened
Fires when the color picker is opened.
ColorPicker.Closed
Fires when the color picker is closed.
Parameters:
-
canceled (boolean)
: Returnstrue
if the color picker was closed using the cancel button or the:Cancel()
method.
ColorPicker.Changed
Fires when the color selection changes.
Parameters:
-
updatedColor (Color3)
: The color it was changed to.
Methods
ColorPicker:Start()
Opens the color picker.
ColorPicker:Cancel()
Closes the color picker.
ColorPicker:SetColor(color: Color3)
Sets the color of the color picker.
ColorPicker:GetColor(): Color3
Returns the current color of the color picker.
ColorPicker:Destroy()
Destroys the color picker.
Feel free to use this color picker however you want. Use it into your projects, sell it, modify it, or use the code as a learning resource!
If you use it in your project, I’d love to hear about it, so feel free to message me!
That’s about everything! I would love to hear your feedback!
Old version
you can find the old version here.
(if this version still has bugs I won’t be fixing them.)
Documentation
Constructor
ColorPickerModule.new(): ColorPicker
Constructor for creating a new ColorPicker object.
Events
ColorPicker.Opened
Fires when the color picker is opened.
ColorPicker.Closed
Fires when the color picker is closed.
Parameters
-
selectedColor
(Color3): The color selected when the color picker is closed. -
confirmed
(boolean?):-
true
when closed with the ‘OK’ button. -
false
when closed with the ‘Cancel’ button. -
nil
when closed using the:Close()
method.
-
ColorPicker.Changed
Fires when the color selection changes.
Parameters
-
updatedColor
(Color3): The updated color during color selection.
Methods
ColorPicker:Start()
Opens the color picker.
ColorPicker:Cancel()
Cancels the color selection and closes the color picker.
ColorPicker:SetColor(color: Color3)
Sets the color of the color picker.
ColorPicker:GetColor(): Color3
Returns the current color of the color picker.
ColorPicker:Destroy()
Destroys the color picker.