<canvas id="canvas"></canvas>
body{
  background:darkblue;
  margin:0;
  overflow:hidden;
  padding:0;
}
(function() {
  var canvas = document.getElementById('canvas');
  var windowWidth = window.innerWidth;
  var windowHeight = window.innerHeight;
  canvas.width = windowWidth;
  canvas.height = windowHeight;
  var ctx = canvas.getContext('2d');
  var building;
  var bWindow = {
    width: 20,
    height: 20,
    offset: 20
  }
  var Building = function(x, w, h, c) {
    this.width = w;
    this.height = h;
    this.x = x;
    this.y = windowHeight - h;
    this.color = c;
  }
  Building.prototype.drawBuilding = function() {
    ctx.fillStyle = this.color;
    ctx.fillRect(this.x, this.y, this.width, this.height);
    this.drawWindow();
  }
  Building.prototype.drawWindow = function() {
    var windowCol = Math.floor((this.width - bWindow.offset) / (bWindow.width + bWindow.offset));
    var windowRow = Math.floor((this.height - bWindow.offset) / (bWindow.height + bWindow.offset));
    for (var i = 1; i < windowCol; i++) {
      for (var j = 1; j < windowRow; j++) {
        ctx.fillStyle = "yellow";
        ctx.fillRect(this.x + i * (bWindow.width + bWindow.offset), this.y + j * (bWindow.height + bWindow.offset), bWindow.width, bWindow.height);
      }
    }
  }
  Building.prototype.onresize = function() {
    var bHeight = this.height;
    this.y = windowHeight - bHeight;
  }

  document.addEventListener('DOMContentLoaded', function() {
    init();
  }, false);

  function init() {
    canvas.width = windowWidth;
    canvas.height = windowHeight;
    building = new Building(50, 200, 300, "#333333");
    render();
  }

  function render() {
    ctx.clearRect(0, 0, windowWidth, windowHeight);
    building.drawBuilding();
    window.requestAnimationFrame(render);
  }

  function onResize() {
    windowWidth = window.innerWidth;
    windowHeight = window.innerHeight;
    canvas.width = windowWidth;
    canvas.height = windowHeight;
    building.onresize();
  }

  window.addEventListener('resize', onResize, false);
})();

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.