var GetTilesWithin = require('./GetTilesWithin'); var Color = require('../../display/color'); var RenderDebug = function (graphics, styleConfig, layer){ if (styleConfig === undefined) { styleConfig = { } ; } var tileColor = styleConfig.tileColor !== undefined? styleConfig.tileColor: new Color(105, 210, 231, 150); var collidingTileColor = styleConfig.collidingTileColor !== undefined? styleConfig.collidingTileColor: new Color(243, 134, 48, 200); var faceColor = styleConfig.faceColor !== undefined? styleConfig.faceColor: new Color(40, 39, 37, 150); var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null , layer); for (var i = 0; i < _AN_Read_length('length', tiles); i++ ){ var tile = tiles[i]; var tw = tile.width; var th = tile.height; var x = tile.pixelX; var y = tile.pixelY; var color = tile.collides? collidingTileColor: tileColor; if (color !== null ) { graphics.fillStyle(color.color, color.alpha / 255); graphics.fillRect(x, y, tw, th); } x += 1; y += 1; tw -= 2; th -= 2; if (faceColor !== null ) { graphics.lineStyle(1, faceColor.color, faceColor.alpha / 255); if (tile.faceTop) { graphics.lineBetween(x, y, x + tw, y); } if (tile.faceRight) { graphics.lineBetween(x + tw, y, x + tw, y + th); } if (tile.faceBottom) { graphics.lineBetween(x, y + th, x + tw, y + th); } if (tile.faceLeft) { graphics.lineBetween(x, y, x, y + th); } } } } ; module.exports = RenderDebug;