Demo Scene Raster Fx lazarus / 39-Graphics ---------------------------------------------------------------------- Gigatron · 2024-05-03 22:10 Hi, Just coded under 1 hour a nice example of rasters demo; source (commented)  and png files  are included in attachement. Have fun Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, Spin,  StdCtrls, BGRAVirtualScreen, BGRABitmap, BCTypes, BGRABitmapTypes; type   { TForm1 }   TForm1 = class(TForm)    BGRAVirtualScreen1: TBGRAVirtualScreen;    FloatSpinEdit1: TFloatSpinEdit;    FloatSpinEdit2: TFloatSpinEdit;    GroupBox1: TGroupBox;    SpinEdit1: TSpinEdit;    SpinEdit2: TSpinEdit;    Timer1: TTimer;    procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);    procedure FormCreate(Sender: TObject);    procedure Timer1Timer(Sender: TObject);  private    raster_1  : TBGRABitmap;    raster_2  : TBGRABitmap;    raster_3  : TBGRABitmap;    raster_4  : TBGRABitmap;    raster_5  : TBGRABitmap;    raster_6  : TBGRABitmap;  raster_7  : TBGRABitmap;    raster_8  : TBGRABitmap;    raster_9  : TBGRABitmap;    raster_10 : TBGRABitmap;    raster_11 : TBGRABitmap;    public   end; var  Form1: TForm1;   y: integer ;   // offset between rasters  amp,r_sin,offset,sin_factor : double; // amplitude, raster_sin, sinus mul factor, implementation {$R *.lfm} { TForm1 }   procedure TForm1.FormCreate(Sender: TObject);begin  raster_1 := TBGRABitmap.Create('5.png'); // rasters bitmaps raster_2 := TBGRABitmap.Create('6.png'); raster_3 := TBGRABitmap.Create('2.png'); raster_4 := TBGRABitmap.Create('1.png'); raster_5 := TBGRABitmap.Create('9.png'); raster_6 := TBGRABitmap.Create('8.png');  raster_7 := TBGRABitmap.Create('12.png'); raster_8 := TBGRABitmap.Create('11.png'); raster_9 := TBGRABitmap.Create('13.png'); raster_10 := TBGRABitmap.Create('3.png'); raster_11 := TBGRABitmap.Create('4.png');      // init vars     r_sin :=0;     offset :=0.06;     amp :=100.0;     sin_factor :=0;     y:=1; end; procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);var i: integer; begin  for i:=0 to 26 do    // 27 * 24w  pixel rasters ; begin     Bitmap.PutImage(i*24,180+round(sin(i*y+r_sin- offset*50.0)*amp),raster_1,dmSet);    Bitmap.PutImage(i*24,180+round(sin(i*y+r_sin- offset*45.0)*amp),raster_2,dmSet);    Bitmap.PutImage(i*24,180+round(sin(i*y+r_sin- offset*40.0)*amp),raster_3,dmSet);    Bitmap.PutImage(i*24,180+round(sin(i*y+r_sin- offset*35.0)*amp),raster_4,dmSet);    Bitmap.PutImage(i*24,180+round(sin(i*y+r_sin- offset*30.0)*amp),raster_5,dmSet);    Bitmap.PutImage(i*24,180+round(sin(i*y+r_sin- offset*25.0)*amp),raster_6,dmSet);    Bitmap.PutImage(i*24,180+round(sin(i*y+r_sin- offset*20.0)*amp),raster_7,dmSet);    Bitmap.PutImage(i*24,180+round(sin(i*y+r_sin- offset*15.0)*amp),raster_8,dmSet);    Bitmap.PutImage(i*24,180+round(sin(i*y+r_sin- offset*10.0)*amp),raster_9,dmSet);    Bitmap.PutImage(i*24,180+round(sin(i*y+r_sin- offset*5.0)*amp),raster_10,dmSet);    Bitmap.PutImage(i*24,180+round(sin(i*y+r_sin-offset)*amp),    raster_11,dmSet);   end; end;// loop with timer to render variables modifications by user !procedure TForm1.Timer1Timer(Sender: TObject);begin       r_sin      := r_sin + sin_factor;       amp      := spinedit1.Value;       sin_factor := FloatSpinedit1.Value;       offset     := FloatSpinedit2.Value;       y          := spinedit2.Value;        BGRAVirtualScreen1.RedrawBitmap;end; end.