Circle Fractal: Many Cool Additions Added by Josh lazarus / 39-Graphics ---------------------------------------------------------------------- Boleeman · 2024-02-25 12:35 Go to the 2nd page to get to play around with the Phong Version. The Lazarus beginning of a circle fractal program. Converted from my VB6 code at https://github.com/BoleeMan/Circle- Fractal Lazarus version not as colorful as the vb6 version yet. Here is what I have so far: ---------------------------------------------------------------------- VisualLab · 2024-02-25 14:13 Quote from: Boleeman on February 25, 2024, 01:35:25 pmThe Lazarus beginning of a circle fractal program. Converted from my VB6 code at https://github.com/BoleeMan/Circle- Fractal Lazarus version not as colorful as the vb6 version yet. Also don't know why it is not showing on form create. Here is what I have so far: Very nice patterns. ---------------------------------------------------------------------- Josh · 2024-02-25 14:23 add a bgrabitmap buffer image,convert to bgracanvas, and a few color changes and you get ---------------------------------------------------------------------- Dzandaa · 2024-02-25 15:08 Hi, I did a quick Code based on yours: B-> ---------------------------------------------------------------------- Boleeman · 2024-02-26 01:55 Dzandaa, I like the way yours resizes nicely. Very slick. BTW, why is the memo there? To alter the number of circles to eight circles, we need to adjust this (so loop to 8 and make Pi/4 of which the divisor is half of eight   )     DrawPanel.Canvas.Ellipse(X - R, Y - R, X + R, Y + R);     for int1 := 1 to 8 do       DrawCircle(Round(X + 2 * R * Cos((int1 - 1) * Pi / 4)),                  Round(Y + 2 * R * Sin((int1 - 1) * Pi / 4)),                  Round(R / 4.2), n - 1, k); So to alter the number of circles with a TSpinedit and adjust the distance of the circles from the center with TTrackbar: 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    for int1 := 1 to se_NumCircles.value do     RecursiveCircle(Round(X + (TrackBar1.Position / 100) * R * Cos((int1 - 1) * Pi / (0.5*se_NumCircles.value))),                    Round(Y + (TrackBar1.Position / 100) * R * Sin((int1 - 1) * Pi / (0.5*se_NumCircles.value))),                    Round(R / 4.2), n - 1, k); Josh, what I was aiming for was with another pattern in the center, as shown below. So I was thinking: How do I isolate just one of the intricate patterns, copy it to a temp buffer, resize it slightly and paste it transparently to the center?  Or Just include another in the center by altering the algorithm? ---------------------------------------------------------------------- Roland57 · 2024-02-26 05:59 Quote from: Boleeman on February 25, 2024, 01:35:25 pmHere is what I have so far: Here (on Linux) the window stays empty. Nothing is drawn.  By the way, you don't need to write Form1. in TForm1 methods. ---------------------------------------------------------------------- Boleeman · 2024-02-26 07:11 My newest one with the the TTrackbar and TSpinedit and some TCheckboxes on a TImage. First first picture: Trackbar set to 180, TSpinedit for Recursion level = 4 and TSpinedit for Number of circles set to 8 circles. For second picture: 7 circles and unfilled. Roland I had for i := 1 to 8 do     instead of for int1 := 1 to 8 do Also perhaps try Dzandaa's version, as he may have made that on Linux? ---------------------------------------------------------------------- Dzandaa · 2024-02-26 09:55 Hi, @Boleeman Concerning the memo: In you first version, I had the same problem as you with the display in Form.OnCreate. So I quickly rewrote it using one of my Templates that had a memo for Logs and I forgot to remove it. That's it:) B-> ---------------------------------------------------------------------- Roland57 · 2024-02-26 13:00 Quote from: Boleeman on February 26, 2024, 08:11:02 amAlso perhaps try Dzandaa's version, as he may have made that on Linux? Yes, that version works. ---------------------------------------------------------------------- lainz · 2024-02-26 15:29 Check this website, you will become crazy when the ammount of drawings they have: https://openprocessing.org/browse/# ---------------------------------------------------------------------- Dzandaa · 2024-02-26 17:48 Hi @lainz Thank you. I know Processing and I used it a long time ago to control Arduino's, but I didn't know that website. Processing: https://processing.org/ Cool language to test graphic programs. @Roland57 I write my Lazarus code on Windows 7 64bits Pro but also test it on Linux 64bits and sometimes Mac OS (and Windows 10, beuark!!!). B-> ---------------------------------------------------------------------- Josh · 2024-02-27 09:45 some ideas ---------------------------------------------------------------------- Boleeman · 2024-02-27 09:51 Dzandaa resizeable panel version with variable number of circles, radial position change and colours selection. Play around with the colours and slider position. Sorry put wrong update. Will check out your version Josh. ---------------------------------------------------------------------- Boleeman · 2024-02-27 10:16 Josh your effects are amazing. Really like the colour scheme and the random modes. The rotate feature  was also good to include, to adjust the fractal for different numbers of circles. For some reason on my Windows 10 the screen does not refresh initially (see second attached picture), but clicking show drawing refreshes it. Also noticed the random mode has repeated colours for the fills of the circles in level 2 of the fractal. What would be nice is some variable opacity so when the petals overlap there is a see through effect (like in the Pythagoras Tree in https://forum.lazarus.freepascal.org/index.php/topic,66256.15.html on the last page). Love how you make all of those variations. Really cool, with that Wow Factor. The first attached picture in my previous reply, also has some sort of pixelated border on the smallest circles. Not sure how to reproduce that feature, so that the border on the smallest circles is variegated/spikey. Is there a way to adjust the border type on an ellipse? Also now noticed that you used cb_CheckListBox. That's interesting. Never thought of using that instead of normal checkboxes. I wonder also if Phong shading could be implemented using bgraBmp to give a 3D effect to the fractal. Your sample has opened all sorts of possibilities. Man I feel like Christmas has come early. Love playing around with this sort of stuff. ---------------------------------------------------------------------- Josh · 2024-02-27 13:47 Opacity slider added changed the random color method ---------------------------------------------------------------------- Josh · 2024-02-27 15:23 forgot add fixed color change,  right click panel for menu. ---------------------------------------------------------------------- Boleeman · 2024-02-28 07:57 Josh, thanks for the updates. Apologies for disappearing yesterday, as I was feeling a bit off (badly sore ear). I looked at your two circle fractal updates and experimented. Tried changing the divisor slightly from R /4.2 to R/3.8. Some nice patterns happening. I also did a shape insertion in the middle of the circle fractal with a paint program, just to see the effect. Looking good. I especially like the color scheme generated circle fractal with R/3.8, with the bright smaller upper level petals. Your random colour mode with opacity now has a "jeweled like effect". Need to understand how you did that opacity with bgrabmp so will need to go over that:    if FillBackGround then bmp.EllipseAntialias(X, Y,R+RAdjust, R+RAdju st,ColorToBGRA(PenColor,tb_Opacity.Position),PenWidth,ColorToBGRA(Brus hColor,tb_Opacity.Position))    else bmp.EllipseAntialias(X, Y,R+RAdjust, R+RAdjust,ColorToBGRA(PenColor,tb_Opacity.Position),PenWidth); Dzandaa used  PictOrig := TBGRABitmap.Create(w, h, BGRAPixelTransparent);  and   PictOrig.FillPoly(Pt, Col, dmDrawWithTransparency, True); to do the fills. Wondering what the difference is? Also with the Pythagoras Tree here (https://forum.lazarus.freepascal.org/index.php/topic,66256.0.html) I used Luminance to filter out some of the colours (to make either dark or light random colours) 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 function GetLuminance(color: TColor): Double;var  r, g, b: Byte;begin  r := Red(color);  g := Green(color);  b := Blue(color);  Result := 0.2126 * r / 255 + 0.7152 * g / 255 + 0.0722 * b / 255;end; procedure TForm1.GenerateRandomColors;var  i: Integer;begin  SetLength(Colors, 20);  for i := 0 to High(Colors) do  begin    repeat      Colors[i] := RGBToColor(Random(256), Random(256), Random(256));    until GetLuminance(Colors[i]) > LumLimit;  end;end;   and also transitioning from one colour to another: 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.GenerateColorsBrowntoGreen;var  i: Integer;  BrownR, BrownG, BrownB: Byte;  GreenR, GreenG, GreenB: Byte;  BlendFactorFill, BlendFactorLine: Double;  MaxLevel: Integer;begin  BrownR := 101;  BrownG := 67;  BrownB := 33;   GreenR := 0;  GreenG := 128;  GreenB := 0;   MaxLevel := seRecursionLevel.Value;   SetLength(Colors, MaxLevel);  for i := 0 to MaxLevel - 1 do  begin    BlendFactorFill := i / (MaxLevel - 1);    Colors[i] := RGBToColor(      Round((1 - BlendFactorFill) * BrownR + BlendFactorFill * GreenR),      Round((1 - BlendFactorFill) * BrownG + BlendFactorFill * GreenG),      Round((1 - BlendFactorFill) * BrownB + BlendFactorFill * GreenB)    );     BlendFactorLine := i / (MaxLevel - 1);    Colors[i] := RGBToColor(    Round((1 - BlendFactorLine) * BrownR + BlendFactorLine * GreenR),    Round((1 - BlendFactorLine) * BrownG + BlendFactorLine * GreenG),    Round((1 - BlendFactorLine) * BrownB + BlendFactorLine * GreenB)    );  end;end;   Josh, Thanks for helping to add those great features and demonstrating how to use bgrabmp. I am still learning bgrabmp so your samples are really good for learning purposes. I always like looking at your work and how you do things (don't always fully understand it but progressively getting better), as well as Dzandaa's nice samples. ---------------------------------------------------------------------- Josh · 2024-02-28 09:56 moded to allow radius ratio adustment. ---------------------------------------------------------------------- Boleeman · 2024-02-28 20:03 Creating some brilliant Circle Fractals. with that addition of "a radial slider". The outer rings seem to join up well. Just thought of another feature with a radial gradient fill, so that the circles look a bit spherical (similar to Dzandaa's beaded Sunflower). ---------------------------------------------------------------------- Josh · 2024-02-29 01:04 added phong lighting option if you bring up the popup menu to adust colors, you have a extra option set light source.its set to wher you brought up the menu. ---------------------------------------------------------------------- Boleeman · 2024-02-29 06:04 "Phonging Fantastic" is all I can say. Now the Flower Fractals have almost a gilded-like leather appearance. Good idea with the extra option to set the light source. Brilliant Josh. ---------------------------------------------------------------------- Josh · 2024-02-29 07:58 Overlapping effect ---------------------------------------------------------------------- Boleeman · 2024-02-29 08:24 Hey Josh, I worked out how to put an extra outer curve in the center in the Dzandaa version. Also, I used a different way for the radial shift, but I think your way for radial shift achieves better results. 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.DrawCircle(X, Y, R: Integer; n: Integer; k: Single; isCenter: Boolean);var  int1: Integer;begin  if n < 1 then  begin    DrawPanel.Canvas.Pen.Color := clBlack;    DrawPanel.Canvas.Brush.Color := TColor($FF1493);    DrawPanel.Canvas.Pen.Width := 2;    DrawPanel.Canvas.Ellipse(X - R, Y - R, X + R, Y + R);  end  else  begin    DrawPanel.Canvas.Pen.Width := 3;    DrawPanel.Canvas.Pen.Color := cbBorderpencolor.ButtonColor;    DrawPanel.Canvas.Brush.Color := cbFillcolor.ButtonColor;    DrawPanel.Canvas.Ellipse(X - R, Y - R, X + R, Y + R);    for int1 := 1 to se_NumCircles.Value do      DrawCircle(        Round(X + (TrackBar1.Position / 100) * R * Cos((int1 - 1) * Pi / (0.5 * se_NumCircles.Value))),        Round(Y + (TrackBar1.Position / 100) * R * Sin((int1 - 1) * Pi / (0.5 * se_NumCircles.Value))),        Round(R / 3.8), n - 1, k, False);     // Check if an extra center circle should be drawn    if isCenter then      DrawCircle(X, Y, Round(R / 3.8), n - 1, k, False);  end;end;   That overlap version of yours looks good. Sort of marbles effect. ---------------------------------------------------------------------- Josh · 2024-02-29 10:22 ok ---------------------------------------------------------------------- Boleeman · 2024-02-29 13:52 With my trackbar1 change I sort of got some extra play with the movement of the outer circles, along with the other radial change that you did (by changing that 4/2 divisor with a trackbar). Attached is an image to explain.         Round(X + (TrackBar1.Position / 100) * R * Cos((int1 - 1) * Pi / (0.5 * se_NumCircles.Value))),         Round(Y + (TrackBar1.Position / 100) * R * Sin((int1 - 1) * Pi / (0.5 * se_NumCircles.Value))), With your latest update, I got some nice results, but the checkboxes were a bit out of sync with the image when selecting and unselecting. The image was not updating properly. After a while the problems sort of fixed themselves up (don't know why?) After a while I got these (especially like the red one): ---------------------------------------------------------------------- Boleeman · 2024-03-01 08:20 Just a little animation of some sample Circle Fractals. ---------------------------------------------------------------------- Boleeman · 2024-03-01 08:56 Just a version of the Circle Fractal (to share) that I made with bgrabmp based on Dzandaa's resizable Tpanel version. I added save to png (transparent and opaque background). Also has a radial sizing and radial displacement. Joshes' version has the Phong shading, with all the bells and whistles. ---------------------------------------------------------------------- Boleeman · 2024-03-01 11:43 One more effect that would be nice to implement would be changing the HUE. I did these in Paint.Net using the same png file. Would anyone know how to do this with Lazarus and a TSlider? ---------------------------------------------------------------------- Josh · 2024-03-01 15:41 added save png/save png transparent in popup menu last pic, cange pen color while drawing ---------------------------------------------------------------------- Josh · 2024-03-01 16:57 and some melting chocolate ---------------------------------------------------------------------- Boleeman · 2024-03-01 20:44 "Some melting chocolate" with triple blended Coffee. Next, melted cheese and extra oregano for a quick pizza snack. Just kidding. Looks great. The recording of the settings in the picture name was a great idea. The saving to png works fantastically. Josh, I could not get the Auto pen colour to work (I used the menu to select it and looked at the settings that you had used but somehow could not see any change). I ended up with a nice crystallized (almost sugary like) pattern by altering the opacity (shown below). ---------------------------------------------------------------------- Josh · 2024-03-02 12:57 Hi AutoPen Color would set the pen color to a value based on the brush color only when clicked changed this on final version, now if set pen color is changed whenever brush color is changed, ie in random or schemed mode.