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); } }