aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects/SaturationValueSelector.cs
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-03-31 12:25:56 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-03-31 12:25:56 +0200
commit135ced0e0a94ae759fba5fec7c0f35ec9be28231 (patch)
treebf7704783131ed55d89ab1dd8183458584c10f03 /src/GraphicObjects/SaturationValueSelector.cs
parentd7457dc87ec4a282ac58a5617f149164a1421a64 (diff)
convert hsv to integer in color pickerIFaceByParenting
Diffstat (limited to 'src/GraphicObjects/SaturationValueSelector.cs')
-rw-r--r--src/GraphicObjects/SaturationValueSelector.cs22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/GraphicObjects/SaturationValueSelector.cs b/src/GraphicObjects/SaturationValueSelector.cs
index 485a33d2..42958b42 100644
--- a/src/GraphicObjects/SaturationValueSelector.cs
+++ b/src/GraphicObjects/SaturationValueSelector.cs
@@ -38,16 +38,18 @@ namespace Crow
{
}
+ const double div = 255.0;
+ const double colDiv = 1.0 / div;
double v, s;
[XmlAttributeAttribute()]
public virtual double V {
- get { return v; }
+ get { return Math.Round(v * div); }
set {
- if (v == value)
+ if (S == value)
return;
- v = value;
- NotifyValueChanged ("V", v);
+ v = value * colDiv;
+ NotifyValueChanged ("V", V);
mousePos.Y = (int)Math.Floor((1.0-v) * (double)ClientRectangle.Height);
RegisterForRedraw ();
@@ -55,12 +57,12 @@ namespace Crow
}
[XmlAttributeAttribute()]
public virtual double S {
- get { return s; }
+ get { return Math.Round(s * div); }
set {
- if (s == value)
+ if (S == value)
return;
- s = value;
- NotifyValueChanged ("S", s);
+ s = value * colDiv;
+ NotifyValueChanged ("S", S);
mousePos.X = (int)Math.Floor(s * (double)ClientRectangle.Width);
RegisterForRedraw ();
@@ -121,8 +123,8 @@ namespace Crow
Rectangle cb = ClientRectangle;
s = (double)mousePos.X / (double)cb.Width;
v = 1.0 - (double)mousePos.Y / (double)cb.Height;
- NotifyValueChanged ("S", s);
- NotifyValueChanged ("V", v);
+ NotifyValueChanged ("S", S);
+ NotifyValueChanged ("V", V);
RegisterForRedraw ();
}