Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. void TileLayer::resize(const QSize &size, const QPoint &offset)
  2. {
  3.     if (this->size() == size && offset.isNull())
  4.         return;
  5.  
  6.     QScopedPointer<TileLayer> newLayer(new TileLayer(QString(), 0, 0, size.width(), size.height()));
  7.  
  8.     // Copy over the preserved part
  9.     QRect area = mBounds.translated(-position() + offset).intersected(newLayer->rect());
  10.     for (int y = area.top(); y <= area.bottom(); ++y)
  11.         for (int x = area.left(); x <= area.right(); ++x)
  12.             newLayer->setCell(x, y, cellAt(x - offset.x(), y - offset.y()));
  13.  
  14.     mChunks = newLayer->mChunks;
  15.     mBounds = newLayer->mBounds;
  16.     setSize(size);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement