From de021edd107b90b0555f094dbfe25a9100f6b193 Mon Sep 17 00:00:00 2001 From: Gord Tanner Date: Tue, 27 Mar 2012 17:41:30 -0400 Subject: [PATCH] got rid of unneeded background-size style and added init to fix the full renderer --- display.js | 4 +++- display/full.js | 23 ++++++++++++++--------- display/random.js | 14 ++++++++------ public/index.html | 1 - 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/display.js b/display.js index 2f80cbe..4251cfa 100644 --- a/display.js +++ b/display.js @@ -9,9 +9,11 @@ module.exports = { var plugin = require("./display/" + plugin), row, col; + plugin.init(); + for (row = 0; row < grid.length; row++) { for (col = 0; col < grid[row].length; col++) { - grid[row][col].emit('img', plugin(row, col)); + grid[row][col].emit('img', plugin.render(row, col)); } } } diff --git a/display/full.js b/display/full.js index 87a2ba9..767e173 100644 --- a/display/full.js +++ b/display/full.js @@ -1,11 +1,16 @@ -var images = require('../images'); +var images = require('../images'), + img = ""; -module.exports = function (row, col) { - return { - url: images.random("full"), - size: { x: 3072, y: 1800 }, - pos: {x: 1024 * col * -1, y: 600 * row * -1}, - row: row, - col: col - }; +module.exports = { + init: function () { + img = images.random("full"); + }, + render: function (row, col) { + return { + url: img, + pos: {x: 1024 * col * -1, y: 600 * row * -1}, + row: row, + col: col + }; + } }; diff --git a/display/random.js b/display/random.js index f7dc6c6..2d0338d 100644 --- a/display/random.js +++ b/display/random.js @@ -1,9 +1,11 @@ var images = require('../images'); -module.exports = function (x, y) { - return { - url: images.random("tile"), - size: { x: 1024, y: 600 }, - pos: { x: 0, y: 0 } - }; +module.exports = { + init: function () { }, + render: function (row, col) { + return { + url: images.random("tile"), + pos: { x: 0, y: 0 } + }; + } }; diff --git a/public/index.html b/public/index.html index 78ea0d8..3b05448 100644 --- a/public/index.html +++ b/public/index.html @@ -18,7 +18,6 @@ socket.on('img', function (data) { console.log(data); var style = "background-image: url('" + data.url + "');"; - style += "background-size: " + data.size.x + "px " + data.size.y + "px;"; style += "background-position: " + data.pos.x + "px " + data.pos.y + "px;"; $("#img").attr("style", style).show(); });