Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

Commit

Permalink
got rid of unneeded background-size style and added init to fix the f…
Browse files Browse the repository at this point in the history
…ull renderer
  • Loading branch information
gtanner committed Mar 27, 2012
1 parent 4e7b53b commit de021ed
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
4 changes: 3 additions & 1 deletion display.js
Expand Up @@ -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));
}
}
}
Expand Down
23 changes: 14 additions & 9 deletions 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
};
}
};
14 changes: 8 additions & 6 deletions 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 }
};
}
};
1 change: 0 additions & 1 deletion public/index.html
Expand Up @@ -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();
});
Expand Down

0 comments on commit de021ed

Please sign in to comment.