Rotating Text lazarus / 39-Graphics ---------------------------------------------------------------------- Gigatron · 2025-05-01 18:49 Hi, Here is a simple animated rotating text it use Bgra canvas2d functions like javascript , the code is not yet optimized i will try to improve it. 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+}interfaceuses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls,  BGRABitmap, BGRABitmapTypes, BGRACanvas2D,mmsystem;type  { TForm1 }  TForm1 = class(TForm)    Timer1: TTimer;    procedure FormCreate(Sender: TObject);    procedure FormDestroy(Sender: TObject);    procedure FormResize(Sender: TObject);    procedure Timer1Timer(Sender: TObject);  private    FBuffer: TBGRABitmap;    txt: string;    CIndex: Integer;    RotAngle: Single;    LastCharTm: QWord;    procedure RenderToBuffer;  public  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject);const sflag = snd_Loop or snd_Async;begin  Caption := 'Rotating TEXT V1.0 Gigatron';  txt := 'LAZARUS FPC 2025 ';  CIndex := 0;  RotAngle := 0;  LastCharTm := 0;  FBuffer := TBGRABitmap.Create(Width, Height);  playsound('mbis.wav',0, sflag);//monoend; procedure TForm1.FormDestroy(Sender: TObject);begin  FBuffer.Free;end; procedure TForm1.FormResize(Sender: TObject);begin  if Assigned(FBuffer) then  begin    FBuffer.SetSize(Width, Height);  end;end; procedure TForm1.RenderToBuffer;var  centerX, centerY, radius: Integer;  i: Integer;  charAngle: Single;  x, y: Integer;  canvas2D: TBGRACanvas2D;begin   FBuffer.Fill(BGRA($77, $77, $77));  centerX := Width div 2;  centerY := Height div 2;  radius := 220;  canvas2D := FBuffer.Canvas2D;  // canvas operation delta force !  for i := 0 to CIndex - 1 do  begin    charAngle := (i * 2 * Pi / Length(txt)) + RotAngle;     x := centerX + Round(radius * Cos(charAngle));    y := centerY + Round(radius * Sin(charAngle));   canvas2D.save;    canvas2D.translate(x, y);    canvas2D.rotate(charAngle + Pi/2);    canvas2D.fillStyle(BGRA($ee,$ee,$ee));    canvas2D.font := 'bold 64px Arial';    canvas2D.fillText(txt[i+1], 0, 0);    canvas2D.fillStyle(BGRA($ff,$00,$00));    canvas2D.fillText(txt[i+1], 8, 0);    canvas2D.restore;  end;   RotAngle := RotAngle + 0.04;end; procedure TForm1.Timer1Timer(Sender: TObject);var  cTime: QWord;begin  //cTime := GetTickCount64;  //if (CIndex < Length(txt)) and (cTime - LastCharTm > 150) then  // typewrite time  //begin  //  Inc(CIndex);  //  LastCharTm := cTime;  //end;  Cindex := Length(txt);  RenderToBuffer;  FBuffer.Draw(Canvas, 0, 0, true);end;end. ---------------------------------------------------------------------- Gigatron · 2025-05-01 19:16 The same text effect code but much more faster and smooth without canvas2d. Used BGRA bitmap virtualscreen; 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+}interfaceuses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls,  BGRABitmap, BGRABitmapTypes, BGRAVirtualScreen, mmsystem;type  { TForm1 }  TForm1 = class(TForm)  BGRAVirtualScreen1: TBGRAVirtualScreen;    Timer1: TTimer;    procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);    procedure FormCreate(Sender: TObject);    procedure FormResize(Sender: TObject);    procedure Timer1Timer(Sender: TObject);  private    txt: string;    CIndex: Integer;    RotAngle: Single;    LastCharTm: QWord;  public  end;var  Form1: TForm1;implementation{$R *.lfm}{ TForm1 }procedure TForm1.FormCreate(Sender: TObject);const sflag = snd_Loop or snd_Async;begin  Caption := 'Rotating TEXT V1.0 Gigatron';  txt := 'LAZARUS FPC 2025 ';  CIndex := 0;  RotAngle := 0;  LastCharTm := 0;  BGRAVirtualScreen1.Align := alClient;  playsound('mbis.wav', 0, sflag);//monoend; procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);var  centerX, centerY, radius: Integer;  i: Integer;  charAngle: Single;  x, y: Integer;begin   Bitmap.Fill(BGRA($77, $77, $77));   centerX := BGRAVirtualScreen1.Width div 2;  centerY := BGRAVirtualScreen1.Height div 2;  radius := 220;   bitmap.FontFullHeight := 72;  bitmap.FontName :='Arial';  bitmap.FontStyle := [fsBold];   // BGRA operation delta force !  for i := 0 to CIndex - 1 do  begin    charAngle := (i * 2 * Pi / Length(txt)) + RotAngle;    x := centerX + Round(radius * Cos(charAngle));    y := centerY + Round(radius * Sin(charAngle));   bitmap.TextOutAngle(x,y-30, Round(charAngle),txt[i+1],BGRA(255,255,255));    bitmap.TextOutAngle(x +4,y-30,Round(charAngle),txt[i+1],BGRA(255,0,0));   end;end; procedure TForm1.FormResize(Sender: TObject);begin  BGRAVirtualScreen1.Invalidate;end; procedure TForm1.Timer1Timer(Sender: TObject);var  cTime: QWord;begin  cTime := GetTickCount64;  if (CIndex < Length(txt)) and (cTime - LastCharTm > 150) then  // typewrite time  begin    Inc(CIndex);    LastCharTm := cTime;  end;   RotAngle := RotAngle + 0.02;  BGRAVirtualScreen1.RedrawBitmap;end;end. ---------------------------------------------------------------------- d2010 · 2025-05-02 01:13 Plase you do not calculate reiterator sine and cosine. You make static array of single !! not double. 1)you add menuFile.-> File->Open 2)you add menufile->File->Save, as Csv File 3)You add submenu "Edit->Calculatorr SharpCalculator" Code: [Select]Type TFomat10FileRotate=      cmdX:shortstring;      cmdy:shortstring;      FontFullHeight : integer;      FontName :array[0..31] of char      FontStyle : word      cmdxyCount:integer;      Bufx:array[word] of single      Bufy:array[word] of single;   End; Var SharpCalc:TFomat10FileRotate; Yom put outside TForm the SharpCalc; You must be sure yon have only one, one, one , one variabile SharpCalc on entire MyProject.lpi Always You save All sine and cosine, after after the full-calc, You save  onto-array SharpCalc:array[word] of integer; Code: [Select]Var SharpCalc:TFomat10FileRotate; Implementation ---------------------------------------------------------------------- Gigatron · 2025-05-02 13:11 Hi , @d2010 certainly answered on another post. So, this time using rotating text to make Rotating Scroll Text , if you have long text. 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,  BGRABitmap, BGRABitmapTypes, BGRAVirtualScreen, mmsystem; type   // structure chr !  TChr = record    Char: Char;    Angle: Single;    Rotations: Integer;    Age: Integer;  end;   { TForm1 }  TForm1 = class(TForm)    BGRAVirtualScreen1: TBGRAVirtualScreen;    Timer1: TTimer;    procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);    procedure FormCreate(Sender: TObject);    procedure FormResize(Sender: TObject);    procedure Timer1Timer(Sender: TObject);  private    txt: string;    ChrArray: array of TChr;    CCharIndex: Integer;    FrameCount: Integer;  public  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject);const  sflag = snd_Loop or snd_Async;begin  Caption := 'Rotating Scroll Text V1.0 Gigatron';  txt := '    GIGATRON PRESENTS ROTATING SCROLL TEXT MADE WITH LAZARUS FPC ON 5.5.2025  GREETINGS TO SAVAGE & TRONIC DESIGN & PARANOIMIA-ITALY   ...... SEE YOU BYE ............................';   CCharIndex := 0;  FrameCount := 0;  SetLength(ChrArray, 0);// reserve mem chrtab  BGRAVirtualScreen1.Align := alClient;  playsound('mbis.wav', 0, sflag); // monoend; procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);var  centerX, centerY, radius: Integer;  i: Integer;  x, y: Integer;begin  Bitmap.Fill(BGRA(0, 0, 0));   centerX := BGRAVirtualScreen1.Width div 2;  centerY := BGRAVirtualScreen1.Height div 2;  radius := 250;   bitmap.FontFullHeight := 72;  bitmap.FontName := 'Arial';  bitmap.FontStyle := [fsBold];   for i := Length(ChrArray) - 1 downto 0 do  begin    // Calcul de la position    x := centerX + Round(radius * Cos(ChrArray[i].Angle));    y := centerY + Round(radius * Sin(ChrArray[i].Angle));     bitmap.TextOut(x, y-30,   ChrArray[i].Char,   BGRA(255, 255, 255));    bitmap.TextOut(x+4, y-30, ChrArray[i].Char,   BGRA(0, 0, 255));  end;end; procedure TForm1.FormResize(Sender: TObject);begin  BGRAVirtualScreen1.Invalidate;end; procedure TForm1.Timer1Timer(Sender: TObject);var  i: Integer;  angleStep: Single;  newAngle: Single;  posfree: Boolean;  angleDiff: Single;  charAppearSpeed: Integer;  rotationSpeed: Single;  totalChr: Integer;  chrFullRotated: Single;begin   charAppearSpeed := 11;     // Frame chr space  rotationSpeed := 1.2 * Pi / 180;  totalchr := 60;         // max visible chr  angleStep := (2 * Pi) / totalChr;   // Add chr if  if (FrameCount mod charAppearSpeed = 0) and (CCharIndex < Length(txt) * 2) then  begin     posfree := False;    newAngle := 0; // Commence à l'angle 0     for i := 0 to Length(ChrArray) - 1 do    begin      angleDiff := Abs(ChrArray[i].Angle - newAngle);      if angleDiff < angleStep * 0.8 then // Marge de sécurité      begin        posfree := True;        Break;      end;    end;     if not posfree then    begin      SetLength(ChrArray, Length(ChrArray) + 1);      ChrArray[Length(ChrArray) - 1].Char := txt[(CCharIndex mod Length(txt)) + 1];      ChrArray[Length(ChrArray) - 1].Angle := newAngle;      ChrArray[Length(ChrArray) - 1].Rotations := 0;      ChrArray[Length(ChrArray) - 1].Age := 0;       Inc(CCharIndex);    end;  end;   for i := Length(ChrArray) - 1 downto 0 do  begin    ChrArray[i].Angle := ChrArray[i].Angle - rotationSpeed;    ChrArray[i].Age := ChrArray[i].Age + 1;     chrFullRotated := 2 * Pi - (40 * Pi / 180);     if Abs(ChrArray[i].Angle) >= chrFullRotated then    begin       if i < Length(ChrArray) - 1 then        ChrArray[i] := ChrArray[Length(ChrArray) - 1];      SetLength(ChrArray, Length(ChrArray) - 1);      Continue;    end;     if ChrArray[i].Angle <= -2 * Pi then    begin      ChrArray[i].Angle := ChrArray[i].Angle + 2 * Pi;      ChrArray[i].Rotations := ChrArray[i].Rotations + 1;    end;  end;   // Restart scroll txt  if (CCharIndex >= Length(txt)) and (Length(ChrArray) = 0) then    CCharIndex := 0;   Inc(FrameCount);  BGRAVirtualScreen1.RedrawBitmap;end; end. ---------------------------------------------------------------------- cdbc · 2025-05-02 13:28 Hi Nope, d2010 is just trolling to waste your time! Sorry, completely forgot, your text is looking good =^ Regards Benny