Recent

Author Topic: JellyFish(raylib)  (Read 2064 times)

Guva

  • Full Member
  • ***
  • Posts: 204
  • 🌈 ZX-Spectrum !!!
JellyFish(raylib)
« on: July 25, 2025, 02:31:15 pm »
Code translation from Oberon and Python.
https://community.wolfram.com/groups/-/m/t/3516580
https://github.com/mebriki/MathPyLab/blob/main/jellyfish/jellyfish.ipynb

Code: Pascal  [Select][+][-]
  1. program AnimatedPoints;
  2.  
  3. uses
  4.   Raylib, Math;
  5.  
  6. const NUM_POINTS = 10000;
  7.  
  8. var
  9.   t: Single = 0.0;
  10.   Points: array of TVector2;
  11.  
  12. procedure CalculatePoint(x, y, t: Single; var px, py: Single);
  13. var
  14.   k, d, e, c, q: Single;
  15. begin
  16.   k := (4.0 + Sin(x / 11.0 + t * 8.0)) * Cos(x / 14.0);
  17.   e := y / 8.0 - 19.0;
  18.   d := Sqrt(k * k + e * e) + Sin(y / 9.0 + t * 2.0);
  19.   c := d * d / 49.0 - t;
  20.   q := 2.0 * Sin(k * 2.0) + Sin(y / 17.0) * k * (9.0 + 2.0 * Sin(y - d * 3.0));
  21.   px := q + 50.0 * Cos(c) + 200.0;
  22.   py := q * Sin(c) + d * 39.0 - 440.0;
  23. end;
  24.  
  25. procedure Setup;
  26. begin
  27.   InitWindow(800, 800, 'Animated Points');
  28.   SetTargetFPS(60);
  29.   SetLength(Points, NUM_POINTS);
  30. end;
  31.  
  32. procedure UpdateJellyPoints;
  33. var
  34.   x, y, k, e, d0, d, angle, q, c: Single;
  35.   i: integer;
  36. begin
  37.   t := t + 0.01;
  38.   for i := 0 to NUM_POINTS - 1 do
  39.   begin
  40.     x := i;
  41.     y := i / 41.0;
  42.  
  43.     k := 5 * Cos(x/19) * Cos(y/30);
  44.     e := y/8 - 12;
  45.     d0 := Sqrt(k*k + e*e);
  46.     d := (d0*d0)/59 + 2;
  47.  
  48.     angle := ArcTan2(k, e);
  49.     q := (4 * Sin(angle * 9) + 9 * Sin(d - t) -
  50.          (k/d) * (9 + 3*Sin(d*9 - t*16)));
  51.     c := (d*d)/7 - t;
  52.  
  53.     Points[i].x := (q + 50*Cos(c)) * 2 + 800/2;
  54.     Points[i].y := (q*Sin(c) + d*45) * 2;
  55.   end;
  56. end;
  57.  
  58. procedure DrawFrame;
  59. var
  60.   i: Integer;
  61.   px, py: Single;
  62. begin
  63.   px := 0; py := 0;
  64.   t := t + Pi / 240.0;
  65.   ClearBackground(BLACK);
  66.   for i := 0 to 9999 do
  67.   begin
  68.     CalculatePoint(i, i / 235.0, t, px, py);
  69.     DrawPixel(Round(px), Round(py), RayWhite );
  70.   end;
  71.   UpdateJellyPoints;
  72.   for i := 0 to NUM_POINTS - 1 do DrawPixelV(Points[i], WHITE);
  73. end;
  74.  
  75. begin
  76.   Setup;
  77.   while not WindowShouldClose do
  78.   begin
  79.     BeginDrawing;
  80.       DrawFrame;
  81.     EndDrawing;
  82.   end;
  83.   CloseWindow;
  84. end.
  85.  

Fred vS

  • Hero Member
  • *****
  • Posts: 3734
    • StrumPract is the musicians best friend
Re: JellyFish(raylib)
« Reply #1 on: July 25, 2025, 03:15:34 pm »
Code translation from Oberon and Python.
https://community.wolfram.com/groups/-/m/t/3516580
https://github.com/mebriki/MathPyLab/blob/main/jellyfish/jellyfish.ipynb

WOOOW!  ;D

In your program code:
Code: Pascal  [Select][+][-]
  1. program AnimatedPoints;
  2.  
  3. uses
  4.   Raylib, Math;
  5.  

You only added Raylib in the "uses" section, and no LCL interface is used.
On your site https://github.com/GuvaCode, I only see packages for Lazarus.
Where is the necessary Raylib.pas file located?
« Last Edit: July 25, 2025, 03:20:24 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Guva

  • Full Member
  • ***
  • Posts: 204
  • 🌈 ZX-Spectrum !!!
Re: JellyFish(raylib)
« Reply #2 on: July 25, 2025, 03:19:50 pm »
You only added Raylib in uses section and no LCL interface is used.
In your site https://github.com/GuvaCode I see only packages for Lazarus.
Where is that Raylib.pas that is needed?
https://github.com/GuvaCode/ray4laz/blob/main/source/raylib.pas

Fred vS

  • Hero Member
  • *****
  • Posts: 3734
    • StrumPract is the musicians best friend
Re: JellyFish(raylib)
« Reply #3 on: July 25, 2025, 03:21:16 pm »
You only added Raylib in uses section and no LCL interface is used.
In your site https://github.com/GuvaCode I see only packages for Lazarus.
Where is that Raylib.pas that is needed?
https://github.com/GuvaCode/ray4laz/blob/main/source/raylib.pas

Perfect, thanks and wooow again.
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 3734
    • StrumPract is the musicians best friend
Re: JellyFish(raylib)
« Reply #4 on: July 25, 2025, 03:33:33 pm »
Maybe, for this summer, change this:

Code: Pascal  [Select][+][-]
  1.   {$IFDEF LINUX} 'libraylib.so'; {$IFEND}
  2.   {$IFDEF DARWIN} 'libraylib.dylib'; {$IFEND}
  3.   {$IFDEF HAIKU} 'libraylib.so'; {$IFEND}

with this:

Code: Pascal  [Select][+][-]
  1.   {$IFDEF UNIX}
  2.   {$IFDEF DARWIN} 'libraylib.dylib';
  3.   {$ELSE} 'libraylib.so'; {$IFEND}  // for Linux, FreeBSD, NetBSD, OpenBSD, DragonFly, Haiku
  4.   {$IFEND}

 ;)
« Last Edit: July 25, 2025, 03:35:14 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Guva

  • Full Member
  • ***
  • Posts: 204
  • 🌈 ZX-Spectrum !!!
Re: JellyFish(raylib)
« Reply #5 on: July 25, 2025, 03:44:50 pm »
Maybe, for this summer, change this:

Code: Pascal  [Select][+][-]
  1.   {$IFDEF LINUX} 'libraylib.so'; {$IFEND}
  2.   {$IFDEF DARWIN} 'libraylib.dylib'; {$IFEND}
  3.   {$IFDEF HAIKU} 'libraylib.so'; {$IFEND}

with this:

Code: Pascal  [Select][+][-]
  1.   {$IFDEF UNIX}
  2.   {$IFDEF DARWIN} 'libraylib.dylib';
  3.   {$ELSE} 'libraylib.so'; {$IFEND}  // for Linux, FreeBSD, NetBSD, OpenBSD, DragonFly, Haiku
  4.   {$IFEND}

 ;)

Oh, yes, I did. Tnx

Fred vS

  • Hero Member
  • *****
  • Posts: 3734
    • StrumPract is the musicians best friend
Re: JellyFish(raylib)
« Reply #6 on: July 25, 2025, 03:59:59 pm »
Oh, yes, I did. Tnx

I will try this end of summer to build + test RayLib on FreeBSD 64/32, NetBSD 64, OpenBSD 64/32 and Mac OSX + XQuartz, if you want I can give you the binaries of the libs.
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Guva

  • Full Member
  • ***
  • Posts: 204
  • 🌈 ZX-Spectrum !!!
Re: JellyFish(raylib)
« Reply #7 on: July 25, 2025, 04:06:55 pm »
I will try this end of summer to build + test RayLib on FreeBSD 64/32, NetBSD 64, OpenBSD 64/32 and Mac OSX + XQuartz, if you want I can give you the binaries of the libs.
Oh, that would be wonderful.

Fred vS

  • Hero Member
  • *****
  • Posts: 3734
    • StrumPract is the musicians best friend
Re: JellyFish(raylib)
« Reply #8 on: July 29, 2025, 08:57:32 pm »
Oh, that would be wonderful.

ray4laz is wonderful too on FreeBSD, OpenBSD and NetBSD.  ;)
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

 

TinyPortal © 2005-2018