コード例 #1
0
        private void MakeGradient(PatternPoint from, PatternPoint to)
        {
            HSBcolor hsb;
            //Color from = fromPoint.PointColor;
            //Color to = toPoint.PointColor;
            int stepCount = to.LedPos - from.LedPos; 
            //Console.WriteLine("From: {0}     To: {1}", from.LedPos, to.LedPos);
            double deltaHue = (to.Hue - from.Hue) / stepCount; 
            double deltaSat = (to.Saturation - from.Saturation) / stepCount; 
            double deltaBri = (to.Brightness - from.Brightness) / stepCount; 
            StripModel[from.LedPos - 1].PointColor = from.PointColor;
            StripModel[to.LedPos - 1].PointColor = to.PointColor;

            for (int i = 1; i < stepCount; i++)
            {
                hsb = new HSBcolor(from.Hue + i * deltaHue,
                                   from.Saturation + i * deltaSat,
                                   from.Brightness + i * deltaBri);
                StripModel[from.LedPos + i - 1].PointColor = hsb.RgbColor;
            }
        }
コード例 #2
0
        /************************************************************************/

        #region Input Handlers

        protected override void OnMouseWheel(MouseWheelEventArgs e)
        {
            HSBcolor hsb = null;
            base.OnMouseWheel(e);
            //Color color;
            if (SelectedPoint != null)
            {
                //color = SelectedPoint.PointColor;
                //PatternPoint pp = StripModel[SelectedPoint.LedPos - 1];
                hsb = new HSBcolor(SelectedPoint.Hue, SelectedPoint.Saturation, SelectedPoint.Brightness);
                int bri = (int)(hsb.Brightness * 100.0);
                if (e.Delta > 0)
                {
                    if (bri + 5 > 100)
                    {
                        //hsb = color.HsbColor();

                        hsb.Brightness = 1.0;
                        //pp.PointBrightness = 1.0;
                        //SelectedPoint.PointBrightness = 1.0;
                        //SelectedPoint.HSB.Brightness = 1;
                        //hsb = new HSBcolor(SelectedPoint.HSB.Hue, SelectedPoint.HSB.Saturation, 1);
                        //pp.PointColor = hsb.RgbColor;
                        SelectedPoint.PointColor = hsb.RgbColor;
                    }
                    else
                    {
                        hsb.Brightness = (bri + 5.0) / 100.0;
                        //pp.PointBrightness = hsb.Brightness;
                        //SelectedPoint.PointBrightness = hsb.Brightness;
                        //hsb = new HSBcolor(SelectedPoint.HSB.Hue, SelectedPoint.HSB.Saturation, (bri + 5.0) / 100.0);
                        //pp.PointColor = hsb.RgbColor;
                        SelectedPoint.PointColor = hsb.RgbColor;
                    }
                }
                else
                {
                    if (bri - 5 < 1)
                    {
                        hsb.Brightness = 0.01;
                        //pp.PointColor = hsb.RgbColor;
                        SelectedPoint.PointColor = hsb.RgbColor;
                    }
                    else
                    {
                        hsb.Brightness = (bri - 5.0) / 100.0;
                        //pp.PointColor = hsb.RgbColor;
                        SelectedPoint.PointColor = hsb.RgbColor;
                    }
                }
                UpdateModel();
            }
        }