I'm have try drawing color picker by Ellipse LinearGradientBrush.
<Ellipse Width="200" Height="200">
<Ellipse.Fill>
<VisualBrush TileMode="None">
<VisualBrush.Visual>
<Canvas Width="1" Height="1" SnapsToDevicePixels="True">
<Rectangle Width="1" Height="1" SnapsToDevicePixels="True">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<LinearGradientBrush.GradientStops>
<GradientStop Color="#FF0000" Offset="0" />
<GradientStop Color="#FFFF00" Offset="0.167" />
<GradientStop Color="#00FF00" Offset="0.333" />
<GradientStop Color="#00FFFF" Offset="0.5" />
<GradientStop Color="#0000FF" Offset="0.667" />
<GradientStop Color="#FF00FF" Offset="0.833" />
<GradientStop Color="#FF0000" Offset="1" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Fill>
<Rectangle.OpacityMask>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="#FFFFFFFF" Offset="0"/>
<GradientStop Color="#00FFFFFF" Offset="1"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.OpacityMask>
</Rectangle>
</Canvas>
</VisualBrush.Visual>
</VisualBrush>
</Ellipse.Fill>
</Ellipse>
It's just like this:
But How can drawing a colorpicker have multiple color and like the scattered out color like a this.
I have not idea. please any one help.
CodePudding user response:
Personally, I'd just use a background texture. @Jim Foye is right though, it's very easy to do with a pixel shader: