Making a ColorPicker.
So, just out of curiosity, how would you guys go about creating a ColorPicker with noesis? Since afaik there isn't any control supported to make a ColorPicker?
Thanks.
Thanks.
Re: Making a ColorPicker.
Hi,
I'm still a noob in WPF but here is what i would do.
Firstly i would create a panel with the following code:
In procedural code i would detected the clicks on the left to select the brightness and saturation.
On the right i would detect the clicks to select the hue and change the brush of the left panel to reflect it.
(In my sample code the hue is red, obviously) I think you could go even further by customizing a slider to select the hue but i don't know how to do it.
I'm still a noob in WPF but here is what i would do.
Firstly i would create a panel with the following code:
Code: Select all
<DockPanel>
<Grid x:Name="huePanel" DockPanel.Dock="Right" MinWidth="20">
<Border>
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Red" Offset="0"/>
<GradientStop Color="Blue" Offset="0.333"/>
<GradientStop Color="Lime" Offset="0.666"/>
<GradientStop Color="Red" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
</Border>
</Grid>
<Grid x:Name="saturationBrightnessPanel">
<Border>
<Border.Background>
<LinearGradientBrush EndPoint="0,0" StartPoint="1,0">
<GradientStop Color="#FFFF0000" Offset="0"/>
<GradientStop Color="#FFFFFFFF" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
</Border>
<Border>
<Border.Background>
<LinearGradientBrush EndPoint="0,0" StartPoint="0,1">
<GradientStop Color="#FF000000" Offset="0"/>
<GradientStop Color="#00000000" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
</Border>
</Grid>
</DockPanel>
On the right i would detect the clicks to select the hue and change the brush of the left panel to reflect it.
(In my sample code the hue is red, obviously) I think you could go even further by customizing a slider to select the hue but i don't know how to do it.
-
-
sfernandez
Site Admin
- Posts: 3222
- Joined:
Re: Making a ColorPicker.
Hi Justei,
You already have a ColorPicker example within the Primitives sample that comes with NoesisGUI Unity package. There you can find the xaml and associated script:
Assets/NoesisGUI/Samples/Primitives/ColorPicker.xaml
Assets/NoesisGUI/Samples/Primitives/ColorPicker.cs
Assets/NoesisGUI/Samples/Primitives/HSVControl.xaml
Assets/NoesisGUI/Samples/Primitives/HSVControl.cs
You can directly use it, or take it as base for creating your own control
You already have a ColorPicker example within the Primitives sample that comes with NoesisGUI Unity package. There you can find the xaml and associated script:
Assets/NoesisGUI/Samples/Primitives/ColorPicker.xaml
Assets/NoesisGUI/Samples/Primitives/ColorPicker.cs
Assets/NoesisGUI/Samples/Primitives/HSVControl.xaml
Assets/NoesisGUI/Samples/Primitives/HSVControl.cs
You can directly use it, or take it as base for creating your own control

Re: Making a ColorPicker.
oh lol i had not seen that, gonna check it too to see if it's like what i would have done
-
-
sfernandez
Site Admin
- Posts: 3222
- Joined:
Re: Making a ColorPicker.
The HSV control is very similar to the one you postedoh lol i had not seen that, gonna check it too to see if it's like what i would have done

Re: Making a ColorPicker.
A new color picker we have just added in one of the tutorials of NoesisGUI v1.1 can be found here:
http://forum.unity3d.com/threads/192064 ... ost1382484
We are preparing a gallery subsection to share xaml spinets and user control developed by the community.
http://forum.unity3d.com/threads/192064 ... ost1382484
We are preparing a gallery subsection to share xaml spinets and user control developed by the community.
Who is online
Users browsing this forum: Ahrefs [Bot] and 3 guests