//public SvgLine()
        //{
        //}

        //! Constructors
        public SvgLine(SvgPaintStyle paintStyle, Matrix3x3 transformation, float x1, float y1, float x2, float y2)
            : base(paintStyle, transformation)
        {
            d_x1 = x1;
            d_y1 = y1;
            d_x2 = x2;
            d_y2 = y2;
        }
        //public SvgCircle()
        //{
        //}

        public SvgCircle(SvgPaintStyle paintStyle,
                         Matrix3x3 transformation,
                         float cx,
                         float cy,
                         float r) : base(paintStyle, transformation)
        {
            d_cx = cx;
            d_cy = cy;
            d_r  = r;
        }
        //public SvgRect()
        //{
        //}

        public SvgRect(SvgPaintStyle paintStyle, Matrix3x3 transformation,
                       float x, float y, float width, float height, float rx = 0.0f, float ry = 0.0f)
            : base(paintStyle, transformation)
        {
            d_x      = x;
            d_y      = y;
            d_width  = width;
            d_height = height;
            d_rx     = rx;
            d_ry     = ry;
        }
Exemple #4
0
        /// <summary>
        /// Function that parses the paint style (fill and stroke parameters) from an SVG graphics element.
        /// </summary>
        /// <param name="attributes">
        /// The XML attributes from which the values will be parsed.
        /// </param>
        /// <returns></returns>
        private static SvgPaintStyle parsePaintStyle(XMLAttributes attributes)
        {
            var paintStyle = new SvgPaintStyle();

            // TODO: ...
            // unsupported/unspecified values should be inherited from the parents if possible, this
            // however would require adding an additional bool to every attribute member variable to check if
            // it is to be inherited or not
            var fillString = attributes.GetValueAsString(SVGGraphicsElementAttributeFill);

            parsePaintStyleFill(fillString, paintStyle);

            var fillRuleString = attributes.GetValueAsString(SVGGraphicsElementAttributeFillRule);

            parsePaintStyleFillRule(fillRuleString, paintStyle);

            var fillOpacityString = attributes.GetValueAsString(SVGGraphicsElementAttributeFillOpacity);

            parsePaintStyleFillOpacity(fillOpacityString, paintStyle);

            var strokeString = attributes.GetValueAsString(SVGGraphicsElementAttributeStroke);

            parsePaintStyleStroke(strokeString, paintStyle);

            var strokeWidthString = attributes.GetValueAsString(SVGGraphicsElementAttributeStrokeWidth, "1");

            parsePaintStyleStrokeWidth(strokeWidthString, paintStyle);

            var strokeLinecapString = attributes.GetValueAsString(SVGGraphicsElementAttributeStrokeLinecap, "butt");

            parsePaintStyleStrokeLinecap(strokeLinecapString, paintStyle);

            var strokeLinejoinString = attributes.GetValueAsString(SVGGraphicsElementAttributeStrokeLinejoin, "miter");

            parsePaintStyleStrokeLinejoin(strokeLinejoinString, paintStyle);

            var strokeMiterLimitString = attributes.GetValueAsString(SVGGraphicsElementAttributeStrokeMiterLimit, "4");

            parsePaintStyleMiterlimitString(strokeMiterLimitString, paintStyle);

            var strokeDashArrayString = attributes.GetValueAsString(SVGGraphicsElementAttributeStrokeDashArray);

            parsePaintStyleStrokeDashArray(strokeDashArrayString, paintStyle);

            var strokeDashOffsetString = attributes.GetValueAsString(SVGGraphicsElementAttributeStrokeDashOffset);

            parsePaintStyleStrokeDashOffset(strokeDashOffsetString, paintStyle);

            var strokeOpacityString = attributes.GetValueAsString(SVGGraphicsElementAttributeStrokeOpacity);

            parsePaintStyleStrokeOpacity(strokeOpacityString, paintStyle);

            return(paintStyle);
        }
        //public SvgEllipse()
        //{
        //}

        public SvgEllipse(SvgPaintStyle paintStyle,
                          Matrix3x3 transformation,
                          float cx,
                          float cy,
                          float rx,
                          float ry) : base(paintStyle, transformation)
        {
            d_cx = cx;
            d_cy = cy;
            d_rx = rx;
            d_ry = ry;
        }
Exemple #6
0
 //! Parses the String value of a 'stroke-width' property
 private static void parsePaintStyleStrokeWidth(string strokeWidthString, SvgPaintStyle paintStyle)
 {
     paintStyle.d_strokeWidth = Single.Parse(strokeWidthString);
     if (paintStyle.d_strokeWidth < 0.0f)
     {
         paintStyle.d_strokeWidth = 1.0f;
         System.GetSingleton()
         .Logger.LogEvent(
             "SVGData::parsePaintStyle - An unsupported value for stroke-width was specified in the SVG file. The value is set to the initial value '1'.",
             LoggingLevel.Errors);
     }
 }
Exemple #7
0
 //! Parses the String value of a 'stroke' property
 private static void parsePaintStyleStroke(string strokeString, SvgPaintStyle paintStyle)
 {
     if (String.IsNullOrEmpty(strokeString) || strokeString.Equals("none"))
     {
         paintStyle.d_stroke.d_none = true;
     }
     else
     {
         paintStyle.d_stroke.d_none   = false;
         paintStyle.d_stroke.d_colour = parseColour(strokeString);
     }
 }
Exemple #8
0
 //! Parses the String value of a 'stroke-opacity' property
 private static void parsePaintStyleStrokeOpacity(string strokeOpacityString, SvgPaintStyle paint_style)
 {
     if (String.IsNullOrEmpty(strokeOpacityString))
     {
         paint_style.d_strokeOpacity = 1.0f;
     }
     else
     {
         paint_style.d_strokeOpacity = Single.Parse(strokeOpacityString);
         //! Clamp value without ever throwing a warning
         paint_style.d_strokeOpacity = Math.Min(Math.Max(0.0f, paint_style.d_strokeOpacity), 1.0f);
     }
 }
Exemple #9
0
 //! Parses the String value of a 'fill-opacity' property
 private static void parsePaintStyleFillOpacity(string fillOpacityString, SvgPaintStyle paintStyle)
 {
     if (String.IsNullOrEmpty(fillOpacityString))
     {
         // Inherit value or use default
         paintStyle.d_fillOpacity = 1.0f;
     }
     else
     {
         paintStyle.d_fillOpacity = Single.Parse(fillOpacityString);
         //! Clamp value in each case without throwing a warning if the values are below 0 or above 1
         paintStyle.d_fillOpacity = Math.Min(Math.Max(0.0f, paintStyle.d_fillOpacity), 1.0f);
     }
 }
Exemple #10
0
 //! Parses the String value of a 'fill-rule' property
 private static void parsePaintStyleFillRule(string fillRuleString, SvgPaintStyle paintStyle)
 {
     if (String.IsNullOrEmpty(fillRuleString))
     {
         // Inherit value or use default
         paintStyle.d_fillRule = PolygonFillRule.NonZero;
     }
     else if (fillRuleString.Equals("nonzero"))
     {
         paintStyle.d_fillRule = PolygonFillRule.NonZero;
     }
     else if (fillRuleString.Equals("evenodd"))
     {
         paintStyle.d_fillRule = PolygonFillRule.EvenOdd;
     }
 }
Exemple #11
0
 //! Parses the String value of a 'fill' property
 private static void parsePaintStyleFill(string fillString, SvgPaintStyle paintStyle)
 {
     if (fillString.Equals("none"))
     {
         paintStyle.d_fill.d_none = true;
     }
     else if (String.IsNullOrEmpty(fillString))
     {
         // Inherit value or use default
         paintStyle.d_fill.d_none   = false;
         paintStyle.d_fill.d_colour = parseColour("black");
     }
     else
     {
         paintStyle.d_fill.d_none   = false;
         paintStyle.d_fill.d_colour = parseColour(fillString);
     }
 }
Exemple #12
0
 //! Parses the String value of a 'stroke-linecap' property
 private static void parsePaintStyleStrokeLinecap(string strokeLinecapString, SvgPaintStyle paintStyle)
 {
     if (strokeLinecapString.Equals("butt"))
     {
         paintStyle.d_strokeLinecap = SvgPaintStyle.SVGLinecap.SLC_BUTT;
     }
     else if (strokeLinecapString.Equals("round"))
     {
         paintStyle.d_strokeLinecap = SvgPaintStyle.SVGLinecap.SLC_ROUND;
     }
     else if (strokeLinecapString.Equals("square"))
     {
         paintStyle.d_strokeLinecap = SvgPaintStyle.SVGLinecap.SLC_SQUARE;
     }
     else
     {
         throw new Exception(
                   "SVG file parsing was aborted because of an invalid value for the SVG 'linecap' type");
     }
 }
Exemple #13
0
        //! Parses the String value of a 'stroke-dasharray' property
        private static void parsePaintStyleStrokeDashArray(string strokeDashArrayString, SvgPaintStyle paintStyle)
        {
            if (strokeDashArrayString.Equals("none"))
            {
                paintStyle.d_strokeDashArrayNone = true;
                paintStyle.d_strokeDashArray.Clear();
            }
            else
            {
                paintStyle.d_strokeDashArray = parseListOfLengths(strokeDashArrayString);

                var dashArraySize = paintStyle.d_strokeDashArray.Count;
                paintStyle.d_strokeDashArrayNone = dashArraySize != 0;
                //! If an odd number of values is provided, then the list of values shall be repeated to yield an even number of values
                if (paintStyle.d_strokeDashArrayNone == false && (dashArraySize % 2) == 1)
                {
                    paintStyle.d_strokeDashArray.AddRange(paintStyle.d_strokeDashArray);
                }
            }
        }
        //protected SvgBasicShape()
        //{
        //}

        protected SvgBasicShape(SvgPaintStyle paintStyle, Matrix3x3 transformation)
        {
            PaintStyle     = paintStyle;
            Transformation = transformation;
        }
        //public SvgPolygon()
        //{
        //}

        //! Constructor
        public SvgPolygon(SvgPaintStyle paintStyle, Matrix3x3 transformation, List <Vector2> points)
            : base(paintStyle, transformation)
        {
            d_points = points;
        }
 public SvgLine(SvgPaintStyle paintStyle, Matrix3x3 transformation, Vector2 lineStart, Vector2 lineEnd)
     : this(paintStyle, transformation, lineStart.X, lineStart.Y, lineEnd.X, lineEnd.Y)
 {
 }
Exemple #17
0
 //! Parses the String value of a 'stroke-dashoffset' property
 private static void parsePaintStyleStrokeDashOffset(string strokeDashOffsetString, SvgPaintStyle paint_style)
 {
     if (String.IsNullOrEmpty(strokeDashOffsetString))
     {
         paint_style.d_strokeDashOffset = 0.0f;
     }
     else
     {
         paint_style.d_strokeDashOffset = Single.Parse(strokeDashOffsetString);
     }
 }
Exemple #18
0
 //! Parses the String value of a 'stroke-miterlimit' property
 private static void parsePaintStyleMiterlimitString(string strokeMiterLimitString, SvgPaintStyle paintStyle)
 {
     paintStyle.d_strokeMiterlimit = Single.Parse(strokeMiterLimitString);
     if (paintStyle.d_strokeMiterlimit < 1.0f)
     {
         paintStyle.d_strokeMiterlimit = 4.0f;
         System.GetSingleton()
         .Logger.LogEvent(
             "SVGData::parsePaintStyle - An unsupported value for stroke-miterlimit was specified in the SVG file. The value is set to the initial value '4'.",
             LoggingLevel.Errors);
     }
 }
Exemple #19
0
 //! Parses the String value of a 'stroke-linejoin' property
 private static void parsePaintStyleStrokeLinejoin(string strokeLinejoinString, SvgPaintStyle paintStyle)
 {
     if (strokeLinejoinString.Equals("miter"))
     {
         paintStyle.d_strokeLinejoin = SvgPaintStyle.SVGLinejoin.SLJ_MITER;
     }
     else if (strokeLinejoinString.Equals("round"))
     {
         paintStyle.d_strokeLinejoin = SvgPaintStyle.SVGLinejoin.SLJ_ROUND;
     }
     else if (strokeLinejoinString.Equals("bevel"))
     {
         paintStyle.d_strokeLinejoin = SvgPaintStyle.SVGLinejoin.SLJ_BEVEL;
     }
     else
     {
         throw new Exception("SVG file parsing was aborted because of an invalid value for the SVG 'linejoin' type");
     }
 }