API Docs for: 6.0.1
Show:

Position Class

Extends Base
Module: scrawlCore

Position

Instantiation

  • This object should never be instantiated by users

Purpose

  • supplies objects with basic positional and scaling attributes, and methods for manipulating them
  • start coordinates are relative to the top left corner of the object's Cell
  • handle coordinates are relative to the object's start coordinate

Certain Scrawl extensions will add functionality to this object, for instance scrawlAnimation adds delta attributes which can be used to automatically update the position of a Scrawl entity.

Constructor

Position

(
  • [items]
)

Parameters:

  • [items] Object optional

    Key:value Object argument for setting attributes

Methods

animationPositionClone

() private

Position.setDelta hook function - modified by animation extension

animationPositionGet

() private

Position.get hook function - modified by animation extension

animationPositionInit

() private

Position constructor hook function - modified by animation extension

animationPositionSet

() private

Position.set hook function - modified by animation extension

clone

(
  • items
)
chainable

Inherited from Base but overwritten in source\scrawlCore.js:3446

Augments Base.clone(), to allow users to set the start and handle attributes using startX, startY, handleX, handleY

Parameters:

  • items Object

    Object consisting of key:value attributes, used to update the clone's attributes with new values

Returns:

Cloned object

correctCoordinates

(
  • coords
  • [cell]
)

Stamp helper function - correct mouse coordinates if pad dimensions not equal to base cell dimensions

Parameters:

  • coords Object

    An object containing x and y attributes

  • [cell] String optional

    CELLNAME String

Returns:

Amended coordinate object

get

(
  • get
)

Inherited from Base but overwritten in source\scrawlCore.js:3157

Augments Base.get(), to allow users to get values for start, startX, startY, handle, handleX, handleY

For 'start' and 'handle', returns a copy of the Vector

Parameters:

  • get String

    Attribute key

Returns:

Attribute value

getReferenceDimensions

(
  • reference
)
W: width, h: height, c: centered private

updateCurrentHandle helper object

Parameters:

  • reference Object

    object - Stack, Pad, Element, Cell or Entity (Block, Wheel, Phrase, Picture, Path, Shape or Frame)

Returns:

W: width, h: height, c: centered:

Object with attributes

getX

()

Get the current start x coordinate

Returns:

Attribute value

getY

()

Get the current start y coordinate

Returns:

Attribute value

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

pathPositionInit

() private

Position constructor hook function - modified by path extension

pathPositionSetDelta

() private

Position.setDelta hook function - modified by path extension

set

(
  • items
)
chainable

Inherited from Base but overwritten in source\scrawlCore.js:3205

Augments Base.set(), to allow users to set the start and handle attributes using startX, startY, handleX, handleY

Parameters:

  • items Object

    Object consisting of key:value attributes

Returns:

This

setDelta

(
  • items
)
chainable

Adds the value of each attribute supplied in the argument to existing values; only Number attributes can be amended using this function. This function also accepts startX, startY, handleX, handleY

Parameters:

  • items Object

    Object consisting of key:value attributes

Returns:

This

setDeltaHandle

(
  • items
)
chainable

Adds the value of each attribute supplied in the argument to existing values. This function accepts handle, handleX, handleY

Parameters:

  • items Object

    Object consisting of key:value attributes

Returns:

This

setDeltaHeight

(
  • items
)
chainable

Adds the value of each attribute supplied in the argument to existing values. This function accepts height

Parameters:

  • items Object

    Object consisting of key:value attributes

Returns:

This

setDeltaRoll

(
  • items
)
chainable

Adds the value of each attribute supplied in the argument to existing values. This function accepts roll

Parameters:

  • items Object

    Object consisting of key:value attributes

Returns:

This

setDeltaScale

(
  • items
)
chainable

Adds the value of each attribute supplied in the argument to existing values. This function accepts scale

Parameters:

  • items Object

    Object consisting of key:value attributes

Returns:

This

setDeltaStart

(
  • items
)
chainable

Adds the value of each attribute supplied in the argument to existing values; This function accepts start, startX, startY

Parameters:

  • items Object

    Object consisting of key:value attributes

Returns:

This

setDeltaWidth

(
  • items
)
chainable

Adds the value of each attribute supplied in the argument to existing values. This function accepts width

Parameters:

  • items Object

    Object consisting of key:value attributes

Returns:

This

setHandle

(
  • items
)
chainable

Augments Base.setHandle(), to allow users to set the handle attributes using handle, handleX, handleY

Parameters:

  • items Object

    Object consisting of key:value attributes

Returns:

This

setStampUsingPivot

(
  • [cell]
)
private chainable

Stamp helper function - set this entity, cell or element start values to its pivot entity/point start value, or to the current mouse coordinates

Takes into account lock flag settings

Parameters:

  • [cell] String optional

    CELLNAME String

Returns:

This

setStart

(
  • items
)
chainable

Augments Base.setStart(), to allow users to set the start attributes using start, startX, startY

Parameters:

  • items Object

    Object consisting of key:value attributes

Returns:

This

updateCurrentHandle

() private chainable

Convert handle percentage values to numerical values, stored in currentHandle

Returns:

This

updateCurrentStart

(
  • reference
)
private chainable

Convert start percentage values to numerical values, stored in currentStart

Parameters:

  • reference Object

    object - Stack, Pad, Element, Cell or Entity (Block, Wheel, Phrase, Picture, Path, Shape or Frame)

Returns:

This

Properties

comment

String

Comment, for accessibility

Default: ''

deltaPathPlace

Number

(Added by the path extension) A change value which can be applied to the object's pathPlace attribute

Default: 0

flipReverse

Boolean

Reflection flag; set to true to flip entity, cell or element along the Y axis

Default: false

flipUpend

Boolean

Reflection flag; set to true to flip entity, cell or element along the X axis

Default: false

handle

Object

An Object (in fact, a Vector) containing offset instructions from the object's rotation/flip point, where drawing commences.

SubScrawl, and all Objects that prototype chain to Subscrawl, supports the following 'virtual' attributes for this attribute:

  • handleX - (Mixed) the horizontal offset, either as a Number (in pixels), or a percentage String of the object's width, or the String literal 'left', 'right' or 'center'
  • handleY - (Mixed) the vertical offset, either as a Number (in pixels), or a percentage String of the object's height, or the String literal 'top', 'bottom' or 'center'

Where values are Numbers, handle can be treated like any other Vector

height

Number

Entity, cell or element height (in pixels)

Default: 0

lockX

Boolean

Positioning flag; set to true to ignore path/pivot/mouse changes along the X axis

Default: false

lockY

Boolean

Positioning flag; set to true to ignore path/pivot/mouse changes along the Y axis

Default: false

maxDimensions

Object private

An object with the following attributes:

  • left - x coordinate of top-left corner of the enclosing box relative to the current cell's top-left corner
  • top - y coordinate of top-left corner of the enclosing box relative to the current cell's top-left corner
  • bottom - x coordinate of bottom-right corner of the enclosing box relative to the current cell's top-left corner
  • left - y coordinate of bottom-right corner of the enclosing box relative to the current cell's top-left corner

Default: null

mouseIndex

String

Index of mouse vector to use when pivot === 'mouse'

The Pad.mice object can hold details of multiple touch events - when an entity is assigned to a 'mouse', it needs to know which of those mouse trackers to use. Default: mouse (for the mouse cursor vector)

Default: 'mouse'

name

String

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

path

String

(Added by the path extension) The ENTITYNAME of a Shape entity whose path is used to calculate this object's start point

Default: ''

pathPlace

Number

(Added by the path extension) A value between 0 and 1 to represent the distance along a Path object's path, where 0 is the path start and 1 is the path end

Default: 0

pathSpeedConstant

Boolean

(Added by the path extension) A flag to determine whether the object will calculate its position along a Shape path in a regular (true), or simple (false), manner

Default: true

pivot

String

The ENTITYNAME or POINTNAME of a entity or Point object to be used for setting this object's start point

Default: null

roll

Number

Current rotation of the entity, cell or element (in degrees)

Default: 0

scale

Number

The object's scale value - larger values increase the object's size

Default: 1

start

Vector

The coordinate Vector representing the object's rotation/flip point

SubScrawl, and all Objects that prototype chain to Subscrawl, supports the following 'virtual' attributes for this attribute:

  • startX - (Number) the x coordinate of the object's rotation/flip point, in pixels, from the left side of the object's cell
  • startY - (Number) the y coordinate of the object's rotation/flip point, in pixels, from the top side of the object's cell

timestamp

String

Creation timestamp

Default: ''

title

String

Title, for accessibility

Default: ''

type

String final

Inherited from Base but overwritten in source\scrawlCore.js:3061

Default: 'Position'

width

Number

Entity, cell or element width (in pixels)

Default: 0