本文整理汇总了C++中GFXDrawUtil::drawRect方法的典型用法代码示例。如果您正苦于以下问题:C++ GFXDrawUtil::drawRect方法的具体用法?C++ GFXDrawUtil::drawRect怎么用?C++ GFXDrawUtil::drawRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFXDrawUtil
的用法示例。
在下文中一共展示了GFXDrawUtil::drawRect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onRender
void GuiSwatchButtonCtrl::onRender( Point2I offset, const RectI &updateRect )
{
bool highlight = mMouseOver;
ColorI borderColor = mActive ? ( highlight ? mProfile->mBorderColorHL : mProfile->mBorderColor ) : mProfile->mBorderColorNA;
RectI renderRect( offset, getExtent() );
if ( !highlight )
renderRect.inset( 1, 1 );
GFXDrawUtil *drawer = GFX->getDrawUtil();
drawer->clearBitmapModulation();
// Draw background transparency grid texture...
if ( mGrid.isValid() )
drawer->drawBitmapStretch( mGrid, renderRect );
// Draw swatch color as fill...
if (!mUseSRGB)
drawer->drawRectFill( renderRect, mSwatchColor.toGamma() );
else
drawer->drawRectFill(renderRect, mSwatchColor);
// Draw any borders...
drawer->drawRect( renderRect, borderColor );
}
示例2: onRender
void GuiProgressBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
{
RectI ctrlRect(offset, getExtent());
//grab lowest dimension
if(getHeight() <= getWidth())
mDim = getHeight();
else
mDim = getWidth();
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
drawUtil->clearBitmapModulation();
if(mNumberOfBitmaps == 1)
{
//draw the progress with image
S32 width = (S32)((F32)(getWidth()) * mProgress);
if (width > 0)
{
//drawing stretch bitmap
RectI progressRect = ctrlRect;
progressRect.extent.x = width;
drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRect, mProfile->mBitmapArrayRects[0]);
}
}
else if(mNumberOfBitmaps >= 3)
{
//drawing left-end bitmap
RectI progressRectLeft(ctrlRect.point.x, ctrlRect.point.y, mDim, mDim);
drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRectLeft, mProfile->mBitmapArrayRects[0]);
//draw the progress with image
S32 width = (S32)((F32)(getWidth()) * mProgress);
if (width > mDim)
{
//drawing stretch bitmap
RectI progressRect = ctrlRect;
progressRect.point.x += mDim;
progressRect.extent.x = (width - mDim - mDim);
if (progressRect.extent.x < 0)
progressRect.extent.x = 0;
drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRect, mProfile->mBitmapArrayRects[1]);
//drawing right-end bitmap
RectI progressRectRight(progressRect.point.x + progressRect.extent.x, ctrlRect.point.y, mDim, mDim );
drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRectRight, mProfile->mBitmapArrayRects[2]);
}
}
else
Con::warnf("guiProgressBitmapCtrl only processes an array of bitmaps == 1 or >= 3");
//if there's a border, draw it
if (mProfile->mBorder)
drawUtil->drawRect(ctrlRect, mProfile->mBorderColor);
Parent::onRender( offset, updateRect );
//render the children
renderChildControls(offset, updateRect);
}
示例3: renderBorder
void renderBorder( const RectI &bounds, GuiControlProfile *profile )
{
S32 l = bounds.point.x, r = bounds.point.x + bounds.extent.x - 1;
S32 t = bounds.point.y, b = bounds.point.y + bounds.extent.y - 1;
GFXDrawUtil *drawer = GFX->getDrawUtil();
switch(profile->mBorder)
{
case 1:
drawer->drawRect(bounds, profile->mBorderColor);
break;
case 2:
drawer->drawLine(l + 1, t + 1, l + 1, b - 2, profile->mBevelColorHL);
drawer->drawLine(l + 2, t + 1, r - 2, t + 1, profile->mBevelColorHL);
drawer->drawLine(r, t, r, b, profile->mBevelColorHL);
drawer->drawLine(l, b, r - 1, b, profile->mBevelColorHL);
drawer->drawLine(l, t, r - 1, t, profile->mBorderColorNA);
drawer->drawLine(l, t + 1, l, b - 1, profile->mBorderColorNA);
drawer->drawLine(l + 1, b - 1, r - 1, b - 1, profile->mBorderColorNA);
drawer->drawLine(r - 1, t + 1, r - 1, b - 2, profile->mBorderColorNA);
break;
case 3:
drawer->drawLine(l, b, r, b, profile->mBevelColorHL);
drawer->drawLine(r, t, r, b - 1, profile->mBevelColorHL);
drawer->drawLine(l + 1, b - 1, r - 1, b - 1, profile->mFillColor);
drawer->drawLine(r - 1, t + 1, r - 1, b - 2, profile->mFillColor);
drawer->drawLine(l, t, l, b - 1, profile->mBorderColorNA);
drawer->drawLine(l + 1, t, r - 1, t, profile->mBorderColorNA);
drawer->drawLine(l + 1, t + 1, l + 1, b - 2, profile->mBevelColorLL);
drawer->drawLine(l + 2, t + 1, r - 2, t + 1, profile->mBevelColorLL);
break;
case 4:
drawer->drawLine(l, t, l, b - 1, profile->mBevelColorHL);
drawer->drawLine(l + 1, t, r, t, profile->mBevelColorHL);
drawer->drawLine(l, b, r, b, profile->mBevelColorLL);
drawer->drawLine(r, t + 1, r, b - 1, profile->mBevelColorLL);
drawer->drawLine(l + 1, b - 1, r - 1, b - 1, profile->mBorderColor);
drawer->drawLine(r - 1, t + 1, r - 1, b - 2, profile->mBorderColor);
break;
case 5:
renderFilledBorder( bounds, profile );
break;
//
case -1:
// Draw a simple sizable border with corners
// Taken from the 'Skinnable GUI Controls in TGE' resource by Justin DuJardin
if(profile->mBitmapArrayRects.size() >= 8)
{
drawer->clearBitmapModulation();
RectI destRect;
RectI stretchRect;
RectI* mBitmapBounds = profile->mBitmapArrayRects.address();
// Indices into the bitmap array
enum
{
BorderTopLeft = 0,
BorderTop,
BorderTopRight,
BorderLeft,
//Fill,
BorderRight,
BorderBottomLeft,
BorderBottom,
BorderBottomRight,
NumBitmaps
};
// Draw all corners first.
//top left border
drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[BorderTopLeft]);
//top right border
drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[BorderTopRight].extent.x,bounds.point.y),mBitmapBounds[BorderTopRight]);
//bottom left border
drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottomLeft].extent.y),mBitmapBounds[BorderBottomLeft]);
//bottom right border
drawer->drawBitmapSR(profile->mTextureObject,Point2I(
bounds.point.x + bounds.extent.x - mBitmapBounds[BorderBottomRight].extent.x,
bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottomRight].extent.y),
mBitmapBounds[BorderBottomRight]);
// End drawing corners
// Begin drawing sides and top stretched borders
//start with top line stretch
destRect.point.x = bounds.point.x + mBitmapBounds[BorderTopLeft].extent.x;
destRect.extent.x = bounds.extent.x - mBitmapBounds[BorderTopRight].extent.x - mBitmapBounds[BorderTopLeft].extent.x;
destRect.extent.y = mBitmapBounds[BorderTop].extent.y;
destRect.point.y = bounds.point.y;
//stretch it
stretchRect = mBitmapBounds[BorderTop];
stretchRect.inset(1,0);
//draw it
drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect);
//bottom line stretch
//.........这里部分代码省略.........