ComponentUtils
IOObjectSet
Helper class to hold different groups of components.
The groups are: Input components (anything with 0 output ports and >0 input ports) Output components (anything with 0 input ports and >0 output ports) Wires (wires) Components (anything else).
Note that .getComponents() does NOT contain wires A helper method to get all the components including them is included as toList().
Constructor
public IOObjectSet
Properties
No publicly accessible properties on IOObjectSet
Methods
public getComponents
getComponents() => Component[]
Description needed
Returns
-
Component[]
– Description needed
Static Methods
No static methods for IOObjectSet
Functions
GetAllPorts
GetAllPorts(objs) => Port[]
Helper function to retrieve a list of all the Input/Output ports from the given list of objects/wires.
Parameters
-
objs: Component[]
– The list of objects to get ports from.
Returns
-
Port[]
– All the ports attached to the given list of objects.
CreateGroup
CreateGroup(objects) => IOObjectSet
Creates a Separated group from the given list of objects
and also retrieves all IMMEDIATELY connected wires that
connect to other objects in objects
.
Note that this method assumes all the components you want in the group are
provided in objects
INCLUDING WirePorts, this will not trace down the paths
to get all wires ports. Use GatherGroup(objects) to do this.
Parameters
-
objects: IOObject[]
– The list of objects to separate.
Returns
-
IOObjectSet
– A SeparatedComponentCollection of the objects.
GetPath
GetPath(w, full) => (Wire | Node)[]
Gets all the wires/WirePorts going out from this wire Note: this path is UN-ORDERED!
Parameters
full: false | true
– True if you want to return everything in the circuit otherwise returns only the wires/nodes connected to the wire.
Returns
GetComponentPath
GetComponentPath(c) => Component[]
Gets all the components connected to this component Note: this path is UN-ORDERED!
Parameters
-
c: Component
– The component to start from.
Returns
-
Component[]
– The array of components in the same circuit (including c).
GetAllPaths
GetAllPaths(obj, full) => (Wire | Node)[]
Gathers all wires + wireports in the path from the inputs/outputs of the given component.
Parameters
obj: Component
– The component.full: false | true
– True if you want to return everything in the circuit otherwise returns only the wires/nodes connected to the selected wire.
Returns
GatherGroup
GatherGroup(objects, full) => IOObjectSet
Creates a Separated group from the given list of objects. It also retrieves all "paths" going out from each object.
Parameters
objects: IOObject[]
– The list of objects.full: false | true
– True if you want to return everything in the circuit otherwise returns only the wires/nodes connected to the selected wire.
Returns
-
IOObjectSet
– A SeparatedComponentCollection of the objects.
CreateGraph
CreateGraph(groups) => Graph<number, number>
Helper function to create a directed graph from a given collection of components.
The Graph stores Nodes as indices from the groups.getAllComponents() array.
The edge weights are stored as pairs representing the input index (i1) and the output index (i2) respectively.
Parameters
-
groups: IOObjectSet
– The SeparatedComponentCollection of components.
Returns
-
Graph<number, number>
– A graph corresponding to the given circuit.
SerializeForCopy
SerializeForCopy(objects) => string
Description needed
Parameters
-
objects: IOObject[]
– Description needed
Returns
-
string
– Description needed
CopyGroup
CopyGroup(objects) => IOObjectSet
Copies a group of objects including connections that are present within the objects.
Parameters
-
objects: IOObject[]
– The object to copy.
Returns
-
IOObjectSet
– The copied set of objects.
CircuitBoundingBox
CircuitBoundingBox(all) => BoundingBox
Description needed
Parameters
-
all: CullableObject[]
– Description needed
Returns
-
BoundingBox
– Description needed
GetCameraFit
GetCameraFit(camera, objs, padding) => [Vector, number]<Vector, number>
Calculates camera position and zoom to fit objs to the camera's view with adjustable padding. If objs is empty, uses a default size.
Parameters
camera: Camera
– The camera to fit within.objs: CullableObject[]
– The objects to fit within the camera.padding: number
– The amount of padding for the fit.
Returns
-
[Vector, number]<Vector, number>
– Tuple of desired camera position and zoom.
PortContains
PortContains(port, mousePos) => false | true
Description needed
Parameters
port: Port
– Description neededmousePos: Vector
– Description needed
Returns
-
false | true
– Description needed
Snap
Snap(p) => Vector
Description needed
Parameters
-
p: Vector
– Description needed
Returns
-
Vector
– Description needed