DOM
Draws entities as DOM nodes, specifically <DIV>s.
.getDomId
public this .getId()
Get the Id of the DOM element used to represent the entity.
.DOM
Events
- Draw [Data: { style:String, type:"DOM", co}]
- when the entity is ready to be drawn to the stage
public this .DOM(HTMLElement elem)
- elem
- HTML element that will replace the dynamically created one
Pass a DOM element to use rather than one created. Will set ._element to this value. Removes the old element.
.draw
public this .draw([[Context ctx, ]Number x, Number y, Number w, Number h])
- ctx
- Canvas 2D context if drawing on another canvas is required
- x
- X offset for drawing a segment
- y
- Y offset for drawing a segment
- w
- Width of the segment to draw
- h
- Height of the segment to draw
Method to draw the entity on the canvas element. Can pass rect values for redrawing a segment of the entity.
.css
public * css(String property, String value)
- property
- CSS property to modify
- value
- Value to give the CSS property
public * css(Object map)
- map
- Object where the key is the CSS property and the value is CSS value
Apply CSS styles to the element.
Can pass an object where the key is the style property and the value is style value.
For setting one style, simply pass the style as the first argument and the value as the second.
The notation can be CSS or JS (e.g. text-align or textAlign).
To return a value, pass the property.
Example
this.css({'text-align', 'center', font: 'Arial'});
this.css("textAlign", "center");
this.css("text-align"); //returns center

@craftyjs
#crafty@freenode.net
google groups
louis@craftyjs.com
github