Example #1
0
        protected override unsafe void FillBuffer(ref BrushBuffer buffer)
        {
            buffer.Type = 2;

            if (gradientStops != null && gradientStops.Length > 0)
            {
                buffer.ColorCount = gradientStops.Length;

                fixed(float *colors = buffer.GradientColors, positions = buffer.GradientPositions)
                {
                    for (int i = 0; i < gradientStops.Length; i++)
                    {
                        colors[4 * i + 0] = gradientStops[i].Color.R;
                        colors[4 * i + 1] = gradientStops[i].Color.G;
                        colors[4 * i + 2] = gradientStops[i].Color.B;
                        colors[4 * i + 3] = gradientStops[i].Color.A;

                        positions[i * 4] = gradientStops[i].Position;
                    }
                }
            }

            buffer.Point1 = Transform.ApplyTo(StartPoint).ToSharpDXVector();
            buffer.Point2 = Transform.ApplyTo(EndPoint).ToSharpDXVector();
        }
        protected override unsafe void FillBuffer(ref BrushBuffer buffer)
        {
            buffer.Type = 2;

            if (gradientStops != null && gradientStops.Length > 0)
            {
                buffer.ColorCount = gradientStops.Length;

                fixed (float* colors = buffer.GradientColors, positions = buffer.GradientPositions)
                {
                    for (int i = 0; i < gradientStops.Length; i++)
                    {
                        colors[4 * i + 0] = gradientStops[i].Color.R;
                        colors[4 * i + 1] = gradientStops[i].Color.G;
                        colors[4 * i + 2] = gradientStops[i].Color.B;
                        colors[4 * i + 3] = gradientStops[i].Color.A;

                        positions[i * 4] = gradientStops[i].Position;
                    }
                }
            }

            buffer.Point1 = Transform.ApplyTo(StartPoint).ToSharpDXVector();
            buffer.Point2 = Transform.ApplyTo(EndPoint).ToSharpDXVector();
        }
Example #3
0
        internal BrushBuffer CreateBuffer()
        {
            var buffer = new BrushBuffer {
                Opacity = opacity
            };

            FillBuffer(ref buffer);
            return(buffer);
        }
Example #4
0
 protected override unsafe void FillBuffer(ref BrushBuffer buffer)
 {
     buffer.Type = 4;
     fixed(float *colors = buffer.GradientColors)
     {
         colors[0] = Color.R;
         colors[1] = Color.G;
         colors[2] = Color.B;
         colors[3] = Color.A;
     }
 }
Example #5
0
 protected override unsafe void FillBuffer(ref BrushBuffer buffer)
 {
     buffer.Type = 1;
     fixed (float* colors = buffer.GradientColors)
     {
         colors[0] = Color.R;
         colors[1] = Color.G;
         colors[2] = Color.B;
         colors[3] = Color.A;
     }
 }
Example #6
0
        protected override unsafe void FillBuffer(ref BrushBuffer buffer)
        {
            buffer.Type = 3;

            if (gradientStops != null && gradientStops.Length > 0)
            {
                buffer.ColorCount = gradientStops.Length;

                fixed(float *colors = buffer.GradientColors, positions = buffer.GradientPositions)
                {
                    for (int i = 0; i < gradientStops.Length; i++)
                    {
                        colors[4 * i + 0] = gradientStops[i].Color.R;
                        colors[4 * i + 1] = gradientStops[i].Color.G;
                        colors[4 * i + 2] = gradientStops[i].Color.B;
                        colors[4 * i + 3] = gradientStops[i].Color.A;

                        positions[i * 4] = gradientStops[i].Position;
                    }
                }
            }

            Matrix2x3 transformFromCircle = Matrix2x3.Translation(Center) * Matrix2x3.Rotation(Angle) * Matrix2x3.Scaling(RadiusX, RadiusY);
            Matrix2x3 transformToCircle   = (Transform * transformFromCircle).Invert();

            fixed(float *matrix = buffer.Matrix)
            {
                for (int i = 0; i < 6; i++)
                {
                    matrix[i * 4] = transformToCircle[i / 3, i % 3];
                }
            }

            if (FocusPoint.HasValue)
            {
                Vector2 transformedFocusPoint = transformToCircle.ApplyTo(FocusPoint.Value);
                buffer.Point1 = new SharpDX.Vector2(transformedFocusPoint.X, transformedFocusPoint.Y);
                buffer.Point2 = new SharpDX.Vector2(1, 0);
            }
        }
        protected override unsafe void FillBuffer(ref BrushBuffer buffer)
        {
            buffer.Type = 3;

            if (gradientStops != null && gradientStops.Length > 0)
            {
                buffer.ColorCount = gradientStops.Length;

                fixed (float* colors = buffer.GradientColors, positions = buffer.GradientPositions)
                {
                    for (int i = 0; i < gradientStops.Length; i++)
                    {
                        colors[4 * i + 0] = gradientStops[i].Color.R;
                        colors[4 * i + 1] = gradientStops[i].Color.G;
                        colors[4 * i + 2] = gradientStops[i].Color.B;
                        colors[4 * i + 3] = gradientStops[i].Color.A;

                        positions[i * 4] = gradientStops[i].Position;
                    }
                }
            }

            Matrix2x3 transformFromCircle = Matrix2x3.Translation(Center) * Matrix2x3.Rotation(Angle) * Matrix2x3.Scaling(RadiusX, RadiusY);
            Matrix2x3 transformToCircle = (Transform * transformFromCircle).Invert();
            fixed (float* matrix = buffer.Matrix)
            {
                for (int i = 0; i < 6; i++)
                    matrix[i * 4] = transformToCircle[i / 3, i % 3];
            }

            if (FocusPoint.HasValue)
            {
                Vector2 transformedFocusPoint = transformToCircle.ApplyTo(FocusPoint.Value);
                buffer.Point1 = new SharpDX.Vector2(transformedFocusPoint.X, transformedFocusPoint.Y);
                buffer.Point2 = new SharpDX.Vector2(1, 0);
            }
        }
Example #8
0
 protected abstract void FillBuffer(ref BrushBuffer buffer);
Example #9
0
 internal BrushBuffer CreateBuffer()
 {
     var buffer = new BrushBuffer { Opacity = opacity };
     FillBuffer(ref buffer);
     return buffer;
 }
Example #10
0
 protected abstract void FillBuffer(ref BrushBuffer buffer);