Buddhabrot fractal: Got the Correct Shape lazarus / 39-Graphics ---------------------------------------------------------------------- Boleeman · 2024-06-01 09:51 Tried making a Buddhabrot fractal. Now getting the expected full Buddhabrot fractal shape. ---------------------------------------------------------------------- TRon · 2024-06-01 23:13 Hi Boleeman. If you take a know outcome then you are able to compare. So, that is what I did  and can be seen in the picture named original. The picture itself is also a tell-tale sign as of what seem to be going wrong. Then, taking a look at the code it becomes obvious. You assume that the rawimage data is one block of continues memory with exactly the width and height of the image and top of that assuming that each 'position' is layout as a rgbtripple. Those are wrong assumptions. You are not allowed to assume anything about the layout in memory of a image except when it is explicitly designed to do so (such as BGRABitmap) If you fall back to something more robust such as 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 BrotBitmap.Canvas.DrawPixel(x,y, colour);  Where colour is of type TFPColor or 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   BrotBitmap.Canvas.Pixels(x,y) := colour; where colour is of type TColor ... then things are taking shape such as can been seen in the image fixed. ---------------------------------------------------------------------- Boleeman · 2024-06-02 03:17 Thanks TRon for that advice. Finally got it working with: 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  procedure TForm1.DisplayBrot(wid, hgt, max_r, max_g, max_b: Integer;  hit_r, hit_g, hit_b: TIntegerDynArray2D);var  x, y, r, g, b: Integer;  scale_r, scale_g, scale_b: Double;  pixelColor: TColor;begin  BrotBitmap.SetSize(wid, hgt);   if max_r = 0 then    max_r := 1;  if max_g = 0 then    max_g := 1;  if max_b = 0 then    max_b := 1;   scale_r := 255 * 2.5 / max_r;  scale_g := 255 * 2.5 / max_g;  scale_b := 255 * 2.5 / max_b;   BrotBitmap.Canvas.Lock;  try    for y := 0 to hgt - 1 do    begin      for x := 0 to wid - 1 do      begin        r := Round(hit_r[x, y] * scale_r);        if r > 255 then          r := 255;        g := Round(hit_g[x, y] * scale_g);        if g > 255 then          g := 255;        b := Round(hit_b[x, y] * scale_b);        if b > 255 then          b := 255;         pixelColor := RGBToColor(r, g, b);        BrotBitmap.Canvas.Pixels[x, y] := pixelColor;      end;    end;  finally    BrotBitmap.Canvas.Unlock;  end;   PaintBox1.Invalidate;end; ---------------------------------------------------------------------- Boleeman · 2024-06-02 03:30 Just wondering how to get that "Mystical Glow Effect" ? Would BGRAbmp be better to use to get that Glow Effect? ---------------------------------------------------------------------- TRon · 2024-06-02 04:06 BGRABitmap would not help in that regards. It is the color mapping method used when generating the fractal that is responsible for what colors are used to draw/generate the image. Is the original program able to produce this 'glow' image ? If so then you need to know the parameters used but as far as my knowledge on the buddha fractal goes there are several ways to implement the color mapping and the code as shown does not seem to support generating such 'glow' images. Perhaps someone more knowledgeable on the subject is able to provide more information. ---------------------------------------------------------------------- Boleeman · 2024-06-02 04:28 Thanks TRon for your reply. I tried the Glow Effect with BGRABmp and got a dramatic Rendering speed improvement. About 17 seconds for rendering with fast Gausian Blur on my slow AMD Dell A9 computer. Can't believe how fast it rendered. I think a number of people have developed different rendering methods for the Buddhabrot. Melinda Green discusses The Buddhabrot Technique here: https://superliminal.com/fractals/bbrot/ For that glow effect the website said: For my color Buddhabrot images the three different threshold values are analogous to the different frequencies of light which NASA combined into their beautiful false-color images. Color Buddhabrot For this image I used threshold values of 500, 5000, and 50000, and assigned them to the blue, green, and red channels respectively because this mapping generates images that most resemble the nebula images. I tried those values in the Lazzed BgraBmp version, but was not seeing that "White Glow" effect. Probably a bit more to the rendering. The site goes on to say: Still later while exploring different ways to sample and project these sorts of images, one really surprising thing happened: In one particular rendering projected onto one of the six major planes an image of the logistic map simply popped out! (There are 6 major planes in 4D just like the 3 in 3D.) This had me puzzled for years until 2009 when Taneli Hautaniemi also found it and contacted me. In 2010, Piet en Gilberte then stepped in and made a beautiful animation showing the relationship and added it along with explaination to the Buddhabrot page on Wikipedia. Alex Boswell found an almost magical way to vastly speed the rendering of highly zoomed regions. Six major planes an image. Would like to see that. Actually found a link to the Animated Buddabrot: The Buddhabrot Fractal in 4K https://www.youtube.com/watch?v=zxIcydL7wwY The Buddhabrot converges back to a Mandelbrot then diverges again. Wow ! ---------------------------------------------------------------------- Boleeman · 2024-06-02 05:18 This page has a great discussion: https://benedikt- bitterli.me/buddhabrot/ Download this animation (383 kB in size). https://benedikt-bitterli.me/buddhabrot/images/transform.mp4 Just so Awesome to watch. ---------------------------------------------------------------------- Dzandaa · 2024-06-02 10:38 Hi, Just for the fun I changed: 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 procedure TForm1.DisplayBrot(wid, hgt, max_r, max_g, max_b: Integer;  hit_r, hit_g, hit_b: TIntegerDynArray2D);var  x, y, r, g, b: Integer;  scale_r, scale_g, scale_b, Fact: Double;//  pixelColor: TBGRAPixel;  glowBmp: TBGRABitmap;begin  BrotBitmap.SetSize(wid, hgt);   Fact := 255 * 2.5;  if max_r = 0 then    max_r := 1;  if max_g = 0 then    max_g := 1;  if max_b = 0 then    max_b := 1;  scale_r := Fact / max_r;  scale_g := Fact / max_g;  scale_b := Fact / max_b;   {  scale_r := 255 * 2.5 / max_r;  scale_g := 255 * 2.5 / max_g;  scale_b := 255 * 2.5 / max_b;  }   BrotBitmap.Fill(BGRA(0, 0, 0, 0));   for y := 0 to Pred(hgt) do  begin    for x := 0 to Pred(wid) do    begin    r := Round(hit_r[x, y] * scale_r) and $ff; //     if r > 255 then //     r := 255;      g := Round(hit_g[x, y] * scale_g) and $ff; //     if g > 255 then //       g := 255;      b := Round(hit_b[x, y] * scale_b) and $ff; //     if b > 255 then //       b := 255; //      pixelColor := BGRA(r, g, b);//      BrotBitmap.SetPixel(x, y, pixelColor);       BrotBitmap.SetPixel(x, y, BGRA(r, g, b));    end;  end;   glowBmp := BrotBitmap.FilterBlurRadial(10, rbFast);  BrotBitmap.PutImage(0, 0, glowBmp, dmDrawWithTransparency);   glowBmp.Free;   PaintBox1.Invalidate;end;                                           And 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 procedure TForm1.FormDestroy(Sender: TObject);begin if(BrotBitmap <> nil) then BrotBitmap.Destroy;end;   To gain a little speed and free memory. Great job, Boleeman B-> ---------------------------------------------------------------------- Dzandaa · 2024-06-02 16:16 Hi, Same version but with a resizable TImage. Have fun with Budha B-> ---------------------------------------------------------------------- Boleeman · 2024-06-03 02:22 DZandaa. I checked the forum and got nice surprise. Much appreciated for the Buddhabrot updates. I took a day off work myself, due to a head cold/virus. I work at a college where there are some students and teachers sick at various times. Nice to hear from you Dzandaa. Was not sure if something may have happened? Anyhow, looks like everything is OK. On Github, there are many different versions of the Buddhabrot with different ways of making it so I might look into some of those more interesting methods. Would love to work out how they rendered the Buddhabrot Curve to make that great animation that morphs between the Buddhabrot Curve and the Mandelbrot Curve. Just realized I mistakenly left some TEdit in the code from the VB6 code I was using to convert to Lazarus, so please delete as not needed:     txtWidth: TEdit;     txtHeight: TEdit;     txtRedCutoff: TEdit;     txtGreenCutoff: TEdit;     txtBlueCutoff: TEdit;     txtStopAfter: TEdit;     txtDrawEvery: TEdit; I noticed that the end result Buddhabrot curve differs slightly each time due to Randomize being used. Not sure if you can help out with the Trouchet Curve at https://forum.lazarus.freepascal.org/index.php/topic,67394.0.html. Can't work out why it is not rendering correctly. DZandaa, cheers for now. So glad for your updates and for your reply. "May the Buddha be with you" ---------------------------------------------------------------------- Dzandaa · 2024-06-03 13:15 Hi, @Boleeman I modified the Truchet Curve. Have a nice day. B-> ---------------------------------------------------------------------- Boleeman · 2024-06-03 20:01 Found a free Photoshop plugin that makes nice Buddhabrot fractals at: https://richardrosenman.com/shop/buddhabrot/