Ejemplo n.º 1
0
        //-----------------------------------------------------------------------
        void parsePath(ref MultiShape @out, XmlNode pPathNode)
        {
            //if (pPathNode->first_attribute("d"))
            if (pPathNode.Attributes["d"] != null)
            {
                string temp = xtrim(pPathNode.Attributes["d"].Value, " .-0123456789mMlLhHvVcCsSqQtTaAzZ");
                std_vector <string> parts = split(temp, " ");
                for (int i = 0; i < parts.size(); i++)
                {
                    if (parts[i].Length > 1 && !(parts[i][0] == '-' || ('0' <= parts[i][0] && parts[i][0] <= '9')))
                    {
                        parts.insert(parts.begin() + i + 1, parts[i] + 1);
                        //parts[i].erase(1, parts[i].size());
                        parts[i] = parts[i].Remove(1);
                    }
                }

                SvgLoaderPath sp = new SvgLoaderPath(parts, mNumSeg);
                if (!sp.isValid())
                {
                    return;
                }
                Shape   ss   = sp.getSvgShape();
                Vector2 line = ss.getPoint(1) - ss.getPoint(0);
                //Real deg = line.angleBetween(ss.getPoint(2) - ss.getPoint(0)).valueDegrees();
                float deg = Utils.angleBetween(line, ss.getPoint(2) - ss.getPoint(0)).ValueDegrees;
                if ((0 <= deg && deg <= 180.0f) || (-180.0f <= deg && deg <= 0))
                {
                    ss.setOutSide(Side.SIDE_LEFT);
                }
                else
                {
                    ss.setOutSide(Side.SIDE_RIGHT);
                }

                //if(pPathNode->first_attribute("id"))
                //	ss.id = pPathNode->first_attribute("id")->value();
                ss.translate(getAttribTranslate(pPathNode));
                @out.addShape(ss);
            }
        }
Ejemplo n.º 2
0
 /// Inserts a point to the path
 /// @param index the index before the inserted point
 /// @param x new point's x coordinate
 /// @param y new point's y coordinate
 /// @param z new point's z coordinate
 public Path insertPoint(int index, float x, float y, float z)
 {
     //
     mPoints.insert(index, new Vector3(x, y, z));
     return(this);
 }