new Layer()
Layer
Layerとは一番基本のレイヤの機能が付いてます、おおむねレンダリング用です。
ImageLayerとMessageLayerはこれをprototypeにしてます。
Layerのレンダリング構造は以下通りです:
何かを描画する:
- まずはDrawableオブジェクトを準備して、Layer.childrenに追加します。
- Layer.draw( drawable )をしてます、Layerはすぐ描画するではなく「このDrawableをあとで描画する」と記録します
- Layer.childrenから消したい物を削除する。
- Layer.redrawRect( rect )をする。Layerはすぐクリアするのではなく、「このエリアをあとでクリアします」と記録します。
- Implements:
Extends
Members
(readonly) canvas
Properties:
Name | Type | Description |
---|---|---|
canvas |
Canvas |
(readonly) ctx
Properties:
Name | Type | Description |
---|---|---|
ctx |
CanvasRenderingContext2D |
(constant) initializer :string
The name of constructor the class, will be used to restore the object.
The constructor has to be accessable via
window[initializer]
Type:
- string
- Overrides:
- Implements:
needRedraw
Properties:
Type | Description |
---|---|
boolean |
- Inherited From:
partialDraw
Properties:
Type | Description |
---|---|
boolean |
- Inherited From:
rect
Properties:
Type | Description |
---|---|
Rect |
- Overrides:
Methods
canDrawPartial() → {boolean}
Can it draw only a certain part?
If yes, drawContext will be called with rect, and drawable should draw only in that rect.
Drawing less = better performance.
- Inherited From:
Returns:
- Type
- boolean
children() → {Array.<Drawable>}
Drawable to be draw in the layer
Returns:
- Type
- Array.<Drawable>
draw(drawable)
Parameters:
Name | Type | Description |
---|---|---|
drawable |
Drawable | The drawable to redraw, it has to be one of the children. |
drawOnContext(context, rect)
Draw on this context.
If canDrawPartial is true, this can be called with rect.
When it is called with rect, drawable should only draw in the specificed area.
Parameters:
Name | Type | Description |
---|---|---|
context |
CanvasRenderingContext2D | |
rect |
Rect | In the context's coordinate. |
- Overrides:
flush() → {boolean}
Returns:
trueならredrawしています、falseならしていない
- Type
- boolean
frame() → {Rect}
Return the frame, which is the actually area this drawable draws on (including things like shadow).
Subclass should override if needed.
- Inherited From:
Returns:
- Type
- Rect
getCorrespondingLayer() → {Layer}
Get the fore / back corresponding layer
Returns:
- Type
- Layer
mousedown() → {boolean}
Return true if this layer handled the event,
otherwise the event will passed to the next layer.
Returns:
- Type
- boolean
mousemove() → {boolean}
Return true if this layer handled the event,
otherwise the event will passed to the next layer.
Returns:
- Type
- boolean
mouseup() → {boolean}
Return true if this layer handled the event,
otherwise the event will passed to the next layer.
Returns:
- Type
- boolean
objectToBeSerialized(key) → {object|Serializable}
Return an object to be serialized for a specific key.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The key of property to be serialized |
- Overrides:
- Implements:
Returns:
- An object or serializable to be saved for the specific key, return undefined = not to be saved.
- Type
- object | Serializable
redrawRect(rect)
Parameters:
Name | Type | Description |
---|---|---|
rect |
Rect | Redraw a rect within the layer |
setRect(rect)
Parameters:
Name | Type | Description |
---|---|---|
rect |
Rect |