Ejemplo n.º 1
0
 public Circle()
 {
     _circleRadius = RandomNumberProvider.GetDouble();
     _circleColor  = DoubleColor.GetRandomColor();
     _circleColor.RandomizeAlpha();
     _circleColor.A = _circleColor.A / 2.0;
 }
Ejemplo n.º 2
0
        public static DoubleColor GetRandomColorAlpha()
        {
            DoubleColor color = GetRandomColor();

            color.A = RandomNumberProvider.GetDouble();

            return(color);
        }
Ejemplo n.º 3
0
        public override PointColor Transform(PointColor input)
        {
            double inX = input.X;

            if (inX < 0)
            {
                inX = -inX + _stripeWidth;
            }

            if (inX % (_stripeWidth * 2) < _stripeWidth)
            {
                input.Color = DoubleColor.Combine(input.Color, _stripeColor);
            }

            return(input);
        }
Ejemplo n.º 4
0
        public override PointColor Transform(PointColor input)
        {
            var inX = input.X - 0.5;
            var inY = input.Y - 0.5;

            inX = inX % 1.0;
            inY = inY % 1.0;

            var dist = Math.Sqrt(Math.Pow(inX, 2.0) + Math.Pow(inY, 2.0));

            if (dist < _circleRadius)
            {
                input.Color = DoubleColor.Combine(input.Color, _circleColor);
            }

            return(input);
        }
Ejemplo n.º 5
0
        public static DoubleColor GetRandomColor()
        {
            if (RandomNumberProvider.GetDouble() < 0.5)
            {
                if (RandomNumberProvider.GetDouble() < 0.5)
                {
                    if (RandomNumberProvider.GetDouble() < 0.5)
                    {
                        return(DoubleColor.WhiteColor());
                    }
                    else
                    {
                        return(DoubleColor.BlackColor());
                    }
                }
                var value = RandomNumberProvider.GetDouble();
                return(new DoubleColor(value, value, value));
            }

            return(new DoubleColor(RandomNumberProvider.GetDouble(), RandomNumberProvider.GetDouble(), RandomNumberProvider.GetDouble()));
        }
Ejemplo n.º 6
0
        public static DoubleColor Combine(DoubleColor colorA, DoubleColor colorB)
        {
            if (colorA.A == 0.0)
            {
                return(colorB);
            }
            if (colorB.A == 0.0)
            {
                return(colorA);
            }

            double totalAlpha = colorA.A + colorB.A;
            double aWeight    = (colorA.A / totalAlpha);
            double bWeight    = (colorB.A / totalAlpha);

            double r = (colorA.R * aWeight) + (colorB.R * bWeight);
            double g = (colorA.G * aWeight) + (colorB.G * bWeight);
            double b = (colorA.B * aWeight) + (colorB.B * bWeight);

            return(new DoubleColor(r, g, b, (totalAlpha / 2.0)));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Generate a random gradient
        /// </summary>
        public Gradient()
        {
            // Add beginning and end points
            _segments.Add(0.0, DoubleColor.GetRandomColorAlpha());
            _segments.Add(1.0, DoubleColor.GetRandomColorAlpha());

            // Determine number of intermediate points
            var loops   = 1;
            var loopVal = RandomNumberProvider.GetDouble();

            while (loopVal < (0.75 / loops))
            {
                var newSegmentIndex = RandomNumberProvider.GetDouble();

                if (!_segments.ContainsKey(newSegmentIndex))
                {
                    _segments.Add(newSegmentIndex, DoubleColor.GetRandomColorAlpha());
                }

                loops++;
            }
        }
Ejemplo n.º 8
0
 public VerticalStripe()
 {
     _stripeWidth   = RandomNumberProvider.GetDouble() * 0.25;
     _stripeColor   = DoubleColor.GetRandomColorAlpha();
     _stripeColor.A = _stripeColor.A / 2.0;
 }
Ejemplo n.º 9
0
 public PointColor(double x, double y, DoubleColor color)
 {
     X     = x;
     Y     = y;
     Color = color;
 }
Ejemplo n.º 10
0
 public PointColor()
 {
     X     = 0.0;
     Y     = 0.0;
     Color = DoubleColor.BlackColor();
 }