Recent

Author Topic: N-gram Star Patterns: With Save Settings  (Read 1015 times)

Boleeman

  • Hero Member
  • *****
  • Posts: 686
N-gram Star Patterns: With Save Settings
« on: August 16, 2024, 04:21:17 pm »
I tried to make a Star Pentagram ... and now have an N-Gram Star Pattern

Now With Save Settings


Star Pentagram and Other Recursive Curve Patterns

Please Go down to latest reply.

Star Pentagram fixed by RVK. Thankyou.

« Last Edit: August 17, 2024, 12:04:42 pm by Boleeman »

rvk

  • Hero Member
  • *****
  • Posts: 6399
Re: Star Pentagram: Line End Problems
« Reply #1 on: August 16, 2024, 04:36:38 pm »
You have a problem when recursing.

You do a ACanvas.LineTo inside the loop of 0 to 4 and expect the position to be correct in the next itteration.

But... when calling starpentagram inside the same loop, it can mess with the current position.
If you reset the position after the recursive call back to newX/newY, it will look better.

Code: Pascal  [Select][+][-]
  1.     if i = 0 then
  2.       ACanvas.MoveTo(Round(newX), Round(newY))
  3.     else
  4.       ACanvas.LineTo(Round(newX), Round(newY));
  5.  
  6.     // Draw the smaller star if the recursion level is less than the depth
  7.     if level < depth then
  8.     begin
  9.       starpentagram(level + 1, newX, newY, r * scale, ACanvas);
  10.       ACanvas.MoveTo(Round(newX), Round(newY)); // back to correct position
  11.     end;


Boleeman

  • Hero Member
  • *****
  • Posts: 686
Re: Star Pentagram: Line End Problems
« Reply #2 on: August 16, 2024, 06:50:54 pm »
RVK: A great many thanks for that fix.

I was going batty trying to try to fix that bug.

Added Save to Png and Back Colour selection.

Here is what I ended up with.

2nd attached png was filled manually in MsPaint.

Kinda really like the Black and White Level 5 third attached png, with the fine white lines.
« Last Edit: August 17, 2024, 02:25:11 am by Boleeman »

Boleeman

  • Hero Member
  • *****
  • Posts: 686
Re: Star Pentagram V2: Added Save to Png and Back Colour Select
« Reply #3 on: August 17, 2024, 03:19:58 am »
Wow. Extra Curve Fun

Now getting some extra interesting curves by changing the angle divisor, as well as the scale and the radius.

Even got the square fractal. Can't believe it.
« Last Edit: August 17, 2024, 08:00:54 am by Boleeman »

Boleeman

  • Hero Member
  • *****
  • Posts: 686
Re: Star Pentagram and Other Recursive Curve Patterns
« Reply #4 on: August 17, 2024, 07:34:58 am »
Made some changes to code (In particular, the angle)

Now beautifully rendering to Tbgrabmp, with anti-aliasing.

Able to make N-gram PolyStars, like pentagram, Hexagram, etc.  (see attached png)

Widened the range of values for the TSpinedits to get extra curve types.




Boleeman

  • Hero Member
  • *****
  • Posts: 686
Re: N-gram Star Patterns and Other Recursive Curve Patterns
« Reply #5 on: August 17, 2024, 12:03:30 pm »
A Tbgrabmp version where you can save and load your favorite design settings.

I am not sure why, but when clicking on a Listbox row the loading of the settings is a bit jumpy.

Is it because of using the bgrabmp OnPaint event?

 

TinyPortal © 2005-2018