コード例 #1
0
 public Color GetUniqueColor()
 {
     Color result = Color.Empty;
     List<double> hues = new List<double>();
     foreach(HslColor col in this.assigned)
         hues.Add(col.H);
     int count = hues.Count;
     if(count == 0) {
         result = new HslColor(0, 1.0, .5);
     } else {
         double prev = hues[0];
         double gapStart = prev;
         double largestGap = 0.0;
         double current = 0, gap = 0;
         for(int i = 1; i < count; i += 1) {
             current = hues[i];
             gap = Math.Abs(prev - current);
             if(gap > largestGap) {
                 largestGap = gap;
                 gapStart = prev;
             }
             prev = current;
         }
         current = 360.0;
         gap = Math.Abs(prev - current);
         if(gap > largestGap) {
             largestGap = gap;
             gapStart = prev;
         }
         result = new HslColor(gapStart + (largestGap / 2.0), 1.0, .5);
     }
     this.assigned.Add(result);
     this.assigned.Sort((x, y) => x.H.CompareTo(y.H));
     return result;
 }
コード例 #2
0
ファイル: Saturator.cs プロジェクト: abigail3306/wintumbra
 public override Color16Bit Filter(Color16Bit origColor)
 {
     // Too dark to saturate with good results
     if (origColor.red < 5000 && origColor.green < 5000 && origColor.blue < 5000)
         return origColor;
     HslColor boringHSL = new HslColor(origColor.ToRGBColor());
     double satAmnt = (double)Properties.Settings.Default.saturationAmount;
     double diff = Math.Abs(.5 - boringHSL.L);
     int dir = boringHSL.L > .5 ? -1 : 1;
     if (diff < satAmnt)
         boringHSL.L = .5;
     else
         boringHSL.L += dir * satAmnt;
     return new Color16Bit(boringHSL.ToRgbColor());
 }
コード例 #3
0
ファイル: Brightener.cs プロジェクト: abigail3306/wintumbra
 public override Color16Bit Filter(Color16Bit origColor)
 {
     HslColor hsl = new HslColor(origColor.ToRGBColor());
     if (hsl.L > (1.0 - (double)Properties.Settings.Default.amountToLighten))
         hsl.L = 1.0;
     else
         hsl.L += (double)Properties.Settings.Default.amountToLighten;
     return new Color16Bit(hsl.ToRgbColor());
 }
コード例 #4
0
ファイル: ColorWheel.cs プロジェクト: abigail3306/wintumbra
    protected virtual void PaintColor(PaintEventArgs e, HslColor color, bool includeFocus)
    {
      PointF location;

      location = this.GetColorLocation(color);

      if (!float.IsNaN(location.X) && !float.IsNaN(location.Y))
      {
        int x;
        int y;

        x = (int)location.X - (this.SelectionSize / 2);
        y = (int)location.Y - (this.SelectionSize / 2);

        if (this.SelectionGlyph == null)
        {
          e.Graphics.DrawRectangle(Pens.Black, x, y, this.SelectionSize, this.SelectionSize);
        }
        else
        {
          e.Graphics.DrawImage(this.SelectionGlyph, x, y);
        }

        if (this.Focused && includeFocus)
        {
          ControlPaint.DrawFocusRectangle(e.Graphics, new Rectangle(x - 1, y - 1, this.SelectionSize + 2, this.SelectionSize + 2));
        }
      }
    }
コード例 #5
0
ファイル: ColorWheel.cs プロジェクト: abigail3306/wintumbra
 protected void PaintColor(PaintEventArgs e, HslColor color)
 {
   this.PaintColor(e, color, false);
 }
コード例 #6
0
ファイル: ColorWheel.cs プロジェクト: abigail3306/wintumbra
    /// <summary>
    /// Gets the point within the wheel representing the source color.
    /// </summary>
    /// <param name="color">The color.</param>
    protected virtual PointF GetColorLocation(HslColor color)
    {
      double angle;
      double radius;

      angle = color.H * Math.PI / 180;
      radius = _radius * color.S;

      return this.GetColorLocation(angle, radius);
    }
コード例 #7
0
ファイル: HslColor.cs プロジェクト: abigail3306/wintumbra
 static HslColor()
 {
     Empty = new HslColor {
         IsEmpty = true
     };
 }
コード例 #8
0
ファイル: HSVFade.cs プロジェクト: abigail3306/wintumbra
 private void target()
 {
     int h = 0;
     while (this.IsRunning) {
         h += 1;
         h %= 360;
         HslColor col = new HslColor(h, 1, .5);
         if (NewColorAvailEvent != null) {
             NewColorAvailEvent(new Color16Bit(col.ToRgbColor()), deviceId, index++);
         }
         if (stepSleep != 0)
             Thread.Sleep(stepSleep);
     }
 }