Class Kinetic.Stage
Extends
Kinetic.Container, Kinetic.Node.
Defined in: kinetic.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Kinetic.Stage(cont, width, height)
Stage constructor.
|
Method Attributes | Method Name and Description |
---|---|
add(layer)
add layer to stage
|
|
clear()
clear all layers
|
|
draw()
draw children
|
|
get container DOM element
|
|
get content DOM element
|
|
getDOM()
get stage DOM node, which is a div element
with the class name "kineticjs-content"
|
|
get height
|
|
getIntersections(point)
get shapes that intersect a point
|
|
getMousePosition(evt)
get mouse position for desktop apps
|
|
getSize()
return stage size
|
|
getStage()
get stage
|
|
getTouchPosition(evt)
get touch position for mobile apps
|
|
getUserPosition(evt)
get user position (mouse position or touch position)
|
|
getWidth()
get width
|
|
load(JSON)
load stage with JSON string.
|
|
onFrame(func)
sets onFrameFunc for animation
|
|
remove(layer)
remove layer from stage
|
|
reset()
reset stage to default state
|
|
setSize(width, height)
set stage size
|
|
start()
start animation
|
|
stop()
stop animation
|
|
toDataURL(callback, mimeType, quality)
Creates a composite data URL and passes it to a callback.
|
|
toJSON()
serialize stage and children as a JSON object
|
- Methods borrowed from class Kinetic.Container:
- get, getChildren, isAncestorOf, removeChildren
- Methods borrowed from class Kinetic.Node:
- draggable, getAbsoluteAlpha, getAbsolutePosition, getAbsoluteTransform, getAbsoluteZIndex, getAlpha, getAttrs, getCenterOffset, getDetectionType, getDragBounds, getDragConstraint, getLayer, getLevel, getName, getParent, getPosition, getRotation, getRotationDeg, getScale, getTransform, getX, getY, getZIndex, hide, isDragging, isVisible, listen, move, moveDown, moveTo, moveToBottom, moveToTop, moveUp, off, on, rotate, rotateDeg, setAbsolutePosition, setAlpha, setAttrs, setCenterOffset, setDefaultAttrs, setDetectionType, setDragBounds, setDragConstraint, setPosition, setRotation, setRotationDeg, setScale, setX, setY, setZIndex, show, transitionTo
Class Detail
Kinetic.Stage(cont, width, height)
Stage constructor. A stage is used to contain multiple layers and handle
animations
- Parameters:
- {String|DomElement} cont
- Container id or DOM element
- {int} width
- {int} height
Method Detail
add(layer)
add layer to stage
- Parameters:
- {Layer} layer
clear()
clear all layers
draw()
draw children
getContainer()
get container DOM element
getContent()
get content DOM element
getDOM()
get stage DOM node, which is a div element
with the class name "kineticjs-content"
getHeight()
get height
getIntersections(point)
get shapes that intersect a point
- Parameters:
- {Object} point
getMousePosition(evt)
get mouse position for desktop apps
- Parameters:
- {Event} evt
getSize()
return stage size
getStage()
get stage
getTouchPosition(evt)
get touch position for mobile apps
- Parameters:
- {Event} evt
getUserPosition(evt)
get user position (mouse position or touch position)
- Parameters:
- {Event} evt
getWidth()
get width
load(JSON)
load stage with JSON string. De-serializtion does not generate custom
shape drawing functions, images, or event handlers (this would make the
serialized object huge). If your app uses custom shapes, images, and
event handlers (it probably does), then you need to select the appropriate
shapes after loading the stage and set these properties via on(), setDrawFunc(),
and setImage()
- Parameters:
- {String} JSON
- string
onFrame(func)
sets onFrameFunc for animation
- Parameters:
- {function} func
remove(layer)
remove layer from stage
- Parameters:
- {Layer} layer
reset()
reset stage to default state
setSize(width, height)
set stage size
- Parameters:
- {int} width
- {int} height
start()
start animation
stop()
stop animation
toDataURL(callback, mimeType, quality)
Creates a composite data URL and passes it to a callback. If MIME type is not
specified, then "image/png" will result. For "image/jpeg", specify a quality
level as quality (range 0.0 - 1.0)
- Parameters:
- {function} callback
- {String} mimeType
- (optional)
- {Number} quality
- (optional)
toJSON()
serialize stage and children as a JSON object