Advertisement
Guest User

Untitled

a guest
May 25th, 2013
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7. Dialogs, StdCtrls, ExtCtrls;
  8.  
  9. type
  10. TForm1 = class(TForm)
  11. Image1: TImage;
  12. Button1: TButton;
  13. procedure FormCreate(Sender: TObject);
  14. procedure Button1Click(Sender: TObject);
  15. private
  16. { Private declarations }
  17. public
  18. { Public declarations }
  19. end;
  20.  
  21. var
  22. Form1: TForm1;
  23. imhgt,imwid,frame:Integer;
  24. bm1,bm2:tBitmap;
  25.  
  26. implementation
  27.  
  28. {$R *.dfm}
  29.  
  30. procedure TForm1.FormCreate(Sender: TObject);
  31. begin
  32. imhgt:=Image1.Height;
  33. imwid:=Image1.Width;
  34.  
  35. bm1:=tBitmap.Create;
  36. bm2:=tBitmap.Create;
  37. bm1.Width:=imwid;
  38. bm2.Width:=imwid;
  39. bm1.Height:=imhgt;
  40. bm2.Height:=imhgt;
  41.  
  42.  
  43. end;
  44.  
  45. procedure TForm1.Button1Click(Sender: TObject);
  46. var
  47. x,y,scale,angle,sina,cosa:real;
  48. i,j,k,midx,midy,xdelta,ydelta:integer;
  49. xblock,yblock,blockwid,blockhgt,xblockx,yblocky,xblockxmid,yblockymid,xblocks,yblocks:integer;
  50. xbase,ybase,xfrom,yfrom,xto,yto:integer;
  51. color1,color2:tColor;
  52. begin
  53. bm2.Assign(bm1);
  54.  
  55. midy:=imhgt div 2;
  56. midx:=imwid div 2;
  57. scale:=0.89;
  58. angle:=0.08;
  59. sina:=sin(angle)*scale;
  60. cosa:=cos(angle)*scale;
  61. blockhgt:=8;
  62. blockwid:=2;
  63. yblocks:=imhgt div blockhgt;
  64. xblocks:=imwid div blockwid;
  65.  
  66. //add chaos in the center
  67. if (frame mod 6)=0
  68. then
  69. for i:=-2 to 1 do
  70. for j:=-2 to 0 do
  71. begin
  72. color1:=random(2)shl 23+random(2)shl 15+random(2)shl 7;
  73. color2:=0;
  74. if(random(8)=0) then color2:=color1;
  75. bm2.Canvas.Pixels[midx+j*2,midy+i*2]:=color1;
  76. bm2.Canvas.Pixels[midx+j*2,midy+i*2+1]:=color2;
  77. bm2.Canvas.Pixels[midx+j*2+1,midy+i*2]:=color2;
  78. bm2.Canvas.Pixels[midx+j*2+1,midy+i*2+1]:=color1;
  79. end;
  80. inc(frame);
  81.  
  82. ydelta:=random(2);
  83. xdelta:=random(2);
  84.  
  85. //rotate
  86. for xblock:=0 to xblocks-1 do
  87. //pop de for this column, set page for current output layer in #c000
  88. for yblock:=0 to yblocks-1 do //in vertical lines
  89. begin
  90. //pop hl (two pages of input screen are already set in #0000..#7fff)
  91. yblocky:=yblock*blockhgt;
  92. xblockx:=xblock*blockwid;
  93. yblockymid:=yblocky+(blockhgt div 2)-midy;
  94. xblockxmid:=xblockx+(blockwid div 2)-midx;
  95. ybase:=trunc(yblockymid*cosa+xblockxmid*sina)-(blockhgt div 2)+midy;
  96. xbase:=trunc(xblockxmid*cosa-yblockymid*sina)-(blockwid div 2)+midx;
  97. ybase:=((ybase+ydelta) or 1) - 1{(yblocky and 1)};
  98. xbase:=((xbase+xdelta) or 1) - 1{(xblockx and 1)};
  99. for i:=0 to blockhgt-1 do
  100. for j:=0 to blockwid-1 do
  101. begin
  102. //dup blockhgt/2
  103. //ld a,(hl)
  104. //ld (de),a
  105. //add hl,bc
  106. //exd
  107. //add hl,bc
  108. //ld a,(de)
  109. //ld (hl),a
  110. //add hl,bc
  111. //exd
  112. //add hl,bc
  113. //edup
  114. //org $-1
  115. //or you can use ld a,(nn):ld d/e,a:[push de] instead
  116. yfrom:=ybase+i;
  117. xfrom:=xbase+j;
  118. yto:=yblocky+i;
  119. xto:=xblockx+j;
  120. bm1.Canvas.Pixels[xto,yto]:=bm2.Canvas.Pixels[xfrom,yfrom];
  121. end;
  122. end;
  123.  
  124. Image1.Picture.Assign(bm1);
  125. end;
  126.  
  127. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement