Merge pull request #637 from Azaezel/alpha40/guiRotation

blatantly ganked from T2D; adds rotation as an option for drawbitmap
This commit is contained in:
Brian Roberts 2021-11-08 16:08:17 -06:00 committed by GitHub
commit e0e3ebc69d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 27 deletions

View file

@ -58,6 +58,7 @@ ConsoleDocClass( GuiBitmapCtrl,
GuiBitmapCtrl::GuiBitmapCtrl(void)
: mStartPoint( 0, 0 ),
mColor(ColorI::WHITE),
mAngle(0),
mWrap( false )
{
INIT_ASSET(Bitmap);
@ -83,6 +84,8 @@ void GuiBitmapCtrl::initPersistFields()
addField("color", TypeColorI, Offset(mColor, GuiBitmapCtrl),"color mul");
addField( "wrap", TypeBool, Offset( mWrap, GuiBitmapCtrl ),
"If true, the bitmap is tiled inside the control rather than stretched to fit." );
addField("angle", TypeF32, Offset(mAngle, GuiBitmapCtrl), "rotation");
endGroup( "Bitmap" );
@ -187,14 +190,14 @@ void GuiBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
((texture->mBitmapSize.y*y)+offset.y)-yshift,
texture->mBitmapSize.x,
texture->mBitmapSize.y);
GFX->getDrawUtil()->drawBitmapStretchSR(texture,dstRegion, srcRegion, GFXBitmapFlip_None, GFXTextureFilterLinear);
GFX->getDrawUtil()->drawBitmapStretchSR(texture, dstRegion, srcRegion, GFXBitmapFlip_None, GFXTextureFilterLinear, mAngle);
}
}
else
{
RectI rect(offset, getExtent());
GFX->getDrawUtil()->drawBitmapStretch(mBitmap, rect, GFXBitmapFlip_None, GFXTextureFilterLinear, false);
GFX->getDrawUtil()->drawBitmapStretch(mBitmap, rect, GFXBitmapFlip_None, GFXTextureFilterLinear, false, mAngle);
}
}

View file

@ -44,7 +44,8 @@ class GuiBitmapCtrl : public GuiControl
Point2I mStartPoint;
ColorI mColor;
F32 mAngle;
/// If true, bitmap tiles inside control. Otherwise stretches.
bool mWrap;