height / width 'cleanup'

This commit is contained in:
Howland Owl 2013-10-07 20:06:20 +03:00
parent b3a77f6a66
commit 956748c90b
2 changed files with 6 additions and 4 deletions

View file

@ -946,8 +946,8 @@ class @ImageTextMode
getByteAt: ( data, offset ) -> getByteAt: ( data, offset ) ->
return data.charCodeAt( offset ) & 0xFF return data.charCodeAt( offset ) & 0xFF
# could we replace this with math.max ? # could we replace this with math.max ? Not worth it,called once per view
# we COULD, but we'd do some crap like "Math.max.apply(null,blah) and that's not readable"
getWidth: -> getWidth: ->
max = 0 max = 0
for y in [ 0 .. @screen.length - 1 ] for y in [ 0 .. @screen.length - 1 ]
@ -955,7 +955,7 @@ class @ImageTextMode
return max return max
getHeight: -> getHeight: ->
return @screen.length @screen.length
parsePaletteData: ( data ) -> parsePaletteData: ( data ) ->
colors = [] colors = []
@ -994,6 +994,7 @@ class @ImageTextMode
if @screen[ cy ]? if @screen[ cy ]?
for cx in [ 0 ... @screen[ cy ].length ] for cx in [ 0 ... @screen[ cy ].length ]
pixel = @screen[ cy ][ cx ] pixel = @screen[ cy ][ cx ]
curfillstyle = null
if pixel? if pixel?
if pixel.attr? if pixel.attr?
fg = pixel.attr & 15 fg = pixel.attr & 15

View file

@ -304,7 +304,7 @@
}; };
ImageTextMode.prototype.renderCanvas = function(canvasElem) { ImageTextMode.prototype.renderCanvas = function(canvasElem) {
var bg, canvas, chr, ctx, cx, cy, fg, h, i, j, line, pixel, px, py, w, _i, _j, _k, _l, _len, _ref, _ref1, _ref2; var bg, canvas, chr, ctx, curfillstyle, cx, cy, fg, h, i, j, line, pixel, px, py, w, _i, _j, _k, _l, _len, _ref, _ref1, _ref2;
w = this.getWidth() * this.font.width; w = this.getWidth() * this.font.width;
h = this.getHeight() * this.font.height; h = this.getHeight() * this.font.height;
canvas = document.createElement('canvas'); canvas = document.createElement('canvas');
@ -315,6 +315,7 @@
if (this.screen[cy] != null) { if (this.screen[cy] != null) {
for (cx = _j = 0, _ref1 = this.screen[cy].length; 0 <= _ref1 ? _j < _ref1 : _j > _ref1; cx = 0 <= _ref1 ? ++_j : --_j) { for (cx = _j = 0, _ref1 = this.screen[cy].length; 0 <= _ref1 ? _j < _ref1 : _j > _ref1; cx = 0 <= _ref1 ? ++_j : --_j) {
pixel = this.screen[cy][cx]; pixel = this.screen[cy][cx];
curfillstyle = null;
if (pixel != null) { if (pixel != null) {
if (pixel.attr != null) { if (pixel.attr != null) {
fg = pixel.attr & 15; fg = pixel.attr & 15;