GeoPattern: Thanks WP for the Lazzed BGRABmp version lazarus / 39-Graphics ---------------------------------------------------------------------- Boleeman · 2024-05-11 05:07 Hi All. I found a Github web site that has a program called GeoPattern, that makes nice png and svg geometric patterns. It has also been ported to many other languages (https://github.com/search?q=GeoPattern+&type=repositories&p=1). Converted to Lazarus by WP. Wow can't believe it. A GREAT MANY THANKS to WP for the conversion and also to TRon  for looking at it and gidesa and Thaddy for your replies. Produced some nice patterns. The extended version on GitHub has extra parameter controls.See attached pictures for what it is capable of making. Here are also the other ports: Rust version at (https://github.com/suyash/geopattern-rs) has some unusual patterns. JavaScript port by Brandon Mills: https://github.com/btmills/geopattern TypeScript port by MooYeol Lee: https://github.com/mooyoul/geo-pattern Python port by Bryan Veloso: https://github.com/bryanveloso/geopatterns Elixir port by Anne Johnson: https://github.com/annejohnson/geo_pattern PHP port by Anand Capur: https://github.com/redeyeventures/geopattern- php Go port by Pravendra Singh: https://github.com/pravj/geopattern CoffeeScript port by Aleks (muchweb): https://github.com/muchweb/geo- pattern-coffee Cocoa port by Matt Faluotico: https://github.com/mattfxyz/GeoPattern- Cocoa Middleman extension by @maxmeyer: https://github.com/fedux- org/middleman-geo_pattern Dart(Flutter) port by @suyash: https://github.com/suyash/geopattern Lua port by Ivan Azoyan: https://github.com/azoyan/geopattern Attached are some pics from the Lazarus port of this program. ---------------------------------------------------------------------- Thaddy · 2024-05-11 16:06 Well, as usual, if you have the formulae you can also do it in Pascal. ---------------------------------------------------------------------- gidesa · 2024-05-11 17:10 Quote from: Boleeman on May 11, 2024, 07:07:30 am I compiled the CSharp program to a DLL but was wondering how to use it in Lazarus to create the Geometric Patterns. Your DLL is a pure Dotnet one. That is, it doesn't export any API in C ("unmanaged") format, or in Activex/Com format. So it's unusable from FPC (or Delphi, too). ---------------------------------------------------------------------- Thaddy · 2024-05-11 19:54 There are actually bindings available. ---------------------------------------------------------------------- Boleeman · 2024-05-11 22:23 Thanks ALL for the replies. Some more samples from the WP Lazarus Port on Github. Once again, a BIG THANK YOU to WP for making the BGRABmp Lazarus port of this program (that saves to png and SVG). So Fantastic. Christmas has come early. ---------------------------------------------------------------------- gidesa · 2024-05-12 09:36 Quote from: Boleeman on May 12, 2024, 12:23:16 amThanks ALL for the replies. I don't know how to approach this one in Lazarus. Anyway I thought I would let people on the Lazarus Graphics forum know about it. Indeed there are Python-Lazarus/Delphi bindings, https://github.com/pyscripter/python4delphi. And Lua bindings, for example https://github.com/malcome/Lua4Lazarus. So, you can try to interface the Python or Lua library to Lazarus. Think that Lua is much more simple to install (a single Dll, versus many Dll and other files). And much faster, especially the LuaJit version. ---------------------------------------------------------------------- Thaddy · 2024-05-12 10:21 Give us the formulae... Then we write it in pure pascal. For such things no extra dll's etc are necessary. ---------------------------------------------------------------------- TRon · 2024-05-12 10:32 @Thaddy, I only had a brief encounter with the code but afaik they are all wrappers around SVG not using plot routines. SO you would actually would have to look at a svg implementation for FPC that support all those routines (or redo them in Pascal ofc). ---------------------------------------------------------------------- Thaddy · 2024-05-12 12:11 There are Pascal implementations for SVG. Do not know how complete they are. ---------------------------------------------------------------------- wp · 2024-05-12 22:39 Find in the attachment an attempt to convert some of the generators from the Lua version to Lazarus. I did not paint to svg but to a bitmap, and as a consequence there are some occasional rows of pixels at the tile boundaries which are not drawn due to rounding errors. Doing the project with BGRABitmap probably will avoid this since it supports fractional pixels, AFAIK. And I commented out the GenerateSineWave method because I did not want to spend the time to learn how the PolyBezier method works. Usage: Just type any text into the edit box. The TGeoPattern class calculates the SHA1 hash value of the entered string and determines pattern type, color and opacity from parts of the sha1 string. All the rest is just generation of an image of simple shapes which is tiled over the display area, a paintbox here. ---------------------------------------------------------------------- TRon · 2024-05-13 10:33 You are fast wp.... really fast.. I was still contemplating how to approach this, e.g. use fpvectorial, bgrasvg or re-create in Pascal (your approach) and that is even in case there isn't another SVG related (vector drawing) implementation that I am not aware of. Your speed is no match for someone ignorant to the subject trying to figure out what would be the best way ---------------------------------------------------------------------- wp · 2024-05-17 16:24 I extended the code a bit (converted to BGRABitmap, more patterns, save to png and svg, additional control via parameters) and put the application on my GitHub: https://github.com/wp- xyz/GeoPattern/tree/main ---------------------------------------------------------------------- Boleeman · 2024-05-18 04:34 WP.   The BGRABmp version on Github produces some really nice patterns (with varying opacity, color, styles).         Been playing around with the new version, making some COOL Patterns. The save to SVG is fantastic.         Also played around with the additional control via parameters (a great feature for controlling the colors).         Thank you for the new update. I came across a wavey pattern that had some semi-circles. Not sure why it happened, but thought I'd mention it (attached below). ---------------------------------------------------------------------- wp · 2024-05-18 10:30 Quote from: Boleeman on May 18, 2024, 06:34:50 amI came across a wavey pattern that had some semi-circles. Not sure why it happened, but thought I'd mention it (attached below). Please post the generator string that you use to create this pattern so that I can reproduce. ---------------------------------------------------------------------- Boleeman · 2024-05-18 17:48 Sorry WP but lost  the generator string. Perhaps I will add a save and reecall the generator string to Tlistbox feature, so I don't lose it next time. ---------------------------------------------------------------------- wp · 2024-05-18 19:15 I changed the factor which moves the sine wave up to fill the area of the negative excursion (sorry, hard to explain...) from 1.5 to 1.0, and the issue was solved for the critical generator string that I had found.