Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ExtCtrls;
- type
- TForm1 = class(TForm)
- Image1: TImage;
- Button1: TButton;
- procedure FormCreate(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- imhgt,imwid,frame:Integer;
- bm1,bm2:tBitmap;
- implementation
- {$R *.dfm}
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- imhgt:=Image1.Height;
- imwid:=Image1.Width;
- bm1:=tBitmap.Create;
- bm2:=tBitmap.Create;
- bm1.Width:=imwid;
- bm2.Width:=imwid;
- bm1.Height:=imhgt;
- bm2.Height:=imhgt;
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- var
- x,y,scale,angle,sina,cosa:real;
- i,j,k,midx,midy,xdelta,ydelta:integer;
- xblock,yblock,blockwid,blockhgt,xblockx,yblocky,xblockxmid,yblockymid,xblocks,yblocks:integer;
- xbase,ybase,xfrom,yfrom,xto,yto:integer;
- color1,color2:tColor;
- begin
- bm2.Assign(bm1);
- midy:=imhgt div 2;
- midx:=imwid div 2;
- scale:=0.89;
- angle:=0.08;
- sina:=sin(angle)*scale;
- cosa:=cos(angle)*scale;
- blockhgt:=8;
- blockwid:=2;
- yblocks:=imhgt div blockhgt;
- xblocks:=imwid div blockwid;
- //add chaos in the center
- if (frame mod 6)=0
- then
- for i:=-2 to 1 do
- for j:=-2 to 0 do
- begin
- color1:=random(2)shl 23+random(2)shl 15+random(2)shl 7;
- color2:=0;
- if(random(8)=0) then color2:=color1;
- bm2.Canvas.Pixels[midx+j*2,midy+i*2]:=color1;
- bm2.Canvas.Pixels[midx+j*2,midy+i*2+1]:=color2;
- bm2.Canvas.Pixels[midx+j*2+1,midy+i*2]:=color2;
- bm2.Canvas.Pixels[midx+j*2+1,midy+i*2+1]:=color1;
- end;
- inc(frame);
- ydelta:=random(2);
- xdelta:=random(2);
- //rotate
- for xblock:=0 to xblocks-1 do
- //pop de for this column, set page for current output layer in #c000
- for yblock:=0 to yblocks-1 do //in vertical lines
- begin
- //pop hl (two pages of input screen are already set in #0000..#7fff)
- yblocky:=yblock*blockhgt;
- xblockx:=xblock*blockwid;
- yblockymid:=yblocky+(blockhgt div 2)-midy;
- xblockxmid:=xblockx+(blockwid div 2)-midx;
- ybase:=trunc(yblockymid*cosa+xblockxmid*sina)-(blockhgt div 2)+midy;
- xbase:=trunc(xblockxmid*cosa-yblockymid*sina)-(blockwid div 2)+midx;
- ybase:=((ybase+ydelta) or 1) - 1{(yblocky and 1)};
- xbase:=((xbase+xdelta) or 1) - 1{(xblockx and 1)};
- for i:=0 to blockhgt-1 do
- for j:=0 to blockwid-1 do
- begin
- //dup blockhgt/2
- //ld a,(hl)
- //ld (de),a
- //add hl,bc
- //exd
- //add hl,bc
- //ld a,(de)
- //ld (hl),a
- //add hl,bc
- //exd
- //add hl,bc
- //edup
- //org $-1
- //or you can use ld a,(nn):ld d/e,a:[push de] instead
- yfrom:=ybase+i;
- xfrom:=xbase+j;
- yto:=yblocky+i;
- xto:=xblockx+j;
- bm1.Canvas.Pixels[xto,yto]:=bm2.Canvas.Pixels[xfrom,yfrom];
- end;
- end;
- Image1.Picture.Assign(bm1);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement