Recent

Author Topic: Demo Scene Text Fx  (Read 3500 times)

Gigatron

  • Jr. Member
  • **
  • Posts: 78
  • Amiga Rulez !!
Re: Demo Scene Text Fx
« Reply #15 on: May 10, 2024, 04:57:51 pm »
So what is the result ? :)

Oh, it looks really cool!!!

This video needs to be added in #madewithinraylib on discord channel

https://discord.gg/raylib

Ok , let me just learn Raylib quickly i mean Faster than light ;  and improve the demo and then will post it to discord sure :)

Edit : Nice, do someting nice at 1500 times faster than light here ;

https://www.youtube.com/watch?v=qQUGzPRQhoM&t=42s


« Last Edit: May 10, 2024, 07:17:56 pm by Gigatron »
Sub Quantum Technology ! We are in a micro universe.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Demo Scene Text Fx
« Reply #16 on: May 10, 2024, 06:34:00 pm »
https://discord.gg/raylib
I was very happy to read about Discord server but a little disappointed on arrival :D
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Gigatron

  • Jr. Member
  • **
  • Posts: 78
  • Amiga Rulez !!
Re: Demo Scene Text Fx
« Reply #17 on: May 23, 2024, 07:03:04 pm »
Hi, just made another intro using BGRA component;


Raylib version is different : https://www.youtube.com/watch?v=dfoDfmjd1x8



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, BGRACanvas2D, Math;
  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.   private
  22.  
  23.   public
  24.   procedure drawStar(ctx: TBGRACanvas2D;cx, cy, spikes : integer; outerRadius, innerRadius, rotation : single;style : TBGRAPixel);
  25.    procedure reset;
  26.   end;
  27.  
  28. var
  29.   Form1: TForm1;
  30.   rt : double;
  31.   x_pos,y_pos : integer;
  32.  
  33.   // txt
  34.   x,y,i,j,g_timer,speed  : integer;  // general demo timer
  35.   tx: Array[0..12]  Of String =('+******************+',
  36.                                 '*    GIGATRON      *',
  37.                                 '*                  *',
  38.                                 '*PRESENTS TEXT FX#5*',
  39.                                 '*                  *',
  40.                                 '*  BGRA COMPONENT  *',
  41.                                 '*                  *',
  42.                                 '*@LAZARUS FPC RULEZ*',
  43.                                  '********************',
  44.                                 '*SFX : TDK         *',
  45.                                 '*FONT: DOUGHNUT    *',
  46.                                 '*CODE: GIGATRON    *',
  47.                                 '+******************+');
  48.   dest_y :Array[0..12]  Of integer;
  49.  
  50. implementation
  51.  
  52. {$R *.lfm}
  53.  
  54. { TForm1 }
  55.  
  56. procedure Tform1.DrawStar(ctx: TBGRACanvas2D; cx, cy, spikes: Integer; outerRadius, innerRadius, rotation: single;style : TBGRAPixel);
  57. var
  58.   rot, step, x, y: single;
  59.   i: Integer;
  60. begin
  61.   rot := Pi / 2 * 3 + rotation;
  62.   step := Pi / spikes;
  63.  
  64.   ctx.BeginPath;
  65.   x := cx + cos(rot) * outerRadius;
  66.   y := cy + sin(rot) * outerRadius;
  67.   ctx.MoveTo(x, y);
  68.  
  69.   for i := 0 to spikes - 1 do
  70.   begin
  71.     x := cx + cos(rot) * outerRadius;
  72.     y := cy + sin(rot) * outerRadius;
  73.     ctx.LineTo(x, y);
  74.     rot := rot + step;
  75.     x := cx + cos(rot) * innerRadius;
  76.     y := cy + sin(rot) * innerRadius;
  77.     ctx.LineTo(x, y);
  78.     rot := rot + step;
  79.   end;
  80.  
  81.   x := cx + cos(rot) * outerRadius;
  82.   y := cy + sin(rot) * outerRadius;
  83.   ctx.LineTo(x, y);
  84.   ctx.ClosePath;
  85.  
  86.   ctx.LineWidth := 50;
  87.   ctx.strokeStyle(style);
  88.   ctx.Stroke;
  89.   ctx.fillStyle ('rgba(0,0,0,0)');;
  90.   ctx.Fill;
  91. end;
  92.  
  93. procedure TForm1.FormCreate(Sender: TObject);
  94. begin
  95.   rt := 0.0;
  96.   x_pos :=160;
  97.   y_pos :=50;
  98.  
  99.      x:=10; y:=0; i :=0; j :=0; speed := 40; // speed of fx
  100.      for i:=0 to 12 do
  101.      begin
  102.      dest_y[i] := 800  ; // set ypos for each lines
  103.      end;
  104.      sleep(5000);
  105. end;
  106. procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  107. var
  108.   ctx: TBGRACanvas2D;
  109. begin
  110.   ctx := Bitmap.Canvas2D;
  111.   bitmap.FontName:='AmigaDigital8';
  112.   bitmap.FontHeight := 40;
  113.   bitmap.FontAntialias := false;
  114.  
  115.   drawStar(ctx, x_pos+200,y_pos+210, 7, 110.0, 170.0, rt,BGRA(44,55,66));
  116.   drawStar(ctx, x_pos+210,y_pos+220, 7, 110.0, 170.0, rt,BGRA(66,77,88));
  117.   drawStar(ctx, x_pos+220,y_pos+225, 7, 110.0, 170.0, rt,BGRA(77,88,99));
  118.   /// Txt
  119.   for j := 0 to  Min((g_timer div speed), High(tx)) do
  120.   begin
  121.     if g_timer > (j * speed) then
  122.     begin
  123.       for i := 0 to 1 do
  124.       begin
  125.         Bitmap.TextOut(x , dest_y[j] + 6, tx[j], BGRA(68, 85, 102));
  126.         Bitmap.TextOut(x , dest_y[j],     tx[j], BGRA(255, 255, 255));
  127.         dest_y[j] := dest_y[j] - 8;
  128.         if dest_y[j] < (j * 32) then dest_y[j] := j * 32;
  129.       end;
  130.     end;
  131.   end;
  132. end;
  133.  
  134. procedure TForm1.Timer1Timer(Sender: TObject);
  135. begin
  136.          rt := rt + 0.02;
  137.          inc(g_timer);
  138.          if(g_timer>800) then
  139.          begin
  140.           g_timer :=0;
  141.           BGRAVirtualScreen1.Invalidate;
  142.           reset;
  143.         end;
  144.         BGRAVirtualScreen1.RedrawBitmap;
  145. end;
  146.  
  147. procedure TForm1.reset();
  148. begin
  149.     i:=0;
  150.     for i:=0 to 12 do
  151.      begin
  152.        dest_y[i] := 800  ;
  153.      end;
  154. end;
  155.  
  156. end.
  157.  


« Last Edit: May 23, 2024, 07:09:23 pm by Gigatron »
Sub Quantum Technology ! We are in a micro universe.

Gigatron

  • Jr. Member
  • **
  • Posts: 78
  • Amiga Rulez !!
Re: Demo Scene Text Fx
« Reply #18 on: June 19, 2024, 07:38:38 pm »
Hi,
Here is another cool text fx, this one bounce each chars of your text from top to bottom and stop !

The javascript live version here :

http://gigatron3k.free.fr/laz/bounce.html

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.   private
  22.   Positions: array of record
  23.       y: Integer;     // yposition for each chars !
  24.       vy: Single;     // yposition speed
  25.     end;
  26.     g: Single;   // gravity
  27.     groundLevel: Integer;
  28.  
  29.   public
  30.  
  31.   end;
  32.  
  33. var
  34.   Form1: TForm1;
  35.   Texte : String = 'GIGATRON PRESENTS';    // text
  36.  
  37. implementation
  38.  
  39. {$R *.lfm}
  40.  
  41. { TForm1 }
  42.  
  43. procedure TForm1.FormCreate(Sender: TObject);
  44. var
  45.   i: Integer;
  46. begin
  47.   SetLength(Positions, Length(Texte));
  48.   g := 0.3;
  49.   groundLevel := 500;
  50.   // fill table y and vy for each char !
  51.   for i := 0 to High(Positions) do
  52.   begin
  53.     Positions[i].y := -140 - i * 40;
  54.     Positions[i].vy := 0;
  55.   end;
  56.  
  57. end;
  58.  
  59. procedure TForm1.Timer1Timer(Sender: TObject);
  60. var
  61.   i: Integer;
  62. begin
  63.   for i := 0 to High(Positions) do
  64.   begin
  65.     Positions[i].vy := Positions[i].vy + Frac(g);
  66.     Positions[i].y := Positions[i].y + Round(Positions[i].vy);
  67.  
  68.     if Positions[i].y > groundLevel then
  69.     begin
  70.       Positions[i].y := groundLevel;
  71.       Positions[i].vy := Positions[i].vy * Frac(-0.8);
  72.     end;
  73.   end;
  74.    BGRAVirtualScreen1.RedrawBitmap;
  75. end;
  76.  
  77. procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  78. var
  79.     i,x, y: Integer;
  80. begin
  81.  
  82.   Bitmap.FontName := 'AmigaDigital8';  // your ttf font
  83.   Bitmap.FontHeight := 80;
  84.  
  85.   for i := 1 to Length(Texte) do
  86.   begin
  87.     x := 60 + (i - 1) * 40; // space between char * 40
  88.     y := Positions[i - 1].y;
  89.     Bitmap.TextOut(x+2, y+4, Texte[i],BGRA(105,105,105));
  90.     Bitmap.TextOut(x, y, Texte[i],BGRA(255,255,255));
  91.   end;
  92. end;
  93.  
  94. end.
  95.  
« Last Edit: June 19, 2024, 08:53:46 pm by Gigatron »
Sub Quantum Technology ! We are in a micro universe.

 

TinyPortal © 2005-2018