Beispiel #1
0
        public void RenderConnection(Connection connection, Vector2 end)
        {
            var bound = connection.GetBounds();
            var pos   = new Vector2(bound.X, bound.Y);
            var v     = new Vector2((pos - end).Length / 4, 0);

            if (pos == end)
            {
                return;
            }
            NanoVG.nvgSave(MainWindow.Nvg);
            NanoVG.nvgLineCap(MainWindow.Nvg, (int)NvgLineCap.Round);
            NanoVG.nvgStrokeColor(MainWindow.Nvg, NanoVG.nvgRGBA(128, 128, 128, 255));
            var ctrl1 = connection.Side == NodeSide.Input ? pos - v : pos + v;
            var ctrl2 = connection.Side == NodeSide.Input ? end + v : end - v;

            NanoVG.nvgBeginPath(MainWindow.Nvg);
            NanoVG.nvgMoveTo(MainWindow.Nvg, pos.X, pos.Y);
            NanoVG.nvgBezierTo(MainWindow.Nvg, ctrl1.X, ctrl1.Y, ctrl2.X, ctrl2.Y, end.X, end.Y);
            NanoVG.nvgStroke(MainWindow.Nvg);
            NanoVG.nvgRestore(MainWindow.Nvg);
        }