|
|
@ -28,7 +28,7 @@ namespace Avalonia.Controls.Primitives |
|
|
|
|
|
|
|
|
public static Hsv IncrementColorChannel( |
|
|
public static Hsv IncrementColorChannel( |
|
|
Hsv originalHsv, |
|
|
Hsv originalHsv, |
|
|
ColorPickerHsvChannel channel, |
|
|
HsvChannel channel, |
|
|
IncrementDirection direction, |
|
|
IncrementDirection direction, |
|
|
IncrementAmount amount, |
|
|
IncrementAmount amount, |
|
|
bool shouldWrap, |
|
|
bool shouldWrap, |
|
|
@ -54,23 +54,23 @@ namespace Avalonia.Controls.Primitives |
|
|
// for saturation and value, this is every increment of 10.
|
|
|
// for saturation and value, this is every increment of 10.
|
|
|
switch (channel) |
|
|
switch (channel) |
|
|
{ |
|
|
{ |
|
|
case ColorPickerHsvChannel.Hue: |
|
|
case HsvChannel.Hue: |
|
|
valueToIncrement = ref newHsv.H; |
|
|
valueToIncrement = ref newHsv.H; |
|
|
incrementAmount = amount == IncrementAmount.Small ? 1 : 30; |
|
|
incrementAmount = amount == IncrementAmount.Small ? 1 : 30; |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case ColorPickerHsvChannel.Saturation: |
|
|
case HsvChannel.Saturation: |
|
|
valueToIncrement = ref newHsv.S; |
|
|
valueToIncrement = ref newHsv.S; |
|
|
incrementAmount = amount == IncrementAmount.Small ? 1 : 10; |
|
|
incrementAmount = amount == IncrementAmount.Small ? 1 : 10; |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case ColorPickerHsvChannel.Value: |
|
|
case HsvChannel.Value: |
|
|
valueToIncrement = ref newHsv.V; |
|
|
valueToIncrement = ref newHsv.V; |
|
|
incrementAmount = amount == IncrementAmount.Small ? 1 : 10; |
|
|
incrementAmount = amount == IncrementAmount.Small ? 1 : 10; |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
default: |
|
|
default: |
|
|
throw new InvalidOperationException("Invalid ColorPickerHsvChannel."); |
|
|
throw new InvalidOperationException("Invalid HsvChannel."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
double previousValue = valueToIncrement; |
|
|
double previousValue = valueToIncrement; |
|
|
@ -99,8 +99,8 @@ namespace Avalonia.Controls.Primitives |
|
|
// While working with named colors, we're going to need to be working in actual HSV units,
|
|
|
// While working with named colors, we're going to need to be working in actual HSV units,
|
|
|
// so we'll divide the min bound and max bound by 100 in the case of saturation or value,
|
|
|
// so we'll divide the min bound and max bound by 100 in the case of saturation or value,
|
|
|
// since we'll have received units between 0-100 and we need them within 0-1.
|
|
|
// since we'll have received units between 0-100 and we need them within 0-1.
|
|
|
if (channel == ColorPickerHsvChannel.Saturation || |
|
|
if (channel == HsvChannel.Saturation || |
|
|
channel == ColorPickerHsvChannel.Value) |
|
|
channel == HsvChannel.Value) |
|
|
{ |
|
|
{ |
|
|
minBound /= 100; |
|
|
minBound /= 100; |
|
|
maxBound /= 100; |
|
|
maxBound /= 100; |
|
|
@ -114,7 +114,7 @@ namespace Avalonia.Controls.Primitives |
|
|
|
|
|
|
|
|
public static Hsv FindNextNamedColor( |
|
|
public static Hsv FindNextNamedColor( |
|
|
Hsv originalHsv, |
|
|
Hsv originalHsv, |
|
|
ColorPickerHsvChannel channel, |
|
|
HsvChannel channel, |
|
|
IncrementDirection direction, |
|
|
IncrementDirection direction, |
|
|
bool shouldWrap, |
|
|
bool shouldWrap, |
|
|
double minBound, |
|
|
double minBound, |
|
|
@ -138,26 +138,26 @@ namespace Avalonia.Controls.Primitives |
|
|
|
|
|
|
|
|
switch (channel) |
|
|
switch (channel) |
|
|
{ |
|
|
{ |
|
|
case ColorPickerHsvChannel.Hue: |
|
|
case HsvChannel.Hue: |
|
|
originalValue = originalHsv.H; |
|
|
originalValue = originalHsv.H; |
|
|
newValue = ref newHsv.H; |
|
|
newValue = ref newHsv.H; |
|
|
incrementAmount = 1; |
|
|
incrementAmount = 1; |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case ColorPickerHsvChannel.Saturation: |
|
|
case HsvChannel.Saturation: |
|
|
originalValue = originalHsv.S; |
|
|
originalValue = originalHsv.S; |
|
|
newValue = ref newHsv.S; |
|
|
newValue = ref newHsv.S; |
|
|
incrementAmount = 0.01; |
|
|
incrementAmount = 0.01; |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case ColorPickerHsvChannel.Value: |
|
|
case HsvChannel.Value: |
|
|
originalValue = originalHsv.V; |
|
|
originalValue = originalHsv.V; |
|
|
newValue = ref newHsv.V; |
|
|
newValue = ref newHsv.V; |
|
|
incrementAmount = 0.01; |
|
|
incrementAmount = 0.01; |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
default: |
|
|
default: |
|
|
throw new InvalidOperationException("Invalid ColorPickerHsvChannel."); |
|
|
throw new InvalidOperationException("Invalid HsvChannel."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool shouldFindMidPoint = true; |
|
|
bool shouldFindMidPoint = true; |
|
|
@ -230,26 +230,26 @@ namespace Avalonia.Controls.Primitives |
|
|
|
|
|
|
|
|
switch (channel) |
|
|
switch (channel) |
|
|
{ |
|
|
{ |
|
|
case ColorPickerHsvChannel.Hue: |
|
|
case HsvChannel.Hue: |
|
|
startValue = ref startHsv.H; |
|
|
startValue = ref startHsv.H; |
|
|
currentValue = ref currentHsv.H; |
|
|
currentValue = ref currentHsv.H; |
|
|
wrapIncrement = 360.0; |
|
|
wrapIncrement = 360.0; |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case ColorPickerHsvChannel.Saturation: |
|
|
case HsvChannel.Saturation: |
|
|
startValue = ref startHsv.S; |
|
|
startValue = ref startHsv.S; |
|
|
currentValue = ref currentHsv.S; |
|
|
currentValue = ref currentHsv.S; |
|
|
wrapIncrement = 1.0; |
|
|
wrapIncrement = 1.0; |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case ColorPickerHsvChannel.Value: |
|
|
case HsvChannel.Value: |
|
|
startValue = ref startHsv.V; |
|
|
startValue = ref startHsv.V; |
|
|
currentValue = ref currentHsv.V; |
|
|
currentValue = ref currentHsv.V; |
|
|
wrapIncrement = 1.0; |
|
|
wrapIncrement = 1.0; |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
default: |
|
|
default: |
|
|
throw new InvalidOperationException("Invalid ColorPickerHsvChannel."); |
|
|
throw new InvalidOperationException("Invalid HsvChannel."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
while (newColorName == currentColorName) |
|
|
while (newColorName == currentColorName) |
|
|
|