Ejemplo n.º 1
0
        public static void DrawOutputPaths(Texture2D canvas, AXParametricObject po, float texSize, float imageSize)
        {
            if (po == null)
            {
                return;
            }

            // GET OUTPUT PARAMETER
            AXParameter p = po.getPreferredOutputSplineParameter();

            if (p == null)
            {
                return;
            }

            bool isClosed = (p.shapeState == ShapeState.Closed);

            Paths paths = null;

            if (p.polyTree != null)
            {
                paths = Clipper.PolyTreeToPaths(p.polyTree);
            }
            else if (p.paths != null)
            {
                paths = p.paths;
            }



            Rect  bounds = AXGeometryTools.Utilities.getClipperBounds(paths);
            float maxdim = (bounds.width > bounds.height) ? bounds.width : bounds.height;
            float scale  = imageSize / maxdim;


            long[] shifter       = AXGeometryTools.Utilities.getShifterToPathsCenter(paths);
            Paths  centeredPaths = AXGeometryTools.Utilities.shiftPathsAsGroup(paths, shifter);



            //Archimatix.printPaths(centeredPaths);

            Vector2 offset = new Vector2(texSize / 2, texSize / 2);

            float rot = po.floatValue("Rot_Z");



            Color lineColor = Color.magenta;

            lineColor = new Color(1, .5f, 1);
            foreach (Path path in centeredPaths)
            {
                Library.DrawPathsOnTexture(canvas, AXGeometryTools.Utilities.path2Vec2s(path, rot, scale), offset, isClosed, lineColor);
            }

            // AXES
            long s = (shifter[2] / 18);

            Path xaxis = new Path();

            xaxis.Add(new IntPoint(-s - shifter[0], -shifter[1]));
            xaxis.Add(new IntPoint(s - shifter[0], -shifter[1]));
            Library.DrawPathsOnTexture(canvas, AXGeometryTools.Utilities.path2Vec2s(xaxis, rot, scale), offset, false, Color.white);

            Path yaxis = new Path();

            yaxis.Add(new IntPoint(-shifter[0], -s - shifter[1]));
            yaxis.Add(new IntPoint(-shifter[0], s - shifter[1]));
            Library.DrawPathsOnTexture(canvas, AXGeometryTools.Utilities.path2Vec2s(yaxis, rot, scale), offset, false, Color.white);
        }