LED 모양 만들기 입니다.
LED 만드는 방법중의 하나가 되겠죠...
int size_rate=2;
AnsiString str=" 볼랜드의 C++Builder 가 발전하기를 바랍니다. 왜냐하면 쉽고 편하기 때문입니다. Good job www.bcbdn.com ^^ ";
void led_effect(int x,int y)
{
Graphics::TBitmap*a=new Graphics::TBitmap();
a->Canvas->Font->Name="굴림";
a->Canvas->Font->Size=9;
a->Canvas->Font->Color=clLime;
a->Canvas->Brush->Color=clGreen;
a->Width=a->Canvas->TextWidth(str);
a->Height=a->Canvas->TextHeight(str);
a->Canvas->TextOut(0,0,str);
//
Graphics::TBitmap*b=new Graphics::TBitmap();
b->Canvas->Pen->Color=clBlack;
b->Width=a->Width*size_rate;
b->Height=a->Height*size_rate;
StretchBlt(
b->Canvas->Handle,0,0,b->Width,b->Height,
a->Canvas->Handle,0,0,a->Width,a->Height,
cmSrcCopy
);
for(int i=0;i<b->Width;i+=size_rate){
b->Canvas->MoveTo(i,0);
b->Canvas->LineTo(i,b->Height);
}
for(int i=0;i<b->Height;i+=size_rate){
b->Canvas->MoveTo(0,i);
b->Canvas->LineTo(b->Width,i);
}
#define view_width 400
int pos=0;
while(pos<b->Width-view_width-size_rate){
BitBlt(
Form1->Canvas->Handle,x,y,x+view_width,y+b->Height,
b->Canvas->Handle,pos,0,cmSrcCopy
);
pos+=size_rate;
Sleep(10);
}
delete b;
delete a;
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
size_rate=2;
led_effect(10,10);
size_rate=3;
led_effect(10,50);
size_rate=4;
led_effect(10,100);
size_rate=5;
led_effect(10,160);
}
|