Example #1
0
    private void DrawNodes()
    {
        if (configuration == null)
        {
            return;
        }

        foreach (Node node in configuration.nodes)
        {
            GUI.skin = nodeSkin;

            if (IsSelectedNode(node))
            {
                GUI.color = new Color(
                    ColorAtlas.orange.r,
                    ColorAtlas.orange.g,
                    ColorAtlas.orange.b,
                    0.55F);

                Rect selection_rect = ViewportService.ToScreenRect(node.position);

                selection_rect.x      -= border_width * 0.5F;
                selection_rect.y      -= border_width * 0.5F;
                selection_rect.width  += border_width;
                selection_rect.height += border_width;

                GUI.Box(selection_rect, "");
            }

            var right_rect = ViewportService.ToScreenRect(ViewportService.GetConnectionEllipse(true, node.position, false));
            var left_rect  = ViewportService.ToScreenRect(ViewportService.GetConnectionEllipse(false, node.position, false));

            GUI.color = node.color;

            GUI.Box(ViewportService.ToScreenRect(node.position), "");

            GUI.color = new Color(0, 1F, 1F, 0.3F);
            GUI.skin  = nodeElipseSkin;

            if (NodeRules.ContainsRightConnection(node))
            {
                GUI.Box(right_rect, "");
            }

            if (NodeRules.ContainsLeftConnection(node))
            {
                GUI.Box(left_rect, "");
            }

            if (editorState == EditorState.Waiting && inputController.isLeftMouse && IsSelectedNode(node))
            {
                node.position.position += inputController.delta * 0.5F;

                CalculateCollision(inputController.delta, node);

                Repaint();
            }
        }
    }
Example #2
0
    private void CreateNode(int Type, Vector2 position)
    {
        Node node = NodeRules.CreateNode(Type);

        node.position = new Rect(ViewportService.FromScreenPoint(position), new Vector2(100, 100));

        configuration?.AddNode(node);
    }
 public Node ToNode(Neuron value)
 {
     if (value is EntryNeuron)
     {
         return(NodeRules.CreateNode(0));
     }
     else if (value is OutputNeuron)
     {
         return(NodeRules.CreateNode(1));
     }
     else if (value is SigmoidNeuron)
     {
         return(NodeRules.CreateNode(2));
     }
     else
     {
         throw new System.NotImplementedException();
     }
 }