Esempio n. 1
0
 public int Color(LEDDomeOutput dome, Configuration config, double loc_y, double loc_ang)
 {
     if (conf.coloring == Coloring.Fade)
     {
         return(LEDColor.ScaleColor(dome.GetSingleColor(this.idx), loc_ang));
     }
     else if (conf.coloring == Coloring.FadeExp)
     {
         var s = 4 * loc_ang - 4;
         return(LEDColor.ScaleColor(
                    dome.GetSingleColor(this.idx),
                    1.0 / (1 + Math.Pow(Math.E, -s))
                    ));
     }
     else if (conf.coloring == Coloring.Multi)
     {
         var end_index = config.colorPalette.colors.Length - 1;
         return(dome.GetGradientBetweenColors(end_index - 4, end_index, loc_ang, 0.0, false));
     }
     return(dome.GetSingleColor(this.idx));
 }
        public override void Animate(LEDDomeOutput dome)
        {
            double intensity          = this.AnimationIntensity;
            double scaleColor         = Math.Min(intensity * 2 * this.velocity, 1.0);
            int    totalParts         = this.shape.layout.NumSegments;
            int    animationSplitInto = 2 * ((totalParts - 1) / 2 + 1);

            for (int part = 0; part < totalParts; part += 2)
            {
                double startRange = (double)part / animationSplitInto;
                double endRange   = (double)(part + 2) / animationSplitInto;
                double scaled     = (intensity - startRange) /
                                    (endRange - startRange);
                scaled     = Math.Max(Math.Min(scaled, 1.0), 0.0);
                startRange = Math.Min(startRange / intensity, 1.0);
                endRange   = Math.Min(endRange / intensity, 1.0);

                var spokeSegment = this.shape.layout.GetSegment(part);
                foreach (var strut in spokeSegment.GetStruts())
                {
                    for (int i = 0; i < strut.Length; i++)
                    {
                        double gradientPos =
                            strut.GetGradientPos(scaled, startRange, endRange, i);
                        int color1 = gradientPos != -1.0
              ? LEDColor.ScaleColor(
                            dome.GetGradientColor(this.pad, gradientPos, 0.0, false),
                            scaleColor
                            )
              : 0x000000;
                        dome.SetPixel(strut.Index, i, color1);
                    }
                }

                if (part + 1 == totalParts)
                {
                    break;
                }

                var circleSegment = this.shape.layout.GetSegment(part + 1);
                var color2        = scaled == 1.0
          ? LEDColor.ScaleColor(dome.GetSingleColor(this.pad), scaleColor)
          : 0x000000;
                foreach (var strut in circleSegment.GetStruts())
                {
                    for (int i = 0; i < strut.Length; i++)
                    {
                        dome.SetPixel(strut.Index, i, color2);
                    }
                }
            }
        }
        public override void Animate(LEDDomeOutput dome)
        {
            double intensity = this.AnimationIntensity;
              double scaleColor = Math.Min(intensity * 2 * this.velocity, 1.0);
              int totalParts = this.shape.layout.NumSegments;
              int animationSplitInto = 2 * ((totalParts - 1) / 2 + 1);
              for (int part = 0; part < totalParts; part += 2) {
            double startRange = (double)part / animationSplitInto;
            double endRange = (double)(part + 2) / animationSplitInto;
            double scaled = (intensity - startRange) /
              (endRange - startRange);
            scaled = Math.Max(Math.Min(scaled, 1.0), 0.0);
            startRange = Math.Min(startRange / intensity, 1.0);
            endRange = Math.Min(endRange / intensity, 1.0);

            var spokeSegment = this.shape.layout.GetSegment(part);
            foreach (var strut in spokeSegment.GetStruts()) {
              for (int i = 0; i < strut.Length; i++) {
            double gradientPos =
              strut.GetGradientPos(scaled, startRange, endRange, i);
            int color1 = gradientPos != -1.0
              ? LEDColor.ScaleColor(
                  dome.GetGradientColor(this.pad, gradientPos, 0.0, false),
                  scaleColor
                )
              : 0x000000;
            dome.SetPixel(strut.Index, i, color1);
              }
            }

            if (part + 1 == totalParts) {
              break;
            }

            var circleSegment = this.shape.layout.GetSegment(part + 1);
            var color2 = scaled == 1.0
              ? LEDColor.ScaleColor(dome.GetSingleColor(this.pad), scaleColor)
              : 0x000000;
            foreach (var strut in circleSegment.GetStruts()) {
              for (int i = 0; i < strut.Length; i++) {
            dome.SetPixel(strut.Index, i, color2);
              }
            }
              }
        }