Skip to content
kucherenkovova edited this page Apr 22, 2016 · 11 revisions

Seriously

A Seriously object stores and manages a network of nodes to be used in a composition and is used to create new nodes.

Constructor

Seriously(options)

Parameters:

  • options (object): An object containing additional option fields. (optional)
    • defaults: An object containing default values for each type of node. Each node created in this composition will use the default input parameter values given in this object.

Example:

Create a composition. Most of the time, options will be unnecessary.

    var seriously = new Seriously();

Setting default input values for given node types. Any blend nodes created will have sizeMode set to 'intersection' by default (the original default value is "bottom").

    var seriously = new Seriously({
        blend: {
            sizeMode: 'intersection'
        }
    });

Methods

effect(type, options)

Create a new effect node

Parameters:

  • type (string): identifier of type of effect to create. Throws error if effect is not found.
  • options (object): Additional fields to be passed to effect plugin. (optional)

Returns:

A new Effect object

source(type, source, options)

Wraps an input source in a Source node object that can be connected to the network.

Parameters:

  • type (string): identifier of type of source to create. Throws error if effect is not found. (optional)
  • source: Identifies the object to be used as input source. Any of the following types:
    • DOMElement: <canvas>, <img> or <video> DOM element
    • string: CSS query string pointing to a <canvas>, <img> or <video> DOM element.
    • ImageData: An object returned by getImageData from a 2D canvas context
    • Array: An array of pixel components arranged as red, green, blue, alpha. Array length must be height x width x 4. width and height must be specified in options parameter, otherwise throws an error.
  • options: An object containing additional option fields. (optional)
    • width: width of source image in pixels.
    • height: height of source image in pixels.
    • flip: boolean value specifying whether image should be flipped vertically. default is false Throws an error if source parameter is missing or of unknown type.
    • Additional options may apply for other source types.

Each parameter may be optional, depending on the form of the call and the type of source. One or both of type and source must be provided. If the source type can be inferred by the source object provided, specifying the type is unnecessary. This is usually the case, as when the source is an image, canvas or video element. Some source types, like "camera" do not accept a source object, so the type string is required. It's also required for source plugins like "depth", which accepts a source object but is not the default plugin for image elements.

Returns:

A new Source object

If source is called twice with the same object, the second call will return a reference to the first object created.

Example:

    var video, seriously, source1, source2;
    
    seriously = Seriously();
    video = document.getElementById('video');

    // creating a source node without the need to specify type
    source1 = seriously.source(video);
    source2 = seriously.source('#video');
    
    source1 === source2; // true!

Accessing the camera directly as a source node is easy. The type string "camera" is necessary, but a source object is not. The camera source plugin accepts an options object with video constraints.

    var seriously, source;
    seriously = Seriously(),
    source = seriously.source('camera', {
        video: {
            mandatory: {
                minWidth: 1280,
                minHeight: 720,
                maxWidth: 1280,
                maxHeight: 720
            }
        }
    });

transform (type, options)

Transform nodes are similar to effect nodes. They are much more efficient, but they are limited to affecting the position, scale and orientation and can only accept a single input.

Parameters:

  • type (string): identifier of type of transform node to create. Throws error if plugin is not found.
  • options (object): Additional fields to be passed to transform plugin. (optional)

Returns:

A new Transform object

Example:

    var seriously, shrink, flip;

    seriously = Seriously();

    flip = seriously.transform('flip');
    flip.direction = 'vertical';
    flip.source = '#video'; // implicitly create a hidden source node

    shrink = seriously.transform('2d');
    shrink.scale(0.5);
    shrink.source = flip;

target(type, target, options)

Wraps an target object in a Target node object that can be connected to the network. The target is usually a <canvas> element where the resulting image will be rendered.

Parameters:

  • type (string): identifier of type of source to create. Throws error if effect is not found. (optional)
  • target: Identifies the object to be used as input source. Any of the following types:
    • DOMElement: <canvas> element
    • string: CSS query string pointing to a <canvas> DOM element.
    • other target object types may be available if a target plugin is installed (e.g. a Three.js render target)
  • options (object): Additional fields to be passed to target plugin. (optional)

Each parameter may be optional, depending on the form of the call and the type of source. One or both of type and target must be provided. If the source type can be inferred by the source object provided, specifying the type is unnecessary. As of now all the included target types require a target object and do not require the type string.

Returns:

A new Target object

If target is called twice with the same object, the second call will return a reference to the first object created.

Example:

    var canvas, seriously, target1, target2;
    
    seriously = Seriously();
    canvas = document.getElementById('canvas');

    // creating a target node without the need to specify type
    target1 = seriously.source(canvas);
    target2 = seriously.source('#canvas');
    
    target1 === target2; // true!

aliases

removeAlias

defaults

go(preCb, postCb)

Tells Seriously to keep rendering everything in our node network.

Parameters:

  • preCb(now) (function): function that is called before the browser renders your node. It's called right in the beginnig of renderDaemon function. (optional)
    • now (Number): current time in mills
  • postCb(now)(function): function that is called after the browser renders your node. It's called right in the end of renderDaemon function. (optional)
    • now (Number): current time in mills

stop

render

destroy

isDestroyed

incompatible

isNode

isSource

isEffect

isTransform

isTarget

Properties

id

Utilities

The following functions and objects are properties of the global Seriously object.

incompatible

plugin

removePlugin

source

removeSource

transform

removeTransform

target

removeTarget

inputValidators

effects

logger

util