new Helpers()
Methods
-
<static> align(element, parent, mode, regPoint, regPointMode)
-
Aligns an element (horizontally, vertically or both) based on it's parent bounds.
Parameters:
Name Type Description elementObject | Container | Element can be an Object, an DrawJS instance, a CreateJS Core Elements instance parentnull | Object | Container | Element can be an Object, an DrawJS instance, a CreateJS Core Elements instance
if null, it takes automatically the parent property of element parametermodeString can be a couple of word for horizontal or vertical align, in any order
accepts the following modes
- Horizontal Modes: left, center, right
- Vertical Modes: top, middle, bottom
regPointBoolean enabled alignment also on registration point regPointModenull | String can be a couple of word for horizontal or vertical align, in any order
accepts the following modes
- Horizontal Modes: left, center, right
- Vertical Modes: top, middle, bottom
if null it considers mode parameter as fallbackReturns:
- Type
- Object | Container | Element
-
<static> alignRegPoint(element, mode)
-
aligns the reg point or an element
Parameters:
Name Type Description elementObject | Container | Element can be an Object, an DrawJS instance, a CreateJS Core Elements instance modeString can be a couple of word for horizontal or vertical align, in any order
accepts the following modes
- Horizontal Modes: left, center, right
- Vertical Modes: top, middle, bottom
Returns:
- Type
- Object | Container | Element
-
<static> createCircle(options, bounds)
-
creates an DrawJS Circle Shape instance
Parameters:
Name Type Description optionsObject the options can contain Properties
Name Type Description fillString | Object color for filling graphics Properties
Name Type Description colorsArray colors to create a linear gradient fill ratiosArray color ratios to create a linear gradient fill pointsArray start & stop points to create a linear gradient fill strokeString | Object stroke options, if string it creates a stroke with size 1 Properties
Name Type Description sizeNumber the size colorString the color radiusNumber the radius of the circle boundsArguments the bounds parameter will be passed to setBounds method of DrawJS Container class
so it has to be an array with this sequence
- {Number} x
- {Number} y
- {Number} width
- {Number} height
Returns:
- Type
- Shape
-
<static> createContainer(bounds)
-
creates an DrawJS Container instance based on bounds parameters
Parameters:
Name Type Description boundsArguments the bounds parameter will be passed to setBounds method of DrawJS Container class
so it has to be an array with this sequence
- {Number} x
- {Number} y
- {Number} width
- {Number} height
Returns:
- Type
- Container
-
<static> createGraphics(options, bounds)
-
creates an DrawJS Graphics instance
Parameters:
Name Type Description optionsObject the options can contain Properties
Name Type Description fillString | Object color for filling graphics
Properties
Name Type Description colorsArray colors to create a linear gradient fill ratiosArray color ratios to create a linear gradient fill pointsArray start & stop points to create a linear gradient fill strokeString | Object stroke options, if string it creates a stroke with size 1 Properties
Name Type Description sizeNumber the size colorString the color boundsArguments the bounds parameter will be passed to setBounds method of DrawJS Container class
so it has to be an array with this sequence
- {Number} x
- {Number} y
- {Number} width
- {Number} height
Returns:
- Type
- Graphics
-
<static> createImage(image)
-
creates an DrawJS Bitmap instance
Parameters:
Name Type Description imageHTMLElement the preloaded DOM element representing the image Returns:
- Type
- Bitmap
-
<static> createRect(options, bounds)
-
creates an DrawJS Rect Shape instance
Parameters:
Name Type Description optionsObject the options can contain Properties
Name Type Description fillString | Object color for filling graphics
Properties
Name Type Description colorsArray colors to create a linear gradient fill ratiosArray color ratios to create a linear gradient fill pointsArray start & stop points to create a linear gradient fill strokeString | Object stroke options, if string it creates a stroke with size 1 Properties
Name Type Description sizeNumber the size colorString the color radiusBoolean | Number | Array
if false it draws a rect
if Number it draws a round rect
if Array it draws a round rect complex (array has to respect the arguments sequence of drawRoundRectComplex method of DrawJS Graphics classboundsArguments the bounds parameter will be passed to setBounds method of DrawJS Container class
so it has to be an array with this sequence
- {Number} x
- {Number} y
- {Number} width
- {Number} height
Returns:
- Type
- Shape
-
<static> createSprite(spritesheet)
-
creates an DrawJS Sprite instance
Parameters:
Name Type Description spritesheetHTMLElement the preloaded DOM element representing the sprite Returns:
- Type
- Sprite
-
<static> createText(text, font, color)
-
creates an DrawJS Text instance
Parameters:
Name Type Description textString the text to be rendered fontString font options as expected by the DrawJS Text class colorString the color of the text Returns:
- Type
- Text
-
<static> scale(element, scale)
-
sets the scale factor of an DrawJS element
Parameters:
Name Type Description elementObject | Container | Element can be an Object, an DrawJS instance, a CreateJS Core Elements instance scaleNumber | Object the scale factor to be used for both scaleX and scaleY Returns:
- Type
- Object | Container | Element
-
<static> setBoxSize(element, width, height, css)
-
sets the box size of an DrawJS element
Parameters:
Name Type Description elementObject | Container | Element can be an Object, an DrawJS instance, a CreateJS Core Elements instance widthNumber the width heightNumber the height cssBoolean specity if you want to override also the css box size properties Returns:
- Type
- Object | Container | Element