Animate.cpp
上传用户:lulishicai
上传日期:2010-03-01
资源大小:13202k
文件大小:4k
源码类别:

Delphi/CppBuilder

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <stdlib.h>
  5. #include "Animate.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma resource "*.dfm"
  9. TForm1 *Form1;
  10. //---------------------------------------------------------------------------
  11. __fastcall TForm1::TForm1(TComponent* Owner)
  12.         : TForm(Owner)
  13. {
  14. }
  15. //---------------------------------------------------------------------------
  16. void __fastcall TForm1::Timer1Timer(TObject *Sender)
  17. {
  18. Randomize;
  19. Form1->Shape1->Brush->Color=RGB(random(255),random(255),random(255));
  20. //设置画刷颜色
  21. Randomize;
  22. switch (random(8))
  23.      {
  24.      case 0:Form1->Shape1->Brush->Style=bsSolid;
  25.             break;
  26.      case 1:Form1->Shape1->Brush->Style=bsClear;
  27.             break;
  28.      case 2:Form1->Shape1->Brush->Style=bsHorizontal;
  29.             break;
  30.      case 3:Form1->Shape1->Brush->Style=bsVertical;
  31.             break;
  32.      case 4:Form1->Shape1->Brush->Style=bsFDiagonal;
  33.             break;
  34.      case 5:Form1->Shape1->Brush->Style=bsBDiagonal;
  35.             break;
  36.      case 6:Form1->Shape1->Brush->Style=bsCross;
  37.             break;
  38.      case 7:Form1->Shape1->Brush->Style=bsDiagCross;
  39.      }
  40.      //设置画刷风格
  41. Randomize;
  42. Form1->Shape1->Pen->Color=RGB(random(255),random(255),random(255));
  43. //设置画笔颜色
  44. Randomize;
  45. Form1->Shape1->Pen->Width=random(10)+1;
  46. //设置画笔大小
  47. Randomize;
  48. switch (random(16))
  49.      {
  50.      case 0:Form1->Shape1->Pen->Mode=pmBlack;
  51.             break;
  52.      case 1:Form1->Shape1->Pen->Mode=pmWhite;
  53.             break;
  54.      case 2:Form1->Shape1->Pen->Mode=pmNop;
  55.             break;
  56.      case 3:Form1->Shape1->Pen->Mode=pmNot;
  57.             break;
  58.      case 4:Form1->Shape1->Pen->Mode=pmCopy;
  59.             break;
  60.      case 5:Form1->Shape1->Pen->Mode=pmNotCopy;
  61.             break;
  62.      case 6:Form1->Shape1->Pen->Mode=pmMergePenNot;
  63.             break;
  64.      case 7:Form1->Shape1->Pen->Mode=pmMaskPenNot;
  65.             break;
  66.      case 8:Form1->Shape1->Pen->Mode=pmMergeNotPen;
  67.             break;
  68.      case 9:Form1->Shape1->Pen->Mode=pmMaskNotPen;
  69.             break;
  70.      case 10:Form1->Shape1->Pen->Mode=pmMerge;
  71.             break;
  72.      case 11:Form1->Shape1->Pen->Mode=pmNotMerge;
  73.             break;
  74.      case 12:Form1->Shape1->Pen->Mode=pmMask;
  75.             break;
  76.      case 13:Form1->Shape1->Pen->Mode=pmNotMask;
  77.             break;
  78.      case 14:Form1->Shape1->Pen->Mode=pmXor;
  79.             break;
  80.      case 15:Form1->Shape1->Pen->Mode=pmNotXor;
  81.      }
  82.      //设置画笔绘图模式
  83. Randomize;
  84. switch (random(7))
  85.      {
  86.      case 0:Form1->Shape1->Pen->Style=psSolid;
  87.           break;
  88.      case 1:Form1->Shape1->Pen->Style=psDash;
  89.           break;
  90.      case 2:Form1->Shape1->Pen->Style=psDot;
  91.           break;
  92.      case 3:Form1->Shape1->Pen->Style=psDashDot;
  93.           break;
  94.      case 4:Form1->Shape1->Pen->Style=psDashDotDot;
  95.           break;
  96.      case 5:Form1->Shape1->Pen->Style=psClear;
  97.           break;
  98.      case 6:Form1->Shape1->Pen->Style=psInsideFrame;
  99.      }
  100.      //设置画笔绘图风格
  101. Randomize;
  102. switch (random(6))
  103.      {
  104.      case 0:Form1->Shape1->Shape=stRectangle;
  105.           break;
  106.      case 1:Form1->Shape1->Shape=stSquare;
  107.           break;
  108.      case 2:Form1->Shape1->Shape=stRoundRect;
  109.           break;
  110.      case 3:Form1->Shape1->Shape=stRoundSquare;
  111.           break;
  112.      case 4:Form1->Shape1->Shape=stEllipse;
  113.           break;
  114.      case 5:Form1->Shape1->Shape=stCircle;
  115.      }
  116.      //设置控件形状
  117. }
  118. //---------------------------------------------------------------------------
  119. void __fastcall TForm1::FormCreate(TObject *Sender)
  120. {
  121. Form1->Shape1->Brush->Color=RGB(random(255),random(255),random(255));
  122. Form1->Shape1->Brush->Style=bsBDiagonal;
  123. Form1->Shape1->Pen->Color=RGB(random(255),random(255),random(255));
  124. Form1->Shape1->Pen->Width=random(10)+1;
  125. Form1->Shape1->Pen->Mode=pmMergeNotPen;
  126. Form1->Shape1->Pen->Style=psInsideFrame;
  127. Form1->Shape1->Shape=stRoundSquare;
  128. //设置绘图参数
  129. }
  130. //---------------------------------------------------------------------------
  131. void __fastcall TForm1::Shape1MouseDown(TObject *Sender,
  132.       TMouseButton Button, TShiftState Shift, int X, int Y)
  133. {
  134.    Form1->Timer1->Enabled=!Form1->Timer1->Enabled;
  135. }
  136. //---------------------------------------------------------------------------