Random SnowFlakes: lazarus / 39-Graphics ---------------------------------------------------------------------- Boleeman · 2024-11-30 07:14 Hi All. I have found a nice random Javascript snowflake generator that uses svg elements to generate random snowflake curves. It is in a html file and is only one line long. 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 I tried to convert to Lazarus using a TBgrabmp, but all I see is dots. Is it possible to use svg in TBgrabmp to draw the random snowflakes correctly? Can't seem to work out how to render the curve correctly so that it looks like a snowflake. Must have something to do with the svg graphics ? ---------------------------------------------------------------------- Boleeman · 2024-11-30 07:37 Somehow need to work out how to render svg in Lazarus ? ---------------------------------------------------------------------- Dzandaa · 2024-11-30 10:25 Hi @Boleeman: In BGRAControls, there is a TBCSVGViewer Create your SVG code in a string and put it in TBCSVGViewer.SVGString B-> ---------------------------------------------------------------------- Roland57 · 2024-12-01 15:39 Hi. I don't know the answer to your question, but here are my snowflakes using Cairo.  https://forum.lazarus.freepascal.org/index.php/topic,57657.msg428979.h tml#msg428979 ---------------------------------------------------------------------- Boleeman · 2024-12-02 04:08 Sorry about the late reply: Been a bit crook lately with a bug. Thanks Dzandaa and Roland57 for your replies about snowflakes. Roland57: Compiled your Cairo Snowflake Lazarus source after downloading GTK from http://downloads.sourceforge.net/gladewin32/gtk-2.12.9-win32-2.exe I tried installing GTK3 runtime but was getting an error after compiling the Cairo snowflake code.. Also remembered seeing a few interesting cpp and CSharp snowflake examples on Codeproject ages ago. Went to the Codeproject site yesterday and it looks like it has gone by way of the DODO .... Shutdown. I compiled a CSharp Xmas Snowflakes code, but the flakes seem quite ordinary. There was another Codeproject example that had some intricate random snowflakes but I can't find where I put it. ---------------------------------------------------------------------- Laksen · 2024-12-02 06:17 That's some well obfuscated code... I think, minus the antialiasing and stuff this gets close 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.GenerateSnowflake(BgraBitmap: TBGRABitmap);var  Y, i, ii: integer;  j: integer;  a, c, s: double;   function CC(X: double): double;  var    lx, ly: Int64;  begin    lx:=round(70+x);    ly:=round(s*j+c*y+70);    BgraBitmap.FillRect(lx, ly,lx+1, ly+1, BGRA(0, 0, 0), dmSet);    result:=X;  end;begin  I := 0;  for Y := 0 to 69 do  begin    for ii := 12 downto 0 do    begin      j := ifthen(ii > 5,I,0);       a := PI/3*ii;      c := Cos(a);      s := Sin(a);      CC(-CC(c*j-s*Y));    end;     I:=(trunc(random()-1.9) and (I+1));  end;end; ---------------------------------------------------------------------- Boleeman · 2024-12-02 07:46 Laksen, that's fantastic. Got the thickness working and Multiple Flakes. I wonder if we could possibly smooth the flakes a bit ? Made a small update: Realized that some curves were not that random, so put Randomize in the form's OnCreate. ---------------------------------------------------------------------- Boleeman · 2024-12-02 08:05 I tried applying a Blur filter from TBgrabmp. A bit slower on the rendering now. Would be nice if we could make the lines SVG. What else could we possibly try to make the lines look smoother? ---------------------------------------------------------------------- Thaddy · 2024-12-02 09:37 I had to invert the colours to obtain snowflakes.... ---------------------------------------------------------------------- Boleeman · 2024-12-02 10:26 Great idea Thaddy. White Snowflakes on a black background ! ---------------------------------------------------------------------- Boleeman · 2024-12-02 11:24 Render to a TBgrabmp control. ---------------------------------------------------------------------- Boleeman · 2024-12-03 08:01 Sort of feeling like I need to start looking into fpVectorial to create some vector (svg) curves. Javascript does svg well, but would like to look at Lazarus methods to do vector graphics. ---------------------------------------------------------------------- zamtmn · 2024-12-03 08:23 On topic of the upcoming holidays - it will be useful https://habr.com/ru/articles/246895/ ---------------------------------------------------------------------- Boleeman · 2024-12-03 20:07 Thanks zamtmn for that interesting Snowflake Maker information. And with Lazarus source. I also came across a Snowflake Generator Webpage which does snowflakes as well. The page saved OK so I can run it on my computer without connecting to the Net. Might try to make something similar in Lazarus. Late 2 png attachments: Compiled the program from zamtmn's "snowflaker" site suggestion and tested it out. It uses Bezier type curves. Takes a bit of getting used to, but has real unique curve potential. COOL ! Thanks zamtmn. ---------------------------------------------------------------------- Boleeman · 2025-01-10 05:34 Found a nicely rendered Snowflake Maker (but it for paying customers). The flakes look so realistic. https://www.incendia.net/wiki/index.php?title=Snowflake_Generator https://www.incendia.net/snowflake.php I am drooling looking at the fine details in the rendered flakes. Would be nice to make something like this in Lazarus.