Port
Port
Represents a port. Ports are attached to a parent component. They take an input or output signal.
Constructor
protected Port
new Port(parent, dir)
Intializes a Port with the following parameters.
Parameters
parent: Component
– Parent component of the port.dir: Vector
– Direction of the of the port relative to the parent component.
Properties
No publicly accessible properties on Port
protected isOn: false | true
protected name: string
Name of the port.
protected dir: Vector
Direction of the ports relative to the parent component.
protected origin: Vector
A vector representing the position where the port attaches to the parent component relative to the parent component.
protected target: Vector
A vector representing the position of the port relative to the parent component relative to the parent component.
Methods
private updateDir
updateDir() => void
Updates the direction of the of the port relative to the parent component.
public setName
setName(name) => void
Sets the name of the port to a given string.
Parameters
-
name: string
– String to setthis.name
to.
public setOriginPos
setOriginPos(pos) => void
Changes the position of where the port attaches to the parent component relative to the parent component.
Parameters
-
pos: Vector
– Vector representing the position to change it to.
public setTargetPos
setTargetPos(pos) => void
Changes the position of where the port is on the canvas relative to the parent component.
Parameters
-
pos: Vector
– Vector representing the position to change it to.
public connect
Connects a wire to a port. Left as abstract since we expect different behaviour for analog and digital ports.
connect(w) => void
Connects a wire to a port. Left as abstract since we expect different behaviour for analog and digital ports.
Parameters
-
w: Wire
– Wire to connect.
public disconnect
Disconnects a wire from a port. Left as abstract since we expect different behaviour for analog and digital ports.
disconnect(w) => void
Disconnects a wire from a port. Left as abstract since we expect different behaviour for analog and digital ports.
Parameters
-
w: Wire
– Wire to disconnect.
public isWithinSelectBounds
isWithinSelectBounds(v) => false | true
When clicking on a port returns true if the position clicked is within the selection bound and false otherwise.
Parameters
-
v: Vector
– Vector representing the position clicked.
Returns
-
false | true
– True if the vector v is within the selection bound of the port and false otherwise.
public getIndex
getIndex() => number
Finds index of this port in the parent's array of ports.
Returns
-
number
– The index of this port in the parent component's array of ports.
public getParent
getParent() => Component
Returns the parent Component of this port.
Returns
-
Component
– The parent Component.
public getIsOn
getIsOn() => false | true
Returns whether or not the port is on.
Returns
-
false | true
– True ifthis.isOn
is true and false otherwise.
public getName
getName() => string
Return the name of this port.
Returns
-
string
– The string value ofthis.name
.
public getInitialDir
Returns the intial direction of a port represented as a Vector. Left as abstract since ports will have a different intial direction depending on their parent component and whether they serve as input or output ports.
getInitialDir() => Vector
Returns the intial direction of a port represented as a Vector. Left as abstract since ports will have a different intial direction depending on their parent component and whether they serve as input or output ports.
Returns
-
Vector
– Description needed
public getDir
getDir() => Vector
Returns the direction of the port relative to the parent component.
Returns
-
Vector
– A vector representing the direction of the port relative to the parent component.
public getOriginPos
getOriginPos() => Vector
Returns the position of where the port attaches to the parent component relative to the parent component.
Returns
-
Vector
– A copy ofthis.origin
.
public getTargetPos
getTargetPos() => Vector
Returns the position of where the port is on the canvas relative to the parent component.
Returns
-
Vector
– A copy ofthis.target
.
public getWorldDir
getWorldDir() => Vector
Returns the direction of the port.
Returns
-
Vector
– A vector representing the direction of the port.
public getWorldOriginPos
getWorldOriginPos() => Vector
Returns the position of where the port attaches to the parent component.
Returns
-
Vector
– A vector representing the position where the port attaches to the parent component.
public getWorldTargetPos
getWorldTargetPos() => Vector
Returns the position of where the port is on the canvas.
Returns
-
Vector
– A vector representing the position of the port.
public getPos
getPos() => Vector
Returns the position of where the port is on the canvas relative to the parent component.
Returns
-
Vector
– A vector representing the position of the port relative to the parent component.
public getWires
getWires() => Wire[]
Returns an array that contains the Wires connected to the port.
Returns
-
Wire[]
– The wires connected to this Port.
Static Methods
No static methods for Port