Recent

Author Topic: Demoscene Square dot flag fx  (Read 8214 times)

Gigatron

  • Full Member
  • ***
  • Posts: 145
  • Amiga Rulez !!
Re: Demoscene Square dot flag fx
« Reply #15 on: August 24, 2024, 01:14:00 am »
Hi,
Today I worked on a string table to plot a point.
For example  000000011000011 ; if have 0 then plot black color, or 1 plot red color ;
So look the code and you will understand the principle;

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  9.   BGRAVirtualScreen, BGRABitmap, BGRABitmapTypes;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     BGRAVirtualScreen1: TBGRAVirtualScreen;
  17.     Timer1: TTimer;
  18.     procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  19.     procedure FormCreate(Sender: TObject);
  20.     procedure Timer1Timer(Sender: TObject);
  21.     procedure DotPlot();
  22.   private
  23.  
  24.   public
  25.  
  26.   end;
  27.  
  28. var
  29.   Form1: TForm1;
  30.   message_bitmap,message_bitmap1,bm : TBGRABitmap;
  31.   message : Array[0..19] Of String =('2222222222222222222222222222222222222222222222222222222222222222',
  32.                                      '2222222222222222222222222222222222222222222222222222222222222222',
  33.                                      '2200000000000000000000000000000000000000000000000000000000000022',
  34.                                      '2200001111111111111100011111111111111000111111111111100000000022',
  35.                                      '2200001000000000000000000000001000000000100000000000100000000022',
  36.                                      '2200001000000000000000000000001000000000100000000000100000000022',
  37.                                      '2200001000000000000000000000001000000000100000000000100000000022',
  38.                                      '2200001000000000000000000000001000000000100000000000100000000022',
  39.                                      '2200001000000000000000000000001000000000100000000000100000000022',
  40.                                      '2200001000000000000000000000001000000000111111111111000000000022',
  41.                                      '2200001000011111111100000000001000000000100110000000000000000022',
  42.                                      '2200001000000000000100000000001000000000100001100000000000000022',
  43.                                      '2200001000000000000100000000001000000000100000010000000000000022',
  44.                                      '2200001000000000000100000000001000000000100000001100000000000022',
  45.                                      '2200001000000000000100000000001000000000100000000010000000000022',
  46.                                      '2200001000000000000100000000001000000000100000000001000000000022',
  47.                                      '2200001111111111111100000000001000000000100000000000100000000022',
  48.                                      '2200000000000000000000000000000000000000000000000000000000000022',
  49.                                      '2222222222222222222222222222222222222222222222222222222222222222',
  50.                                      '2222222222222222222222222222222222222222222222222222222222222222');
  51.  
  52.  pos_x,pos_y,x,y  : integer;
  53.  ta,xapp,yapp : single;
  54.  // dot plot
  55.     s,a,ag : single;
  56.  
  57. implementation
  58.  
  59. {$R *.lfm}
  60.  
  61. { TForm1 }
  62.  
  63. procedure TForm1.Timer1Timer(Sender: TObject);
  64. begin
  65.  
  66.     BGRAVirtualScreen1.RedrawBitmap;
  67. end;
  68.  
  69. procedure TForm1.FormCreate(Sender: TObject);
  70. begin
  71.      pos_x := 0;
  72.      pos_y := 0;
  73.      ta :=0;
  74.      xapp :=0;
  75.      yapp :=0;
  76.  
  77.      message_bitmap := TBGRABitmap.Create(ClientWidth,ClientHeight,BGRABlack);
  78.      message_bitmap1 := TBGRABitmap.Create(ClientWidth,ClientHeight,BGRABlack); // buffer
  79.  
  80.    // plot fx
  81.    s := 255/sqrt(3)*2/30;
  82.    a := 0.0;
  83.    // angle
  84.    ag := 0.0;
  85.  
  86. end;
  87.  
  88. procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  89. begin
  90.      DotPlot();
  91.      Bitmap.PutImage(0,0,message_bitmap,dmDrawWithTransparency);
  92. end;
  93.  
  94. procedure TForm1.DotPlot;
  95. var
  96.  ii,jj : integer;
  97.   r,z,x1,x2,y1,y2 : single;
  98. begin
  99.  
  100.      message_Bitmap1.FillRect(0,0,ClientWidth,ClientHeight,BGRA(10,10,10)); // clear screen
  101.       for ii:=1 to 64 do
  102.       begin
  103.         for jj:=0 to High(message) do
  104.          begin
  105.  
  106.            ta   := ta + 0.00004;
  107.            xapp := x  + 32 * sin(ta-jj*0.2);
  108.            yApp := y  + 4  * sin(tA-jj*0.1+ii/2) ;
  109.  
  110.            r := (sqrt(ii*ii+jj*jj))+2;
  111.            z := 10*sin(r+a*0.6)/r*0.8;
  112.  
  113.            x2 := -jj*cos(a*PI/180)-jj*sin(ag*PI/180);
  114.            y2 := ii*sin(a*PI/180)-jj*cos(ag*PI/180);
  115.  
  116.            x1 :=  round(60+(y2-x2)*s*sqrt(3)/2);
  117.            y1 :=  round(120+z-(y2+x2)*s/2);
  118.            pos_x := round(x1+xApp)+ii*12;
  119.            pos_y := round(y1+yApp)+jj*12;
  120.  
  121.     if(message[jj][ii]='1') then message_Bitmap1.FillRect(pos_x, pos_y,pos_x+3,pos_y+3,BGRA(255,0,0,255),dmSet)
  122.     else if
  123.      (message[jj][ii]='2') then message_Bitmap1.FillRect(pos_x, pos_y,pos_x+3,pos_y+3,BGRA(0,125,255,255),dmSet)
  124.     else
  125.        message_Bitmap1.FillRect(pos_x,pos_y,pos_x+3,pos_y+3,BGRA(255,255,255,255),dmSet);
  126.     end;
  127.    end;
  128.       ag := ag + 0.4;
  129.       message_bitmap.PutImage(0,0,message_bitmap1,dmSet);
  130.  end;
  131.  
  132. end.
  133.  
Sub Quantum Technology ! Ufo Landing : Ezekiel 1-4;

 

TinyPortal © 2005-2018