Grape.View Class
A view using canvas to render. It emits the render event to the layer it is added to, with the canvas context as parameter in each render frame. Because the layer emits any event to its sub-layers, instances in sub-layers are alos visible.
Constructor
Grape.View
()
Item Index
Methods
createDom
()
HTMLElement
This abstract method should create the HTMLElement which serves
Returns:
Canvas
getHeight
()
Number
Returns the calculated height value.
Returns:
calculated height
getLeft
()
Number
Returns the calculated width left.
Returns:
calculated left
getOriginX
()
Number
Returns the calculated originX value.
Returns:
calculated originX
getOriginY
()
Number
Returns the calculated originY value.
Returns:
calculated originY
getTop
()
Number
Returns the calculated top value.
Returns:
calculated top
getWidth
()
Number
Returns the calculated width value.
Returns:
calculated width
updateSize
()
Sets the width and height property for canvas (style.width and style.height are wrong).
Properties
alpha
Number
The global alpha value of the view.
Default: 1
ctx
CanvasRenderingContext2D
The context of the view
height
String | Number | Function
The height of the view. The maximum value (100%) is the container height.
Default: '100%'
left
String | Number | Function
The left axis of the view in the container. The maximum value (100%) is the container width.
Default: 0
mouse
Number
Information about the mouse relative to the view.
originX
String | Number | Function
The horizontal origin of the view. Tells where should a point with x = view.x appear on the screen. The maximum value (100%) is the width of the view.
Default: 0
originY
String | Number | Function
The vertical origin of the view. Tells where should a point with y = view.y appear on the screen. The maximum value (100%) is the height of the view.
Default: 0
top
String | Number | Function
The top axis of the view in the container. The maximum value (100%) is the container height.
Default: 0
width
String | Number | Function
The width of the view. The maximum value (100%) is the container width.
Default: '100%'
x
Number
The x coordinate of the showed area.
Default: 0
y
Number
The y coordinate of the showed area.
Default: 0
Events
domCreated
This event is fired after the createDom() method is called and the DOM element is appended to the container. The parameter is the element.
mouseMoveView (layer)
Emitted to the containing layer when the mouse position changed according to the position in the previous frame. The parameter is the view.
render (layer)
The render event is emitted to the layer with the canvas context parameter.