Class Index | File Index

Classes


Class ROT.Display

Visual map display
Defined in: <rot.js>.

Class Summary
Constructor Attributes Constructor Name and Description
 
ROT.Display(options)
Method Summary
Method Attributes Method Name and Description
 
Clear the whole display (cover it with background color)
 
computeFontSize(availWidth, availHeight)
Compute the maximum font size to fit into a set of given constraints
 
computeSize(availWidth, availHeight)
Compute the maximum width/height to fit into a set of given constraints
 
DEBUG(x, y, what)
Debug helper, ideal as a map generator callback.
 
draw(x, y, ch, fg, bg)
 
drawText(x, y, text, maxWidth)
Draws a text at given position.
 
Convert a DOM event (mouse or touch) to map coordinates.
 
Returns the DOM node of this display
 
Returns currently set options
 
setOptions(options)
Class Detail
ROT.Display(options)
Parameters:
{object} options Optional
{int} options.width Optional, Default: ROT.DEFAULT_WIDTH
{int} options.height Optional, Default: ROT.DEFAULT_HEIGHT
{int} options.fontSize Optional, Default: 15
{string} options.fontFamily Optional, Default: "monospace"
{string} options.fontStyle Optional, Default: ""
bold/italic/none/both
{string} options.fg Optional, Default: "#ccc"
{string} options.bg Optional, Default: "#000"
{float} options.spacing Optional, Default: 1
{float} options.border Optional, Default: 0
{string} options.layout Optional, Default: "rect"
{bool} options.forceSquareRatio Optional, Default: false
{int} options.tileWidth Optional, Default: 32
{int} options.tileHeight Optional, Default: 32
{object} options.tileMap Optional, Default: {}
{image} options.tileSet Optional, Default: null
{image} options.tileColorize Optional, Default: false
Method Detail
clear()
Clear the whole display (cover it with background color)

{int} computeFontSize(availWidth, availHeight)
Compute the maximum font size to fit into a set of given constraints
Parameters:
{int} availWidth
Maximum allowed pixel width
{int} availHeight
Maximum allowed pixel height
Returns:
{int} fontSize

{int[2]} computeSize(availWidth, availHeight)
Compute the maximum width/height to fit into a set of given constraints
Parameters:
{int} availWidth
Maximum allowed pixel width
{int} availHeight
Maximum allowed pixel height
Returns:
{int[2]} cellWidth,cellHeight

DEBUG(x, y, what)
Debug helper, ideal as a map generator callback. Always bound to this.
Parameters:
{int} x
{int} y
{int} what

draw(x, y, ch, fg, bg)
Parameters:
{int} x
{int} y
{string || string[]} ch
One or more chars (will be overlapping themselves)
{string} fg Optional
foreground color
{string} bg Optional
background color

{int} drawText(x, y, text, maxWidth)
Draws a text at given position. Optionally wraps at a maximum length. Currently does not work with hex layout.
Parameters:
{int} x
{int} y
{string} text
May contain color/background format specifiers, %c{name}/%b{name}, both optional. %c{}/%b{} resets to default.
{int} maxWidth Optional
wrap at what width?
Returns:
{int} lines drawn

{int[2]} eventToPosition(e)
Convert a DOM event (mouse or touch) to map coordinates. Uses first touch for multi-touch.
Parameters:
{Event} e
event
Returns:
{int[2]} -1 for values outside of the canvas

{node} getContainer()
Returns the DOM node of this display
Returns:
{node} DOM node

{object} getOptions()
Returns currently set options
Returns:
{object} Current options object

setOptions(options)
Parameters:
options
See:
ROT.Display

Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jun 13 2016 11:14:41 GMT+0200 (CEST)