API Docs for: 6.0.1
Show:

TintFilter Class

Extends Filter
Module: scrawlFilters

TintFilter

Instantiation

  • scrawl.makeTintFilter()

Purpose

  • Adds a tint filter effect to an Entity or cell

Access

  • scrawl.filter.FILTERNAME - for the TintFilter object

Constructor

TintFilter

(
  • [items]
)

Parameters:

  • [items] Object optional

    Key:value Object argument for setting attributes

Methods

add

(
  • data
)

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

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

Set attribute values. Multiple attributes can be set in the one call by including the attribute key:value pair in the argument object.

An attribute value will only be set if the object already has a default value for that attribute. This restricts the ability of coders to add attributes to Scrawl objects.

Parameters:

  • items Object

    Object containing attribute key:value pairs

Returns:

This

Example:

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

Properties

alpha

Number - or alternatively percentage String

Filter alpha

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

Default: 1

blueInBlue

Number - or alternatively percentage String

Default: 1

blueInGreen

Number - or alternatively percentage String

Default: 0

blueInRed

Number - or alternatively percentage String

Default: 0

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'

greenInBlue

Number - or alternatively percentage String

Default: 0

greenInGreen

Number - or alternatively percentage String

Default: 1

greenInRed

Number - or alternatively percentage String

Default: 0

name

String

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

redInBlue

Number - or alternatively percentage String

Default: 0

redInGreen

Number - or alternatively percentage String

Default: 0

redInRed

Number - or alternatively percentage String

Default: 1

timestamp

String

Creation timestamp

Default: ''

title

String

Title, for accessibility

Default: ''

type

String final

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

Default: 'Filter'