-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatrixFilterApplyElement.cs
89 lines (76 loc) · 2.82 KB
/
MatrixFilterApplyElement.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using MetaphysicsIndustries.Solus;
using MetaphysicsIndustries.Crystalline;
using MetaphysicsIndustries.Epiphany;
using MetaphysicsIndustries.Acuity;
using MetaphysicsIndustries.Utilities;
namespace MetaphysicsIndustries.Amethyst
{
[Serializable]
public class MatrixFilterApplyElement/*<T>*/ : AmethystElement
//where T : MatrixFilter
{
public MatrixFilterApplyElement()
: base(new MatrixFilterApplyNode(), new SizeV(120,60))
{
}
[Serializable]
public class MatrixFilterApplyNode : Node
{
public MatrixFilterApplyNode()
: base("Filter Apply")
{
}
protected override void InitConnections()
{
InputConnectionBases.Add(Input);
InputConnectionBases.Add(Filter);
OutputConnectionBases.Add(Output);
}
private InputConnection<Matrix> _input = new InputConnection<Matrix>("Input");
public InputConnection<Matrix> Input
{
get { return _input; }
}
private InputConnection<MatrixFilter> _filter = new InputConnection<MatrixFilter>("Filter");
public InputConnection<MatrixFilter> Filter
{
get { return _filter; }
}
private OutputConnection<Matrix> _output = new OutputConnection<Matrix>("Output");
public OutputConnection<Matrix> Output
{
get { return _output; }
}
public override void Execute(Dictionary<InputConnectionBase, object> inputs, Dictionary<OutputConnectionBase, object> outputs)
{
Matrix image = (Matrix)inputs[Input];
MatrixFilter filter = (MatrixFilter)inputs[Filter];
outputs[Output] = filter.Apply(image);
}
}
protected override void InitTerminals()
{
InputTerminal term;
MatrixFilterApplyNode node = (MatrixFilterApplyNode)Node;
term = new InputTerminal(node.Input);
term.Position = Height / 2;
term.Side = BoxOrientation.Left;
term.Size *= 2;
Terminals.Add(term);
term = new InputTerminal(node.Filter);
term.Position = Width / 2;
term.Side = BoxOrientation.Up;
Terminals.Add(term);
OutputTerminal term2;
term2 = new OutputTerminal(node.Output);
term2.Position = Height / 2;
term2.Side = BoxOrientation.Right;
term2.Size *= 2;
Terminals.Add(term2);
}
}
}