예제 #1
0
        public override Color CreateColor(SvgDrawContext context, Rectangle objectBoundingBox, float objectBoundingBoxMargin
                                          , float parentOpacity)
        {
            if (objectBoundingBox == null)
            {
                return(null);
            }
            LinearGradientBuilder builder = new LinearGradientBuilder();

            foreach (GradientColorStop stopColor in ParseStops(parentOpacity))
            {
                builder.AddColorStop(stopColor);
            }
            builder.SetSpreadMethod(ParseSpreadMethod());
            bool isObjectBoundingBox = IsObjectBoundingBoxUnits();

            Point[] coordinates = GetCoordinates(context, isObjectBoundingBox);
            builder.SetGradientVector(coordinates[0].GetX(), coordinates[0].GetY(), coordinates[1].GetX(), coordinates
                                      [1].GetY());
            AffineTransform gradientTransform = GetGradientTransformToUserSpaceOnUse(objectBoundingBox, isObjectBoundingBox
                                                                                     );

            builder.SetCurrentSpaceToGradientVectorSpaceTransformation(gradientTransform);
            return(builder.BuildColor(objectBoundingBox.ApplyMargins(objectBoundingBoxMargin, objectBoundingBoxMargin,
                                                                     objectBoundingBoxMargin, objectBoundingBoxMargin, true), context.GetCurrentCanvasTransform(), context.
                                      GetCurrentCanvas().GetDocument()));
        }