Exemplo n.º 1
0
        // Draw the node on canvas.
        public void Draw()
        {
            switch (Terminal)
            {
            case NodeTerminalType.NonTerminal:
                // Highlighting.
                if (Selected)
                {
                    EditorCanvas.DrawQuad(new Rect(OutlineScope.x - _thickness, (int)OutlineScope.y - _thickness, OutlineScope.width + _thickness * 2, OutlineScope.height + _thickness * 2), Color.red);
                }
                // Main part of node.
                EditorCanvas.DrawQuad(OutlineScope, OutlineColor);
                EditorCanvas.DrawQuad(FilledScope, FilledColor);
                EditorCanvas.DrawQuad(TextScope, Color.clear, "<" + Ordering + ">\n" + Abbreviation, TextColor);
                break;

            case NodeTerminalType.Terminal:
                // Highlighting.
                if (Selected)
                {
                    EditorCanvas.DrawDisc(Position, OutlineScope.width / 2 + _thickness, Color.red);
                }
                // Main part of node.
                EditorCanvas.DrawDisc(Position, OutlineScope.width / 2, OutlineColor);
                EditorCanvas.DrawDisc(Position, OutlineScope.width / 2 - _thickness, FilledColor);
                EditorCanvas.DrawQuad(TextScope, Color.clear, "<" + Ordering + ">\n" + Abbreviation, TextColor);
                break;
            }
        }
Exemplo n.º 2
0
        // Draw the connection on canvas.
        public void Draw()
        {
            if (StartpointStickyOn != null)
            {
                StartPosition = StartpointStickyOn.Position + (EndPosition - StartpointStickyOn.Position).normalized * StartpointStickyOn.FilledScope.width / 2;
            }
            if (EndpointStickyOn != null)
            {
                EndPosition = EndpointStickyOn.Position + (StartPosition - EndpointStickyOn.Position).normalized * EndpointStickyOn.FilledScope.width / 2;
            }
            // Draw the main line about connection.
            EditorCanvas.DrawLine(StartPosition, EndPosition, OutlineColor, LineThickness);
            // Head size
            Vector2 dir        = (EndPosition - StartPosition).normalized * LineThickness;
            Vector2 orthoptics = new Vector2(-dir.y, dir.x);

            // Arrow cap's points
            Vector3[] arrowHead = new Vector3[3];
            arrowHead[0] = EndPosition - dir * 2 + orthoptics;
            arrowHead[1] = EndPosition - dir * 2 - orthoptics;
            arrowHead[2] = EndPosition;
            Vector3[] arrowHeadSec = new Vector3[3];
            Vector2   dir2         = dir = dir + dir * 1f;

            arrowHeadSec[0] = EndPosition - dir2 * 2 + orthoptics;
            arrowHeadSec[1] = EndPosition - dir2 * 2 - orthoptics;
            arrowHeadSec[2] = EndPosition - dir2;
            // Draw the arraw part.
            switch (this.Arrow)
            {
            case ConnectionArrowType.Normal:
                EditorCanvas.DrawTriangle(arrowHead, OutlineColor);
                break;

            case ConnectionArrowType.Double:
                EditorCanvas.DrawTriangle(arrowHead, OutlineColor);
                EditorCanvas.DrawTriangle(arrowHeadSec, OutlineColor);
                break;

            case ConnectionArrowType.WithCircle:
                EditorCanvas.DrawTriangle(arrowHeadSec, OutlineColor);
                EditorCanvas.DrawDisc(EndPosition - dir2 / 2f, LineThickness, OutlineColor);
                EditorCanvas.DrawDisc(EndPosition - dir2 / 2f, LineThickness - 1, Color.white);
                break;
            }
            // Endpoints of conneciton.
            if (Selected)
            {
                EditorCanvas.DrawQuad(StartpointScope, Color.red);
                EditorCanvas.DrawQuad(EndpointScope, Color.blue);
            }
        }