void ParseArc(float[] floatArgs, bool isRel)
        {
            // in arc coordinate system
            Vector2 prevPos = new Vector2(_curHandle.pos.x, _curHandle.pos.y) - _origin;
            prevPos.y = -prevPos.y;

            List<float> cubicArgs = new List<float>();
            int i = 0;
            while (i < floatArgs.Length)
            {
                Vector2 r = new Vector2(floatArgs[i++], floatArgs[i++]);
                float phi = -floatArgs[i++];
                float arcFlag = floatArgs[i++];
                float sweepFlag = floatArgs[i++];

                Vector2 pos = new Vector2(floatArgs[i++], floatArgs[i++]);
                if (isRel) pos += prevPos;

                float[] c = SVGHelper.a2c(prevPos.x, prevPos.y, pos.x, pos.y, arcFlag, sweepFlag, r.x, r.y, phi);
                cubicArgs.AddRange(c);

                prevPos = pos;
            }

            ParseCubic(cubicArgs.ToArray(), false, false);
        }
        public EmployeeView()
            : base(typeof(SynchronizedEmployeeViewModel))
        {
            InitializeComponent();
            gvTasks.SetViewFontSize(2, 1);
            gvEvaluations.SetViewFontSize(2, 1);
            BindCommands();
            ViewModel.EntityChanged             += ViewModel_EntityChanged;
            officeTabFilter.SelectedItemChanged += OfficeTabFilter_SelectedItemChanged;
            tvEvaluations.ItemCustomize         += tvEvaluations_ItemCustomize;
            tvTasks.ItemCustomize += tvTasks_ItemCustomize;
            gcTasks.SizeChanged   += (s, e) =>
            {
                if (gcTasks.MainView == tvTasks)
                {
                    tvTasks.RefreshData();
                }
            };

            var asm = typeof(MainForm).Assembly;

            svgYes         = SvgImage.FromResources("DevExpress.DevAV.Resources.EvaluationYes.svg", asm);
            svgNo          = SvgImage.FromResources("DevExpress.DevAV.Resources.EvaluationNo.svg", asm);
            priorityImages = SVGHelper.CreateTaskPriorityImages(LookAndFeel, "DevExpress.DevAV.Resources.Tasks.");
            buttonPanel.UseButtonBackgroundImages = false;
        }
    void Start()
    {
        // Prepare the vector path, add it to the vector scene.
        m_Path = new Shape()
        {
            Contours = new BezierContour[] {
                new BezierContour()
                {
                    Segments = new BezierPathSegment[2]
                },
                new BezierContour()
                {
                    Segments = new BezierPathSegment[2]
                }
            },
            PathProps = new PathProperties()
            {
                Stroke = new Stroke()
                {
                    Color         = Color.white,
                    HalfThickness = 0.1f
                }
            }
        };

        m_Scene = new Scene()
        {
            Root = new SceneNode()
            {
                Shapes = new List <Shape> {
                    //m_Path
                }
            }
        };

        m_Options = new VectorUtils.TessellationOptions()
        {
            StepDistance         = 1000.0f,
            MaxCordDeviation     = 0.05f,
            MaxTanAngleDeviation = 0.05f,
            SamplingStepSize     = 0.01f
        };

        // Instantiate a new mesh, it will be filled with data in Update()
        m_Mesh = new Mesh();
        GetComponent <MeshFilter>().mesh = m_Mesh;


        // =======================================================================
        string path = string.Format(@"D:\WriteByHand\svgs\{0}.svg", 20986);
        string svg  = SVGHelper.readSVG(path);

        SVGParser.SceneInfo scene_info = SVGParser.ImportSVG(new StringReader(svg));
        Scene     scene = scene_info.Scene;
        SceneNode word  = scene.Root.Children[1];

        // 前半為背景(無 Clipper),後半為寫字筆劃(有 Clipper)
        List <SceneNode> bg_and_stroke = word.Children;
        int double_stroke_number       = bg_and_stroke.Count;
        int stroke_number = double_stroke_number / 2;

        // 筆劃第一筆
        SceneNode    test_node         = bg_and_stroke[stroke_number];
        List <Shape> test_shapes       = test_node.Shapes;
        SceneNode    test_clipper_node = (test_node.Clipper == null) ? null : test_node.Clipper;
        List <Shape> test_clippers     = new List <Shape>();

        if (test_clipper_node != null)
        {
            test_clippers = test_clipper_node.Children[0].Shapes;
            if (test_clippers != null)
            {
                print("test_clippers len:" + test_clippers.Count);
                Shape test_clipper_shape = test_clippers[0];
            }
            else
            {
                print("test_clippers is null");
            }
        }
        else
        {
            print("test_clipper_node is null");
        }

        Shape test_stroke = test_shapes[0];

        BezierContour[]     bezierContours     = test_stroke.Contours;
        BezierPathSegment[] bezierPathSegments = bezierContours[0].Segments;
        BezierPathSegment   point1             = bezierPathSegments[0];
        BezierPathSegment   point2             = bezierPathSegments[bezierPathSegments.Length - 1];

        #region Word scene
        // 遮罩嘗試
        display_scene = new Scene()
        {
            Root = new SceneNode()
            {
                Children = new List <SceneNode>()
                {
                    #region One stroke
                    new SceneNode()
                    {
                        Shapes = new List <Shape>()
                        {
                            #region Piece of stroke
                            new Shape()
                            {
                                Contours = new BezierContour[] {
                                    new BezierContour()
                                    {
                                        Segments = new BezierPathSegment[]
                                        {
                                            point1,
                                            point2
                                        }
                                    },
                                    //new BezierContour() {
                                    //    Segments = new BezierPathSegment[2]
                                    //}
                                },
                                PathProps = new PathProperties()
                                {
                                    Stroke = new Stroke()
                                    {
                                        Color         = Color.white,
                                        HalfThickness = 10f
                                    }
                                }
                            }
                            #endregion Piece of stroke end
                        },
                        Clipper = new SceneNode()
                        {
                            Shapes = new List <Shape>()
                            {
                                #region Piece of clipper
                                test_clippers[0]
                                #endregion Piece of clipper end
                            }
                        }
                    }
                    #endregion One stroke end
                }
            }
        };
        #endregion Word scene end

        StartCoroutine(nextStroke(bg_and_stroke));
    }
Beispiel #4
0
    // Start is called before the first frame update
    void Start()
    {
        string path = string.Format(@"D:\WriteByHand\svgs\{0}.svg", 20986);
        string svg  = SVGHelper.readSVG(path);

        SVGParser.SceneInfo scene_info = SVGParser.ImportSVG(new StringReader(svg));
        scene = scene_info.Scene;

        // svg 本體
        SceneNode        node   = scene.Root;
        List <SceneNode> layer1 = node.Children;

        // node0:背景米字;node1:字的筆劃
        SceneNode node0 = layer1[0], node1 = layer1[1];

        // 背景米字
        //List<SceneNode> layer2 = node0.Children;
        //print("layer2:" + layer2.Count);

        // 字的筆劃
        List <SceneNode> layer3 = node1.Children;

        //print("layer3:" + layer3.Count);
        //int n = 0;
        //foreach (SceneNode scene_node in layer3)
        //{
        //    print(string.Format("=== Node {0} ===", ++n));
        //    List<Shape> shapes = scene_node.Shapes; // length = 1
        //    Shape shape = shapes[0]; // length = 1
        //    BezierContour[] contours = shape.Contours; // length = 1
        //    BezierPathSegment[] segments = contours[0].Segments; // 每一筆劃的區段數量不同
        //    int num = 0;
        //    foreach(BezierPathSegment bezierPathSegment in segments)
        //    {
        //        print(string.Format("= segment {0} =", ++num));
        //        print(bezierPathSegment.P0);
        //        print(bezierPathSegment.P1);
        //        print(bezierPathSegment.P2);
        //        break;
        //    }

        //    SceneNode clipper = (scene_node.Clipper == null) ? null : scene_node.Clipper;
        //    if(clipper != null)
        //    {
        //        List<SceneNode> clippers = clipper.Children; // length = 1
        //        SceneNode mask = clippers[0];
        //        List<Shape> m_shapes = mask.Shapes; // length = 1
        //        Shape m_shape = m_shapes[0];
        //        BezierContour[] m_contours = m_shape.Contours; // length = 1
        //        //print("m_contours len:" + m_contours.Length);
        //        BezierPathSegment[] m_segments = m_contours[0].Segments; // 每一筆劃的區段數量不同
        //        //print("m_segments len:" + m_segments.Length);
        //        int number = 0;
        //        foreach (BezierPathSegment m_bezierPathSegment in m_segments)
        //        {
        //            print(string.Format("= clipper segment {0} =", ++number));
        //            print(m_bezierPathSegment.P0);
        //            print(m_bezierPathSegment.P1);
        //            print(m_bezierPathSegment.P2);
        //            break;
        //        }
        //    }
        //    else
        //    {
        //        print("clipper is null");
        //    }
        //}

        n_scene = new Scene()
        {
            Root = new SceneNode()
            {
                // node.Children  正常的字
                // node1.Children  上下相反的字
                //Children = node.Children
                Children = new List <SceneNode>()
                {
                    new SceneNode()
                    {
                        Children = node1.Children
                    }
                }
            }
        };


        //foreach (SceneNode sceneNode in layer3)
        //{
        //    n_scene.Root.Children.Add(sceneNode);
        //}

        sceneDisplay(n_scene, render);

        //StartCoroutine(nextStroke(layer3));
    }