Skip to main content

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

new IOObjectSet(set)

*Description needed*

Parameters

  •  set: IOObject[]Description needed

Properties

No publicly accessible properties on IOObjectSet

protected components: Set<Component>

Description needed

protected wires: Set<Wire>

Description needed


Methods

public getComponents

getComponents() => Component[]

Description needed

Returns

public getWires

getWires() => Wire[]

Description needed

Returns

  •   Wire[]Description needed

public toList

toList() => IOObject[]

Description needed

Returns


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

  •  w: Wire | Node – The wire to start from.

  •  full: false | true – True if you want to return everything in the circuit otherwise returns only the wires/nodes connected to the wire.

Returns

  •   (Wire | Node)[] – The array of wires/WirePorts in this path (including w).

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

  •   (Wire | Node)[] – An array of connections + WirePorts.

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

SerializeForCopy

SerializeForCopy(objects) => string

Description needed

Parameters

  •  objects: IOObject[]Description needed

Returns

  •   stringDescription 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

CircuitBoundingBox

CircuitBoundingBox(all) => BoundingBox

Description needed

Parameters

Returns

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: PortDescription needed

  •  mousePos: VectorDescription needed

Returns

  •   false | trueDescription needed

Snap

Snap(p) => Vector

Description needed

Parameters

  •  p: VectorDescription needed

Returns

  •   VectorDescription needed