📄 style.h
字号:
#ifndef STYLE_H_
#define STYLE_H_
#include <e32math.h>
#include <fbs.h>
/*
Need to include these lib
LIBRARY bitgdi.lib
*/
#endif /*STYLE_H_*/
/*--------------------雨滴效果--------------------*/
void rain(CFbsBitmap* aNextBitmap, CFbsBitmap* aMemBitmap, TInt screenWidth = 240, TInt screenHeight = 320)
{
CFbsBitmapDevice *bitDev = CFbsBitmapDevice::NewL(aMemBitmap);
CleanupStack::PushL(bitDev);
CFbsBitGc *bitGc;
User::LeaveIfError( bitDev->CreateContext(bitGc));
//算法开始
TInt i;
TInt j;
TInt k = screenHeight / 2;
for(i=0; i<=screenHeight; ++i )
{
for(j=0; j<=screenHeight-i; ++j )
{
bitGc->DrawBitmap(TRect(TPoint(0, j), TSize(screenWidth,1)),
aNextBitmap,
TRect(TPoint(0,screenHeight-i),TSize(screenWidth,1)));
if(j % k == 0)
{
DrawNow();
}
}
}
//算法结束
CleanupStack::PopAndDestroy();
if(bitGc)
{
delete bitGc;
}
}
/*--------------------积木效果--------------------*/
void brick(CFbsBitmap* aNextBitmap, CFbsBitmap* aMemBitmap, TInt screenWidth = 240, TInt screenHeight = 320)
{
CFbsBitmapDevice *bitDev = CFbsBitmapDevice::NewL(aMemBitmap);
CleanupStack::PushL(bitDev);
CFbsBitGc *bitGc;
User::LeaveIfError( bitDev->CreateContext(bitGc));
//算法开始
TInt i;
TInt j;
TInt stepx;
TInt stepy;
TInt dispnum;
TInt x;
TInt y;
const TInt KNUM = 20;
TInt nummax =KNUM * KNUM;
TBool pxy[KNUM][KNUM];
for ( i=0; i<KNUM; ++i )
{
for ( j=0; j<KNUM; ++j )
{
pxy[i][j] = EFalse;
}
}
stepx = screenWidth / KNUM;
stepy = screenHeight / KNUM;
TTime time;
time.HomeTime();
TInt64 aSeed=time.Int64();
//srand( (unsigned)time( NULL ) );
dispnum = 0;
while(1)
{
x= Math::Rand(aSeed) % KNUM;
y= Math::Rand(aSeed) % KNUM;
if ( pxy[x][y] )
//本组x,y所代表的数据组是否已显示过?
continue;
pxy[x][y] = ETrue;
//表明本组x,y所代表的数据组已显示过
bitGc->DrawBitmap(TRect(TPoint(x*stepx, y*stepy), TSize(stepx,stepy)),
aNextBitmap,
TRect(TPoint(x*stepx, y*stepy),TSize(stepx, stepy)));
if(dispnum%2 == 0)
{
DrawNow();
}
dispnum++;
if ( dispnum >= nummax)
break;
}
//算法结束
CleanupStack::PopAndDestroy();
if(bitGc)
{
delete bitGc;
}
}
/*--------------------百叶窗效果--------------------*/
void shutter(CFbsBitmap* aNextBitmap, CFbsBitmap* aMemBitmap, TInt screenWidth = 240, TInt screenHeight = 320)
{
CFbsBitmapDevice *bitDev = CFbsBitmapDevice::NewL(aMemBitmap);
CleanupStack::PushL(bitDev);
CFbsBitGc *bitGc;
User::LeaveIfError( bitDev->CreateContext(bitGc));
//算法开始
TInt i;
TInt j;
TInt stepi;
stepi=screenHeight / 10;
for ( i=0; i<=stepi; ++i )
{
for ( j=0; j<10; ++j )
{
bitGc->DrawBitmap(TRect(TPoint(0, j*stepi+i), TSize(screenWidth, 1)),
aNextBitmap,
TRect(TPoint(0,j*stepi+i),TSize(screenWidth, 1)));
if(j % 2 == 0)
{
DrawNow();
}
}
}
//算法结束
CleanupStack::PopAndDestroy();
if(bitGc)
{
delete bitGc;
}
}
/*--------------------水平交错效果--------------------*/
void horizontal(CFbsBitmap* aNextBitmap, CFbsBitmap* aMemBitmap, TInt screenWidth = 240, TInt screenHeight = 320)
{
CFbsBitmapDevice *bitDev = CFbsBitmapDevice::NewL(aMemBitmap);
CleanupStack::PushL(bitDev);
CFbsBitGc *bitGc;
User::LeaveIfError( bitDev->CreateContext(bitGc));
//算法开始
TInt i;
TInt j;
for(i=0; i <= screenHeight; i+=2)
{
j = i;
while(j > 0)
{
bitGc->DrawBitmap(TRect(TPoint(0, j-1), TSize(screenWidth,1)),
aNextBitmap,
TRect(TPoint(0,screenHeight-(i-j-1)),TSize(screenWidth,1)));
bitGc->DrawBitmap(TRect(TPoint(0, screenHeight-j), TSize(screenWidth,1)),
aNextBitmap,
TRect(TPoint(0,i-j),TSize(screenWidth,1)));
j-=2;
if(j % 100 == 0)
{
DrawNow();
}
}
}
//算法结束
CleanupStack::PopAndDestroy();
if(bitGc)
{
delete bitGc;
}
}
//end of file
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -