本文整理汇总了C++中common::Rect::intersects方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::intersects方法的具体用法?C++ Rect::intersects怎么用?C++ Rect::intersects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::Rect
的用法示例。
在下文中一共展示了Rect::intersects方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rectIntersectsItem
bool RenderQueue::rectIntersectsItem(const Common::Rect &rect) {
for (RenderQueueArray::iterator iter = _currQueue->begin(); iter != _currQueue->end(); iter++) {
const RenderQueueItem *item = &(*iter);
if (rect.intersects(item->rect))
return true;
}
return false;
}
示例2: render
void SurfaceList::render(Graphics::Surface *surface, const Common::Rect & clip) const {
for(uint i = 0; i < surfaces_n; ++i) {
const Surface &s = surfaces[i];
Common::Rect r(s.x, s.y, s.x + s.w, s.y + s.h);
if (r.bottom < clip.bottom || !clip.intersects(r))
continue;
r.clip(clip);
r.translate(-s.x, -s.y);
s.render(surface, r.left, r.top, false, r);
}
}
示例3: invalidateItemsByRect
void RenderQueue::invalidateItemsByRect(const Common::Rect &rect, const RenderQueueItem *item) {
for (RenderQueueArray::iterator iter = _currQueue->begin(); iter != _currQueue->end(); iter++) {
RenderQueueItem *subItem = &(*iter);
if (item != subItem &&
subItem->flags == kUnchanged &&
rect.intersects(subItem->rect)) {
subItem->flags = kRefresh;
invalidateItemsByRect(subItem->rect, subItem);
}
}
}
示例4: drawMouseCursorOnRectUpdate
void OSystem_IPHONE::drawMouseCursorOnRectUpdate(const Common::Rect& updatedRect, const Common::Rect& mouseRect) {
//draw mouse on top
if (_mouseVisible && (updatedRect.intersects(mouseRect))) {
int srcX = 0;
int srcY = 0;
int left = _mouseX - _mouseHotspotX;
if (left < 0) {
srcX -= left;
left = 0;
}
int top = _mouseY - _mouseHotspotY;
if (top < 0) {
srcY -= top;
top = 0;
}
int bottom = top + _mouseHeight;
if (bottom > _screenWidth)
bottom = _screenWidth;
int displayWidth = _mouseWidth;
if (_mouseWidth + left > _screenWidth)
displayWidth = _screenWidth - left;
int displayHeight = _mouseHeight;
if (_mouseHeight + top > _screenHeight)
displayHeight = _screenHeight - top;
byte *src = &_mouseBuf[srcY * _mouseWidth + srcX];
uint16 *dst = &_fullscreen[top * _screenWidth + left];
for (int y = displayHeight; y > srcY; y--) {
for (int x = displayWidth; x > srcX; x--) {
if (*src != _mouseKeyColour)
*dst = _palette[*src];
dst++;
src++;
}
dst += _screenWidth - displayWidth + srcX;
src += _mouseWidth - displayWidth + srcX;
}
}
}
示例5: drawSlideElement
void Slide::drawSlideElement(const Common::Rect &drawRect, const Common::Rect &oldBounds, DisplayElement *picture) {
if (picture && drawRect.intersects(oldBounds)) {
picture->moveElementTo(oldBounds.left, oldBounds.top);
picture->draw(drawRect.findIntersectingRect(oldBounds));
}
}
示例6: drawToSurface
void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect *dstRect, Common::Rect *clipRect) const {
TransparentSurface src(*getSurface(), false);
bool doDelete = false;
if (!clipRect) {
doDelete = true;
clipRect = new Common::Rect();
clipRect->setWidth(getSurface()->w * _transform._numTimesX);
clipRect->setHeight(getSurface()->h * _transform._numTimesY);
}
if (_owner) {
if (_transform._alphaDisable) {
src.setAlphaMode(TransparentSurface::ALPHA_OPAQUE);
} else {
src.setAlphaMode(_owner->getAlphaType());
}
}
if (_transform._numTimesX * _transform._numTimesY == 1) {
src.blit(*_targetSurface, dstRect->left, dstRect->top, _transform._flip, clipRect, _transform._rgbaMod, clipRect->width(), clipRect->height(), _transform._blendMode);
} else {
// clipRect is a subrect of the full numTimesX*numTimesY rect
Common::Rect subRect;
int y = 0;
int w = getSurface()->w;
int h = getSurface()->h;
assert(w == _dstRect.width() / _transform._numTimesX);
assert(h == _dstRect.height() / _transform._numTimesY);
int basex = dstRect->left - clipRect->left;
int basey = dstRect->top - clipRect->top;
for (int ry = 0; ry < _transform._numTimesY; ++ry) {
int x = 0;
for (int rx = 0; rx < _transform._numTimesX; ++rx) {
subRect.left = x;
subRect.top = y;
subRect.setWidth(w);
subRect.setHeight(h);
if (subRect.intersects(*clipRect)) {
subRect.clip(*clipRect);
subRect.translate(-x, -y);
src.blit(*_targetSurface, basex + x + subRect.left, basey + y + subRect.top, _transform._flip, &subRect, _transform._rgbaMod, subRect.width(), subRect.height(), _transform._blendMode);
}
x += w;
}
y += h;
}
}
if (doDelete) {
delete clipRect;
}
}
示例7: getNowSeenRect
Common::Rect ScreenItem::getNowSeenRect(const Plane &plane) const {
CelObj &celObj = getCelObj();
Common::Rect celObjRect(celObj._width, celObj._height);
Common::Rect nsRect;
if (_useInsetRect) {
if (_insetRect.intersects(celObjRect)) {
nsRect = _insetRect;
nsRect.clip(celObjRect);
} else {
nsRect = Common::Rect();
}
} else {
nsRect = celObjRect;
}
const uint16 scriptWidth = g_sci->_gfxFrameout->getCurrentBuffer().scriptWidth;
const uint16 scriptHeight = g_sci->_gfxFrameout->getCurrentBuffer().scriptHeight;
Ratio scaleX, scaleY;
if (_scale.signal & kScaleSignalDoScaling32) {
if (_scale.signal & kScaleSignalUseVanishingPoint) {
int num = _scale.max * (_position.y - plane._vanishingPoint.y) / (scriptWidth - plane._vanishingPoint.y);
scaleX = Ratio(num, 128);
scaleY = Ratio(num, 128);
} else {
scaleX = Ratio(_scale.x, 128);
scaleY = Ratio(_scale.y, 128);
}
}
if (scaleX.getNumerator() == 0 || scaleY.getNumerator() == 0) {
return Common::Rect();
}
int16 displaceX = celObj._displace.x;
int16 displaceY = celObj._displace.y;
if (_mirrorX != celObj._mirrorX && _celInfo.type != kCelTypePic) {
displaceX = celObj._width - displaceX - 1;
}
if (celObj._scaledWidth != kLowResX || celObj._scaledHeight != kLowResY) {
// high resolution coordinates
if (_useInsetRect) {
Ratio scriptToCelX(celObj._scaledWidth, scriptWidth);
Ratio scriptToCelY(celObj._scaledHeight, scriptHeight);
mulru(nsRect, scriptToCelX, scriptToCelY, 0);
if (nsRect.intersects(celObjRect)) {
nsRect.clip(celObjRect);
} else {
nsRect = Common::Rect();
}
}
if (!scaleX.isOne() || !scaleY.isOne()) {
// Different games use a different cel scaling mode, but the
// difference isn't consistent across SCI versions; instead,
// it seems to be related to an update that happened during
// SCI2.1mid where games started using hi-resolution game
// scripts
if (scriptWidth == kLowResX) {
mulinc(nsRect, scaleX, scaleY);
// TODO: This was in the original code, baked into the
// multiplication though it is not immediately clear
// why this is the only one that reduces the BR corner
nsRect.right -= 1;
nsRect.bottom -= 1;
} else {
nsRect.left = (nsRect.left * scaleX).toInt();
nsRect.top = (nsRect.top * scaleY).toInt();
if (scaleX.getNumerator() > scaleX.getDenominator()) {
nsRect.right = (nsRect.right * scaleX).toInt();
} else {
nsRect.right = ((nsRect.right - 1) * scaleX).toInt() + 1;
}
if (scaleY.getNumerator() > scaleY.getDenominator()) {
nsRect.bottom = (nsRect.bottom * scaleY).toInt();
} else {
nsRect.bottom = ((nsRect.bottom - 1) * scaleY).toInt() + 1;
}
}
}
Ratio celToScriptX(scriptWidth, celObj._scaledWidth);
Ratio celToScriptY(scriptHeight, celObj._scaledHeight);
displaceX = (displaceX * scaleX * celToScriptX).toInt();
displaceY = (displaceY * scaleY * celToScriptY).toInt();
mulinc(nsRect, celToScriptX, celToScriptY);
nsRect.translate(_position.x - displaceX, _position.y - displaceY);
} else {
// low resolution coordinates
//.........这里部分代码省略.........