API Docs for: 6.0.1
Show:

MatrixFilter Class

Extends Filter
Module: scrawlFilters

MatrixFilter

Instantiation

  • scrawl.makeMatrixFilter()

Purpose

  • Adds a matrix filter effect to an Entity or cell

Access

  • scrawl.filter.FILTERNAME - for the MatrixFilter object

Constructor

MatrixFilter

(
  • [items]
)

Parameters:

  • [items] Object optional

    Key:value Object argument for setting attributes

Methods

add

(
  • data
)

Inherited from Filter but overwritten in source\scrawlFilters.js:1833

Add function - takes data, calculates its channels and combines it with data

Parameters:

  • data Object
    • canvas getImageData object

Returns:

amended image data object

clone

(
  • items
)
chainable

Clone a Scrawl.js object, optionally altering attribute values in the cloned object

Note that any callback or fn attribute functions will be referenced by the clone, not copied to the clone; these can be overwritten with new anonymous functions by including them in the items argument object

(This function is replaced by the path extension)

Parameters:

  • items Object

    Object containing attribute key:value pairs; will overwrite existing values in the cloned, but not the source, Object

Returns:

Cloned object

Example:

var box = scrawl.makeBlock({
    width: 50,
    height: 50
    });
var newBox = box.clone({
    height: 100
    });
newBox.get('width');        //returns 50
newBox.get('height');       //returns 100

cloneImageData

(
  • original
)

cloneImageData function

Parameters:

  • original Object
    • canvas getImageData object

Returns:

cloned image data object; false on error

get

(
  • item
)

Retrieve an attribute value. If the attribute value has not been set, then the default value for that attribute will be returned.

Parameters:

  • item String

    Attribute key

Returns:

Attribute value

Example:

var box = scrawl.makeBlock({
    width: 50,
    });
box.get('width');               //returns 50
box.get('height');              //returns 0
box.get('favouriteAnimal');     //returns undefined

getAlpha

() private

getAlpha function

Returns:

numerical strength value, between 0 and 1

numberConvert

(
  • val
  • dim
)
private

Stamp helper function - convert string percentage values to numerical values

Parameters:

  • val String

    coordinate String

  • dim Number

    dimension value

Returns:

Number - value

parse

()

Turn the object into a JSON String

Returns:

object of object's currently set attributes

set

(
  • items
)
chainable

Inherited from Base but overwritten in source\scrawlFilters.js:1758

Set attribute values.

Parameters:

  • items Object

    Object containing attribute key:value pairs

Returns:

This

setFilter

() private chainable

SetFilter builds the matrix from width, height and data attributes already supplied to the filter via the constructor or MatrixFilter.set()

Returns:

This

Properties

alpha

Number - or alternatively percentage String

Filter alpha

values between 0 (transparent) and 1 (current alpha values); or '0%' and '100%'

Default: 1

comment

String

Comment, for accessibility

Default: ''

composite

String

Filter composite operation

Only the final filter in an array of filters will determine the composite operation to be used on the cell

Default: 'source-over'

data

Array

Data is made up of an array of weightings - for instance a 3 x 3 matrix will contain 9 Number values; this data then gets converted into Matrix cells

The data array has no meaning without width and height dimensions - if no dimension values are supplied, the constructor will assume a odd-numbered square larger than the square root of the length of the data array (eg 3x3, 5x5), with home coordinates at the center of the square, and pad empty spaces at the end of the array with zero weights (which then get ignored)

Default: false

height

Number

Matrix maximum height

Default: 1

includeInvisiblePoints

Number

Default: false

name

String

Unique identifier for each object; default: computer-generated String based on Object's type

timestamp

String

Creation timestamp

Default: ''

title

String

Title, for accessibility

Default: ''

type

String final

Inherited from Base but overwritten in source\scrawlFilters.js:1699

Default: 'Filter'

width

Number

Matrix maximum width

Default: 1

x

Number

Home cell along the horizontal

Default: 0

y

Number

Home cell along the vertical

Default: 0