Skip to content

Commit

Permalink
Update demo + add docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
Correct-Syntax committed Nov 1, 2021
1 parent 7f6405d commit 80d2fcf
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 19 deletions.
24 changes: 12 additions & 12 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ def __init__(self, parent, id=wx.ID_ANY, title=wx.EmptyString,
wx.Frame.__init__(self, parent, id, title, pos, size, style, name)

registry = {
'image_node': ImageNode,
'mix_node': MixNode,
'blur_node': BlurNode,
'blend_node': BlendNode,
'output_node': OutputNode
'image_nodeid': ImageNode,
'mix_nodeid': MixNode,
'blur_nodeid': BlurNode,
'blend_nodeid': BlendNode,
'output_nodeid': OutputNode
}

ng = NodeGraph(self, registry)

node1 = ng.AddNode('image_node', wx.Point(100, 10))
node2 = ng.AddNode('image_node', wx.Point(450, 400))
node3 = ng.AddNode('mix_node', wx.Point(400, 100))
node4 = ng.AddNode('blur_node', wx.Point(700, 100))
node5 = ng.AddNode('blend_node', wx.Point(720, 300))
node6 = ng.AddNode('output_node', wx.Point(1000, 290))
node1 = ng.AddNode('image_nodeid', wx.Point(100, 10))
node2 = ng.AddNode('image_nodeid', wx.Point(450, 400))
node3 = ng.AddNode('mix_nodeid', wx.Point(400, 100))
node4 = ng.AddNode('blur_nodeid', wx.Point(700, 100))
node5 = ng.AddNode('blend_nodeid', wx.Point(720, 300))
node6 = ng.AddNode('output_nodeid', wx.Point(1000, 290))

self.Maximize(True)

Expand All @@ -85,6 +85,6 @@ def OnDestroy(self, event):
if __name__ == '__main__':
app = MainApp()
frame = MyFrame(None, size=(512, 512))
frame.SetTitle('GS Nodegraph Demo')
frame.SetTitle('GSNodegraph Demo')
frame.Show()
app.MainLoop()
66 changes: 59 additions & 7 deletions nodes/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,66 @@
from gsnodegraph import NodeBase


class Image(object):
""" An example datatype. """
# Create your datatype. For this example, we do nothing.
pass


class Parameter(object):
""" Example parameter base class. """
def __init__(self, idname, label, default):
self.idname = idname
self.label = label
self.default = default
self.binding = None
self.datatype = None


class ImageParam(Parameter):
""" Example parameter. """
def __init__(self, idname, label, default=Image()):
Parameter.__init__(self, idname, label, default)
self.value = default
self.datatype = "RGBAIMAGE"

def GetValue(self):
return self.value

def SetValue(self, value):
self.value = value


class IntegerParam(Parameter):
""" Example parameter. """
def __init__(self, idname, label, default=1):
Parameter.__init__(self, idname, label, default)
self.value = default
self.datatype = "VALUE"

def GetValue(self):
return self.value

def SetValue(self, value):
self.value = value


class OutputNode(NodeBase):
""" Example output node. Only one of these should exist at a time.
Use ``self._isoutput = True`` to set as the output node. """
def __init__(self, nodegraph, _id):
NodeBase.__init__(self, nodegraph, _id)

self._label = "Output"
self._isoutput = True
self._category = "OUTPUT"
self._parameters = {
"Image": None
"image_socketid": ImageParam("image_socketid", "Image")
}


class ImageNode(NodeBase):
""" Example node showing an input node. """
def __init__(self, nodegraph, _id):
NodeBase.__init__(self, nodegraph, _id)

Expand All @@ -39,36 +86,41 @@ def __init__(self, nodegraph, _id):


class MixNode(NodeBase):
""" Example node showing a node with multiple inputs. """
def __init__(self, nodegraph, _id):
NodeBase.__init__(self, nodegraph, _id)

self._label = "Mix"
self._category = "BLEND"
self._parameters = {
"Image 1": None,
"Image 2": None
"image1_socketid": ImageParam("image1_socketid", "Overlay"),
"image2_socketid": ImageParam("image2_socketid", "Image")
}


class BlurNode(NodeBase):
""" Example node showing a node with multiple inputs
and different datatypes. """
def __init__(self, nodegraph, _id):
NodeBase.__init__(self, nodegraph, _id)

self._label = "Blur"
self._category = "FILTER"
self._parameters = {
"Image": None,
"image1_socketid": ImageParam("image1_socketid", "Image"),
"int_socketid": IntegerParam("int_socketid", "Integer")
}


class BlendNode(NodeBase):
""" Example node showing a node with multiple inputs. """
def __init__(self, nodegraph, _id):
NodeBase.__init__(self, nodegraph, _id)

self._label = "Blend"
self._category = "BLEND"
self._parameters = {
"Alpha Mask": None,
"Image 1": None,
"Image 2": None
"alphamask_socketid": ImageParam("alphamask_socketid", "Alpha"),
"image1_socketid": ImageParam("image1_socketid", "Image"),
"image2_socketid": ImageParam("image2_socketid", "Image")
}

0 comments on commit 80d2fcf

Please sign in to comment.