Beispiel #1
0
        public void stroke(Color s)
        {
            SVGPathAttributes attr = cur_attr();

            attr.StrokeColor = s;
            attr.StrokeFlag  = true;
        }
Beispiel #2
0
        // Attribute setting functions.
        public void fill(Color f)
        {
            SVGPathAttributes attr = cur_attr();

            attr.FillColor = f;
            attr.FillFlag  = true;
        }
Beispiel #3
0
 public SVGPathAttributes(SVGPathAttributes attr, int idx)
 {
     index       = idx;
     FillColor   = attr.FillColor;
     StrokeColor = attr.StrokeColor;
     FillFlag    = attr.FillFlag;
     StrokeFlag  = attr.StrokeFlag;
     EvenOddFlag = attr.EvenOddFlag;
     LineJoin    = attr.LineJoin;
     LineCap     = attr.LineCap;
     MiterLimit  = attr.MiterLimit;
     StrokeWidth = attr.StrokeWidth;
     Transform   = attr.Transform;
 }
Beispiel #4
0
 public void CopyFrom(SVGPathAttributes attr)
 {
     index       = attr.index;
     FillColor   = attr.FillColor;
     StrokeColor = attr.StrokeColor;
     FillFlag    = attr.FillFlag;
     StrokeFlag  = attr.StrokeFlag;
     EvenOddFlag = attr.EvenOddFlag;
     LineJoin    = attr.LineJoin;
     LineCap     = attr.LineCap;
     MiterLimit  = attr.MiterLimit;
     StrokeWidth = attr.StrokeWidth;
     Transform   = attr.Transform;
 }
Beispiel #5
0
        public void end_path()
        {
            if (m_attr_storage.Count == 0)
            {
                throw new SVGException("end_path : The path was not begun");
            }

            SVGPathAttributes attr = cur_attr();
            int idx = m_attr_storage[m_attr_storage.Count - 1].index;

            attr.index = idx;
            m_attr_storage[m_attr_storage.Count - 1].CopyFrom(attr);// = attr;
            PopAttr();
        }
Beispiel #6
0
        public void Render(Graphics graphics, Matrix4 mtx, GeometryProcessor transformer)
        {
            for (int i = 0; i < m_attr_storage.Count; i++)
            {
                SVGPathAttributes attr = m_attr_storage[i];
                m_transform = attr.Transform;
                m_transform.Multiply(mtx, MatrixOrder.Append);
                UpdateMatrixRelations();

                double scl = m_transform.Get2DScale();
                m_curved.ApproximationScale = scl;
                m_curved.AngleTolerance     = 0.0;

                if (attr.FillFlag)
                {
                    //TEMP  graphics.FillingRule(attr.EvenOddFlag ? FillEvenOdd : FillNonZero);

                    Color color = attr.FillColor;

                    if (System.Math.Abs(m_curved_trans_contour.Width) < 0.0001)
                    {
                        Geometry geometry = new IndexedPathGeometry(m_curved_trans, attr.index);
                        if (transformer == null)
                        {
                            graphics.FillGeometry(color, geometry);
                        }
                        else
                        {
                            transformer.Geometry = geometry;
                            graphics.FillGeometry(color, transformer);
                        }
                    }
                    else
                    {
                        m_curved_trans_contour.MiterLimit = attr.MiterLimit;

                        Geometry geometry = new IndexedPathGeometry(m_curved_trans_contour, attr.index);
                        if (transformer == null)
                        {
                            graphics.FillGeometry(color, geometry);
                        }
                        else
                        {
                            transformer.Geometry = geometry;
                            graphics.FillGeometry(color, transformer);
                        }
                    }
                }

                if (attr.StrokeFlag)
                {
                    m_curved_stroked.Width              = attr.StrokeWidth;
                    m_curved_stroked.LineJoin           = attr.LineJoin;
                    m_curved_stroked.LineCap            = attr.LineCap;
                    m_curved_stroked.MiterLimit         = attr.MiterLimit;
                    m_curved_stroked.InnerJoin          = Sketch.LineJoin.Round;
                    m_curved_stroked.ApproximationScale = scl;

                    // If the *visual* line width is considerable we
                    // turn on processing of curve cusps.
                    //---------------------
                    if (attr.StrokeWidth * scl > 1.0)
                    {
                        m_curved.AngleTolerance = 0.2;
                    }

                    Color color = attr.StrokeColor;

                    //TEMP  graphics.FillingRule(FillNonZero);

                    Geometry geometry = new IndexedPathGeometry(m_curved_stroked_trans, attr.index);
                    if (transformer == null)
                    {
                        graphics.FillGeometry(color, geometry);
                    }
                    else
                    {
                        transformer.Geometry = geometry;
                        graphics.FillGeometry(color, transformer);
                    }
                }
            }
        }
Beispiel #7
0
 public SVGPathAttributes(SVGPathAttributes attr)
 {
     CopyFrom(attr);
 }