Exemple #1
0
        /// <summary>
        /// Blends two EffectBrushes together by a specified amount
        /// </summary>
        /// <param name="otherBrush">The foreground EffectBrush (When percent is at 1.0D, only this EffectBrush is shown)</param>
        /// <param name="percent">The blending percent value</param>
        /// <returns>The blended EffectBrush</returns>
        public EffectBrush BlendEffectBrush(EffectBrush otherBrush, double percent)
        {
            if (percent <= 0.0)
            {
                return(new EffectBrush(this));
            }
            else if (percent >= 1.0)
            {
                return(new EffectBrush(otherBrush));
            }

            ColorSpectrum currentSpectrum = new ColorSpectrum(GetColorSpectrum());
            ColorSpectrum newSpectrum     = new ColorSpectrum(currentSpectrum).MultiplyByScalar(1.0 - percent);

            foreach (var kvp in otherBrush.colorGradients)
            {
                System.Drawing.Color bgColor = currentSpectrum.GetColorAt(kvp.Key);
                System.Drawing.Color fgColor = kvp.Value;

                newSpectrum.SetColorAt(kvp.Key, Utils.ColorUtils.BlendColors(bgColor, fgColor, percent));
            }

            EffectBrush returnBrush = new EffectBrush(newSpectrum);

            returnBrush.SetBrushType(type).SetWrap(wrap);

            returnBrush.start  = new System.Drawing.PointF((float)(start.X * (1.0 - percent) + otherBrush.start.X * (percent)), (float)(start.Y * (1.0 - percent) + otherBrush.start.Y * (percent)));
            returnBrush.end    = new System.Drawing.PointF((float)(end.X * (1.0 - percent) + otherBrush.end.X * (percent)), (float)(end.Y * (1.0 - percent) + otherBrush.end.Y * (percent)));
            returnBrush.center = new System.Drawing.PointF((float)(center.X * (1.0 - percent) + otherBrush.center.X * (percent)), (float)(center.Y * (1.0 - percent) + otherBrush.center.Y * (percent)));

            return(returnBrush);
        }
Exemple #2
0
 public EffectBrush(EffectBrush otherBrush)
 {
     this.type           = otherBrush.type;
     this.wrap           = otherBrush.wrap;
     this.colorGradients = otherBrush.colorGradients;
     this.start          = otherBrush.start;
     this.end            = otherBrush.end;
     this.center         = otherBrush.center;
 }
Exemple #3
0
        public bool Equals(EffectBrush p)
        {
            if (ReferenceEquals(null, p))
            {
                return(false);
            }
            if (ReferenceEquals(this, p))
            {
                return(true);
            }

            return(type == p.type &&
                   wrap == p.wrap &&
                   colorGradients.Equals(p.colorGradients) &&
                   start.Equals(p.start) &&
                   end.Equals(p.end) &&
                   center.Equals(p.center));
        }