void Camera::setZoom(Scalar z) { Scalar centerx = getTotalX()+(getTotalWidth()-1)/2; Scalar centery = getTotalY()+(getTotalHeight()-1)/2; if(z <= 0) return; zoomIn = z; //zoomIn+=z; //if(zoomIn < 0) // zoomIn = 0.0001; setX((centerx-(getTotalWidth()-1)/2)*zoomIn); setY((centery-(getTotalHeight()-1)/2)*zoomIn); }
QRectF Configuration::getNormalizedScreenRect(const QPoint& tileIndex) const { assert(tileIndex.x() < totalScreenCountX_); assert(tileIndex.y() < totalScreenCountY_); const int xPos = tileIndex.x() * (screenWidth_ + mullionWidth_); const int yPos = tileIndex.y() * (screenHeight_ + mullionHeight_); // normalize to 0->1 const float totalWidth = (float)getTotalWidth(); const float totalHeight = (float)getTotalHeight(); const float screenLeft = (float)xPos / totalWidth; const float screenTop = (float)yPos / totalHeight; const float screenWidth = (float)screenWidth_ / totalWidth; const float screenHeight = (float)screenHeight_ / totalHeight; return QRectF(screenLeft, screenTop, screenWidth, screenHeight); }
void Camera::zoom(Scalar z) { if(z == 0) return; Scalar centerx = getTotalX()+(getTotalWidth()-1)/2; Scalar centery = getTotalY()+(getTotalHeight()-1)/2; zoomIn*=z; //zoomIn+=z; //if(zoomIn < 0) // zoomIn = 0.0001; //setX((centerx-(getTotalWidth()-1)/2)*zoomIn); //setY((centery-(getTotalHeight()-1)/2)*zoomIn); centerAt(centerx, centery); }
double Configuration::getAspectRatio() const { return double(getTotalWidth()) / getTotalHeight(); }
void Camera::centerAt(Scalar x, Scalar y) { setX((x-(getTotalWidth()-1)/2)*zoomIn); setY((y-(getTotalHeight()-1)/2)*zoomIn); }