本文整理汇总了C++中common::Rect::setWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::setWidth方法的具体用法?C++ Rect::setWidth怎么用?C++ Rect::setWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::Rect
的用法示例。
在下文中一共展示了Rect::setWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawSprite
bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, TransformStruct transform) {
BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer);
if (!_loaded) {
finishLoad();
}
if (renderer->_forceAlphaColor != 0) {
transform._rgbaMod = renderer->_forceAlphaColor;
}
// TODO: This _might_ miss the intended behaviour by 1 in each direction
// But I think it fits the model used in Wintermute.
Common::Rect srcRect;
srcRect.left = rect->left;
srcRect.top = rect->top;
srcRect.setWidth(rect->right - rect->left);
srcRect.setHeight(rect->bottom - rect->top);
Common::Rect position;
if (newRect) {
position.top = y;
position.left = x;
position.setWidth(newRect->width());
position.setHeight(newRect->height());
} else {
Rect32 r;
r.top = 0;
r.left = 0;
r.setWidth(rect->width());
r.setHeight(rect->height());
r = TransformTools::newRect(r, transform, 0);
position.top = r.top + y + transform._offset.y;
position.left = r.left + x + transform._offset.x;
position.setWidth(r.width() * transform._numTimesX);
position.setHeight(r.height() * transform._numTimesY);
}
renderer->modTargetRect(&position);
// TODO: This actually requires us to have the SAME source-offsets every time,
// But no checking is in place for that yet.
// Optimize by not doing alpha-blits if we lack alpha
if (_alphaType == TransparentSurface::ALPHA_OPAQUE && !transform._alphaDisable) {
transform._alphaDisable = true;
}
renderer->drawSurface(this, _surface, &srcRect, &position, transform);
return STATUS_OK;
}
示例2: drawToSurface
// Replacement for SDL2's SDL_RenderCopy
void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface) const {
TransparentSurface src(*getSurface(), false);
Common::Rect clipRect;
clipRect.setWidth(getSurface()->w);
clipRect.setHeight(getSurface()->h);
if (_owner) {
if (_transform._alphaDisable) {
src.setAlphaMode(TransparentSurface::ALPHA_OPAQUE);
} else {
src.setAlphaMode(_owner->getAlphaType());
}
}
int y = _dstRect.top;
int w = _dstRect.width() / _transform._numTimesX;
int h = _dstRect.height() / _transform._numTimesY;
for (int ry = 0; ry < _transform._numTimesY; ++ry) {
int x = _dstRect.left;
for (int rx = 0; rx < _transform._numTimesX; ++rx) {
src.blit(*_targetSurface, x, y, _transform._flip, &clipRect, _transform._rgbaMod, clipRect.width(), clipRect.height());
x += w;
}
y += h;
}
}
示例3: readRect
Common::Rect GameModule::readRect(Common::SeekableReadStream &s) {
Common::Rect r;
r.left = s.readUint16LE();
r.top = s.readUint16LE();
r.setWidth(s.readUint16LE());
r.setHeight(s.readUint16LE());
return r;
}
示例4: makeRect
Common::Rect makeRect(int16 x, int16 y, int16 width, int16 height) {
Common::Rect rect;
rect.left = x;
rect.top = y;
rect.setWidth(width);
rect.setHeight(height);
return rect;
}
示例5: getFrameRect
void Animation::getFrameRect(Common::Rect &r) const {
r.setWidth(0); r.setHeight(0);
if (!gfxobj) {
return;
}
gfxobj->getRect(_frame, r);
r.translate(_left, _top);
}
示例6: clip
bool ASurface::clip(Common::Rect &r) {
int skip;
_leftSkip = _rightSkip = 0;
_topSkip = _bottomSkip = 0;
if (r.left > _clipWidth || r.left < 0) {
if (r.left >= 0)
return true;
skip = -r.left;
r.setWidth(r.width() - skip);
_leftSkip = skip;
r.moveTo(0, r.top);
}
int right = r.right - 1;
if (right < 0)
return true;
else if (right > _clipWidth) {
skip = right - _clipWidth;
r.setWidth(r.width() - skip);
_rightSkip = skip;
}
if (r.top > _clipHeight || r.top < 0) {
if (r.top >= 0)
return true;
skip = -r.top;
r.setHeight(r.height() - skip);
_topSkip = skip;
r.moveTo(r.left, 0);
}
int bottom = r.bottom - 1;
if (bottom < 0)
return true;
else if (bottom > _clipHeight) {
skip = bottom - _clipHeight;
_bottomSkip = skip;
r.setHeight(r.height() - skip);
}
return false;
}
示例7: setViewport
bool BaseRenderOSystem::setViewport(int left, int top, int right, int bottom) {
Common::Rect rect;
// TODO: Hopefully this is the same logic that ScummVM uses.
rect.left = (int16)(left + _borderLeft);
rect.top = (int16)(top + _borderTop);
rect.setWidth((int16)((right - left) * _ratioX));
rect.setHeight((int16)((bottom - top) * _ratioY));
_renderRect = rect;
return STATUS_OK;
}
示例8: getItemRect
void InventoryRenderer::getItemRect(ItemPosition pos, Common::Rect &r) {
r.setHeight(_props->_itemHeight);
r.setWidth(_props->_itemWidth);
uint16 line = pos / _props->_itemsPerLine;
uint16 col = pos % _props->_itemsPerLine;
r.moveTo(col * _props->_itemWidth, line * _props->_itemHeight);
}
示例9: getHotRectangle
Common::Rect Cursor::getHotRectangle() const {
if (!_cursorImage) {
return Common::Rect();
} else {
Common::Point hotSpot = _cursorImage->getHotspot();
Common::Rect hotRectangle;
hotRectangle.setWidth(_cursorImage->getWidth());
hotRectangle.setHeight(_cursorImage->getHeight());
hotRectangle.translate(-hotSpot.x, -hotSpot.y);
return hotRectangle;
}
}
示例10: playTransition
void Frame::playTransition(Score *score) {
uint16 duration = _transDuration * 250; // _transDuration in 1/4 of sec
duration = (duration == 0 ? 250 : duration); // director support transition duration = 0, but animation play like value = 1, idk.
if (_transChunkSize == 0)
_transChunkSize = 1; //equal 1 step
uint16 stepDuration = duration / _transChunkSize;
uint16 steps = duration / stepDuration;
switch (_transType) {
case kTransCoverDown:
{
uint16 stepSize = score->_movieRect.height() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setHeight(stepSize * i);
g_system->delayMillis(stepDuration);
score->processEvents();
g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, 0, 0, r.width(), r.height());
g_system->updateScreen();
}
}
break;
case kTransCoverUp:
{
uint16 stepSize = score->_movieRect.height() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setHeight(stepSize * i);
g_system->delayMillis(stepDuration);
score->processEvents();
g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, 0, score->_movieRect.height() - stepSize * i, r.width(), r.height());
g_system->updateScreen();
}
}
break;
case kTransCoverRight: {
uint16 stepSize = score->_movieRect.width() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setWidth(stepSize * i);
g_system->delayMillis(stepDuration);
score->processEvents();
g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, 0, 0, r.width(), r.height());
g_system->updateScreen();
}
}
break;
case kTransCoverLeft: {
uint16 stepSize = score->_movieRect.width() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setWidth(stepSize * i);
g_system->delayMillis(stepDuration);
score->processEvents();
g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, score->_movieRect.width() - stepSize * i, 0, r.width(), r.height());
g_system->updateScreen();
}
}
break;
case kTransCoverUpLeft: {
uint16 stepSize = score->_movieRect.width() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setWidth(stepSize * i);
r.setHeight(stepSize * i);
g_system->delayMillis(stepDuration);
score->processEvents();
g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, score->_movieRect.width() - stepSize * i, score->_movieRect.height() - stepSize * i, r.width(), r.height());
g_system->updateScreen();
}
}
break;
case kTransCoverUpRight: {
uint16 stepSize = score->_movieRect.width() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setWidth(stepSize * i);
r.setHeight(stepSize * i);
g_system->delayMillis(stepDuration);
score->processEvents();
//.........这里部分代码省略.........
示例11: getBounds
bool UserInterface::getBounds(ScrCategory category, int v, Common::Rect &bounds) {
int heightMultiplier, widthMultiplier;
int leftStart, yOffset, widthAmt;
switch (category) {
case CAT_COMMAND:
heightMultiplier = v % 5;
widthMultiplier = v / 5;
leftStart = 2;
yOffset = 3;
widthAmt = 32;
break;
case CAT_INV_LIST:
if (v < _inventoryTopIndex || v >= (_inventoryTopIndex + 5))
return false;
heightMultiplier = v - _inventoryTopIndex;
widthMultiplier = 0;
leftStart = 90;
yOffset = 3;
widthAmt = 69;
break;
case CAT_TALK_ENTRY:
heightMultiplier = v;
widthMultiplier = 0;
leftStart = 2;
yOffset = 3;
widthAmt = 310;
break;
case CAT_INV_SCROLLER:
heightMultiplier = 0;
widthMultiplier = 0;
yOffset = 0;
widthAmt = 9;
leftStart = (v != 73) ? 73 : 75;
break;
default:
heightMultiplier = v;
widthMultiplier = 0;
leftStart = 240;
yOffset = 3;
widthAmt = 80;
break;
}
bounds.left = (widthMultiplier > 0) ? widthMultiplier * widthAmt + leftStart : leftStart;
bounds.setWidth(widthAmt);
bounds.top = heightMultiplier * 8 + yOffset;
bounds.setHeight(8);
if (category == CAT_INV_SCROLLER) {
switch (v) {
case SCROLLBAR_UP:
// Arrow up
bounds.top = 4;
bounds.setHeight(7);
break;
case SCROLLBAR_DOWN:
// Arrow down
bounds.top = 35;
bounds.setHeight(7);
break;
case SCROLLBAR_ELEVATOR:
// Scroller
bounds.top = 12;
bounds.setHeight(22);
break;
case SCROLLBAR_THUMB:
// Thumb
bounds.top = _scrollbarElevator + 14;
bounds.setHeight(1);
break;
default:
break;
}
}
return true;
}
示例12: drawSprite
bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) {
BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer);
if (!_loaded) {
finishLoad();
}
if (renderer->_forceAlphaColor != 0) {
alpha = renderer->_forceAlphaColor;
}
byte r = RGBCOLGetR(alpha);
byte g = RGBCOLGetG(alpha);
byte b = RGBCOLGetB(alpha);
byte a = RGBCOLGetA(alpha);
renderer->setAlphaMod(a);
renderer->setColorMod(r, g, b);
#if 0 // These are kept for reference if BlendMode is reimplemented at some point.
if (alphaDisable) {
SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE);
} else {
SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_BLEND);
}
#endif
// TODO: This _might_ miss the intended behaviour by 1 in each direction
// But I think it fits the model used in Wintermute.
Common::Rect srcRect;
srcRect.left = rect->left;
srcRect.top = rect->top;
srcRect.setWidth(rect->right - rect->left);
srcRect.setHeight(rect->bottom - rect->top);
Common::Rect position;
position.left = x + offsetX;
position.top = y + offsetY;
// Crop off-by-ones:
if (position.left == -1) {
position.left = 0; // TODO: Something is wrong
}
if (position.top == -1) {
position.top = 0; // TODO: Something is wrong
}
position.setWidth((int16)((float)srcRect.width() * zoomX / 100.f));
position.setHeight((int16)((float)srcRect.height() * zoomX / 100.f));
renderer->modTargetRect(&position);
/* position.left += offsetX;
position.top += offsetY;*/
// TODO: This actually requires us to have the SAME source-offsets every time,
// But no checking is in place for that yet.
// TODO: Optimize by not doing alpha-blits if we lack or disable alpha
bool hasAlpha;
if (_hasAlpha && !alphaDisable) {
hasAlpha = true;
} else {
hasAlpha = false;
}
if (alphaDisable) {
warning("BaseSurfaceOSystem::drawSprite - AlphaDisable ignored");
}
renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY, !hasAlpha);
return STATUS_OK;
}
示例13: blit
void Sprite::blit(const Sprite &from, const Common::Rect &area, int32 x, int32 y, bool transp) {
// Sanity checks
assert((x >= 0) && (y >= 0) && (x <= 0x7FFF) && (y <= 0x7FFF));
if (!exists() || !from.exists())
return;
Common::Rect toArea = getArea(true);
toArea.left = x;
toArea.top = y;
if (toArea.isEmpty())
return;
Common::Rect fromArea = from.getArea();
fromArea.clip(area);
fromArea.setWidth (MIN(fromArea.width() , toArea.width()));
fromArea.setHeight(MIN(fromArea.height(), toArea.height()));
if (fromArea.isEmpty() || !fromArea.isValidRect())
return;
int32 w = fromArea.width();
int32 h = fromArea.height();
const int32 fromTop = fracToInt(fromArea.top * from._scaleInverse);
const int32 fromLeft = fracToInt(fromArea.left * from._scaleInverse);
const byte *src = (const byte *) from._surfaceTrueColor.getBasePtr(fromLeft, fromTop);
byte *dst = ( byte *) _surfaceTrueColor.getBasePtr(x, y);
const uint8 *srcT = from._transparencyMap + fromTop * from._surfaceTrueColor.w + fromLeft;
uint8 *dstT = _transparencyMap + y * _surfaceTrueColor.w + x;
frac_t posW = 0, posH = 0;
while (h-- > 0) {
posW = 0;
const byte *srcRow = src;
byte *dstRow = dst;
const uint8 *srcRowT = srcT;
uint8 *dstRowT = dstT;
for (int32 j = 0; j < w; j++, dstRow += _surfaceTrueColor.bytesPerPixel, dstRowT++) {
if (!transp || (*srcRowT == 0)) {
// Ignore transparency or source is solid => copy
memcpy(dstRow, srcRow, _surfaceTrueColor.bytesPerPixel);
*dstRowT = *srcRowT;
} else if (*srcRowT == 2) {
// Half-transparent
if (*dstRowT == 1)
// But destination is transparent => propagate
memcpy(dstRow, srcRow, _surfaceTrueColor.bytesPerPixel);
else
// Destination is solid => mix
ImgConv.mixTrueColor(dstRow, srcRow);
*dstRowT = *srcRowT;
}
// Advance source data
posW += from._scaleInverse;
while (posW >= ((frac_t) FRAC_ONE)) {
srcRow += from._surfaceTrueColor.bytesPerPixel;
srcRowT++;
posW -= FRAC_ONE;
}
}
dst += _surfaceTrueColor.pitch;
dstT += _surfaceTrueColor.w;
// Advance source data
posH += from._scaleInverse;
while (posH >= ((frac_t) FRAC_ONE)) {
src += from._surfaceTrueColor.pitch;
srcT += from._surfaceTrueColor.w;
posH -= FRAC_ONE;
}
}
}
示例14: bltMaskScale
void Gfx::bltMaskScale(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor) {
if (scale == 100) {
// use optimized path
bltMaskNoScale(r, data, surf, z, transparentColor);
return;
}
// unscaled rectangle size
uint width = r.width();
uint height = r.height();
// scaled rectangle size
uint scaledWidth = r.width() * scale / 100;
uint scaledHeight = r.height() * scale / 100;
// scaled rectangle origin
uint scaledLeft = r.left + (width - scaledWidth) / 2;
uint scaledTop = r.top + (height - scaledHeight);
// clipped scaled destination rectangle
Common::Rect dstRect(scaledWidth, scaledHeight);
dstRect.moveTo(scaledLeft, scaledTop);
Common::Rect clipper(surf->w, surf->h);
dstRect.clip(clipper);
if (!dstRect.isValidRect()) return;
// clipped source rectangle
Common::Rect srcRect;
srcRect.left = (dstRect.left - scaledLeft) * 100 / scale;
srcRect.top = (dstRect.top - scaledTop) * 100 / scale;
srcRect.setWidth(dstRect.width() * 100 / scale);
srcRect.setHeight(dstRect.height() * 100 / scale);
if (!srcRect.isValidRect()) return;
Common::Point dp;
dp.x = dstRect.left;
dp.y = dstRect.top;
byte *s = data + srcRect.left + srcRect.top * width;
byte *d = (byte *)surf->getBasePtr(dp.x, dp.y);
uint line = 0, col = 0;
uint xAccum = 0, yAccum = 0;
uint inc = width * (100 - scale);
uint thr = width * 100;
for (uint16 i = 0; i < srcRect.height(); i++) {
yAccum += inc;
if (yAccum >= thr) {
yAccum -= thr;
s += width;
continue;
}
xAccum = 0;
byte *d2 = d;
col = 0;
for (uint16 j = 0; j < srcRect.width(); j++) {
xAccum += inc;
if (xAccum >= thr) {
xAccum -= thr;
s++;
continue;
}
if (*s != transparentColor) {
if (_backgroundInfo->hasMask()) {
byte v = _backgroundInfo->_mask->getValue(dp.x + col, dp.y + line);
if (z >= v) *d2 = *s;
} else {
*d2 = *s;
}
}
s++;
d2++;
col++;
}
s += width - srcRect.width();
d += surf->w;
line++;
}
}
示例15: getRect
void InventoryRenderer::getRect(Common::Rect& r) const {
r.setWidth(_props->_width);
r.setHeight(_props->_itemHeight * getNumLines());
r.moveTo(_pos);
}