Animate.cpp
上传用户:lulishicai
上传日期:2010-03-01
资源大小:13202k
文件大小:4k
源码类别:
Delphi/CppBuilder
开发平台:
C++ Builder
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include <stdlib.h>
- #include "Animate.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Timer1Timer(TObject *Sender)
- {
- Randomize;
- Form1->Shape1->Brush->Color=RGB(random(255),random(255),random(255));
- //设置画刷颜色
- Randomize;
- switch (random(8))
- {
- case 0:Form1->Shape1->Brush->Style=bsSolid;
- break;
- case 1:Form1->Shape1->Brush->Style=bsClear;
- break;
- case 2:Form1->Shape1->Brush->Style=bsHorizontal;
- break;
- case 3:Form1->Shape1->Brush->Style=bsVertical;
- break;
- case 4:Form1->Shape1->Brush->Style=bsFDiagonal;
- break;
- case 5:Form1->Shape1->Brush->Style=bsBDiagonal;
- break;
- case 6:Form1->Shape1->Brush->Style=bsCross;
- break;
- case 7:Form1->Shape1->Brush->Style=bsDiagCross;
- }
- //设置画刷风格
- Randomize;
- Form1->Shape1->Pen->Color=RGB(random(255),random(255),random(255));
- //设置画笔颜色
- Randomize;
- Form1->Shape1->Pen->Width=random(10)+1;
- //设置画笔大小
- Randomize;
- switch (random(16))
- {
- case 0:Form1->Shape1->Pen->Mode=pmBlack;
- break;
- case 1:Form1->Shape1->Pen->Mode=pmWhite;
- break;
- case 2:Form1->Shape1->Pen->Mode=pmNop;
- break;
- case 3:Form1->Shape1->Pen->Mode=pmNot;
- break;
- case 4:Form1->Shape1->Pen->Mode=pmCopy;
- break;
- case 5:Form1->Shape1->Pen->Mode=pmNotCopy;
- break;
- case 6:Form1->Shape1->Pen->Mode=pmMergePenNot;
- break;
- case 7:Form1->Shape1->Pen->Mode=pmMaskPenNot;
- break;
- case 8:Form1->Shape1->Pen->Mode=pmMergeNotPen;
- break;
- case 9:Form1->Shape1->Pen->Mode=pmMaskNotPen;
- break;
- case 10:Form1->Shape1->Pen->Mode=pmMerge;
- break;
- case 11:Form1->Shape1->Pen->Mode=pmNotMerge;
- break;
- case 12:Form1->Shape1->Pen->Mode=pmMask;
- break;
- case 13:Form1->Shape1->Pen->Mode=pmNotMask;
- break;
- case 14:Form1->Shape1->Pen->Mode=pmXor;
- break;
- case 15:Form1->Shape1->Pen->Mode=pmNotXor;
- }
- //设置画笔绘图模式
- Randomize;
- switch (random(7))
- {
- case 0:Form1->Shape1->Pen->Style=psSolid;
- break;
- case 1:Form1->Shape1->Pen->Style=psDash;
- break;
- case 2:Form1->Shape1->Pen->Style=psDot;
- break;
- case 3:Form1->Shape1->Pen->Style=psDashDot;
- break;
- case 4:Form1->Shape1->Pen->Style=psDashDotDot;
- break;
- case 5:Form1->Shape1->Pen->Style=psClear;
- break;
- case 6:Form1->Shape1->Pen->Style=psInsideFrame;
- }
- //设置画笔绘图风格
- Randomize;
- switch (random(6))
- {
- case 0:Form1->Shape1->Shape=stRectangle;
- break;
- case 1:Form1->Shape1->Shape=stSquare;
- break;
- case 2:Form1->Shape1->Shape=stRoundRect;
- break;
- case 3:Form1->Shape1->Shape=stRoundSquare;
- break;
- case 4:Form1->Shape1->Shape=stEllipse;
- break;
- case 5:Form1->Shape1->Shape=stCircle;
- }
- //设置控件形状
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- Form1->Shape1->Brush->Color=RGB(random(255),random(255),random(255));
- Form1->Shape1->Brush->Style=bsBDiagonal;
- Form1->Shape1->Pen->Color=RGB(random(255),random(255),random(255));
- Form1->Shape1->Pen->Width=random(10)+1;
- Form1->Shape1->Pen->Mode=pmMergeNotPen;
- Form1->Shape1->Pen->Style=psInsideFrame;
- Form1->Shape1->Shape=stRoundSquare;
- //设置绘图参数
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Shape1MouseDown(TObject *Sender,
- TMouseButton Button, TShiftState Shift, int X, int Y)
- {
- Form1->Timer1->Enabled=!Form1->Timer1->Enabled;
- }
- //---------------------------------------------------------------------------