code: function(rect) {
          rect = rect || Crafty.viewport.rect();
          var q = Crafty.DebugCanvas.entities,
              i = 0,
              l = q.length,
              ctx = Crafty.DebugCanvas.context,
              current;
  
          var view = Crafty.viewport;
          ctx.setTransform(
              view._scale,
              0,
              0,
              view._scale,
              Math.round(view._x * view._scale),
              Math.round(view._y * view._scale)
          );
  
          ctx.clearRect(rect._x, rect._y, rect._w, rect._h);
  
          var lastLayer = null;
          for (; i < l; i++) {
              current = q[i];
  
              // If necessary, update the view transform to match the current entities layer
              // If the current entity has no layer, switch back to the viewport's transform
              if (lastLayer !== current._drawLayer) {
                  if (current._drawLayer) {
                      view = current._drawLayer._viewportRect();
                      ctx.setTransform(
                          view._scale,
                          0,
                          0,
                          view._scale,
                          Math.round(-view._x * view._scale),
                          Math.round(-view._y * view._scale)
                      );
                  } else {
                      view = Crafty.viewport;
                      ctx.setTransform(
                          view._scale,
                          0,
                          0,
                          view._scale,
                          Math.round(view._x * view._scale),
                          Math.round(view._y * view._scale)
                      );
                  }
                  lastLayer = current._drawLayer;
              }
              current.debugDraw(ctx);
          }
      }
docs: copied from drawAll()