Epitrochoid Curve: Now Drawing correctly lazarus / 39-Graphics ---------------------------------------------------------------------- Boleeman · 2024-05-21 12:14 Made an Epitrochoid Curve. I was getting an annoying extra line from (0,0).   (as shown in attached png picture) Now fixed by Circular and Josh I also changed the minimum A H B selectors to something other than 0 (zero), as Josh was correct about the division by zero bug. The converted CSharp code originally had scale and translate, which I think BGRABmp may have but I just translated by half the paintbox width and height by doing: pt0 := Point(Round(X(a, b, h, t) * scale) + Round(PaintBox1.ClientWidth / 2),                  Round(Y(a, b, h, t) * scale) + Round(PaintBox1.ClientHeight / 2)); Working bug fixed code is now attached below. Also a straight filled pattern using MSPaint. Also wondered it could be possibly be multi-colored and made to spin/animate? The coloured attached picture almost looks like stained glass. Would be nice to alter the opacity of it to make it appear slightly see-through like real glass. ---------------------------------------------------------------------- Boleeman · 2024-05-21 12:27 Just noticed: Varying the value of H makes a blinking eye effect. ---------------------------------------------------------------------- circular · 2024-05-21 19:33 Sure, check when the first coordinate is supplied and use MoveTo instead of LineTo: 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.DrawEpitrochoid(ACanvas: TCanvas; a, b, h, dt: Double);var  scale, stop_t, t: Double;  pt0, pt1: TPoint;  first: boolean;begin  // Calculate the stop value for t.  stop_t := b * 2 * Pi;   // Scale.  scale := Min(PaintBox1.ClientWidth * 0.45, PaintBox1.ClientHeight * 0.45);   // Find the first point on the curve.  t := 0;  repeat    pt0 := Point(Round(X(a, b, h, t) * scale) + Round(PaintBox1.ClientWidth / 2),                 Round(Y(a, b, h, t) * scale) + Round(PaintBox1.ClientHeight / 2));    t := t + dt;  until (t > stop_t) or ((pt0.X >= 0) and (pt0.Y >= 0) and (pt0.X < PaintBox1.ClientWidth) and (pt0.Y < PaintBox1.ClientHeight));   first := true;  while t <= stop_t do  begin    pt1 := Point(Round(X(a, b, h, t) * scale) + Round(PaintBox1.ClientWidth / 2),                 Round(Y(a, b, h, t) * scale) + Round(PaintBox1.ClientHeight / 2));  if first then    begin      ACanvas.MoveTo(pt1.X, pt1.Y);      first := false    end    else      ACanvas.LineTo(pt1.X, pt1.Y);    pt0 := pt1;    t := t + dt;  end; end; ---------------------------------------------------------------------- Josh · 2024-05-21 23:05 also at end line needs to draw back to start ordinates. Also you need to change the minimum A H B selectors to something other than 0 (zero), else you will get FLT error when zero as calc are divided by them. 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.DrawEpitrochoid(ACanvas: TCanvas; a, b, h, dt: Double);var  scale, stop_t, t: Double;  pt0, pt1,fp: TPoint;begin  // Calculate the stop value for t.  stop_t := b * 2 * Pi;   // Scale.  scale := Min(PaintBox1.ClientWidth * 0.45, PaintBox1.ClientHeight * 0.45);   // Find the first point on the curve.  t := 0;  repeat    pt0 := Point(Round(X(a, b, h, t) * scale) + Round(PaintBox1.ClientWidth / 2),                 Round(Y(a, b, h, t) * scale) + Round(PaintBox1.ClientHeight / 2));    t := t + dt;  until (t > stop_t) or ((pt0.X >= 0) and (pt0.Y >= 0) and (pt0.X < PaintBox1.ClientWidth) and (pt0.Y < PaintBox1.ClientHeight));  fp:=pt0;  ACanvas.MoveTo(fp.X, fp.Y);  // move to first point  while t <= stop_t do  begin    pt1 := Point(Round(X(a, b, h, t) * scale) + Round(PaintBox1.ClientWidth / 2),                 Round(Y(a, b, h, t) * scale) + Round(PaintBox1.ClientHeight / 2));    ACanvas.LineTo(pt1.X, pt1.Y);    pt0 := pt1;    t := t + dt;  end;  ACanvas.LineTo(fp.X, fp.Y); // draw line back to originend; ---------------------------------------------------------------------- Boleeman · 2024-05-22 05:55 Thanks to Circular and Josh for replying with your respective fixes. With Circular's code there was still a small gap in the center part of the curve, as the at end line needed to draw back to start ordinates. With Josh's code the gap is now gone. I originally tried ACanvas.MoveTo before asking for help, but for some reason could not get it working properly. As mentioned in 1st post, the original CSharp code had TRANSFORM parts to it like translate and scale, so as to move the curve and to size the curve. I wanted to do some TRANSFORMS like: scale := Min(PaintBox1.ClientWidth * 0.45, PaintBox1.ClientHeight * 0.45);   Canvas.Scale(scale, scale);   Canvas.Translate(PaintBox1.ClientWidth / 2, PaintBox1.ClientHeight / 2); which I think BGRABmp can do. I would still like to know how to perform the transforms in BGRABmp. I ended up doing: pt0 := Point(Round(X(a, b, h, t) * scale) + Round(PaintBox1.ClientWidth / 2),                  Round(Y(a, b, h, t) * scale) + Round(PaintBox1.ClientHeight / 2)); to perform the transformations another way. Attached is a filled pattern, with a Bulge effect done in Paint.Net (making the central shapes more elongated). I wonder if something in BGRABmp can be used to achieve a similar shape distortion effect? I just tried out Josh's Animated Version in the next thread. Nice. Really like the Animate H with Color Cycle and A=19 and B=15 and linewidth=2 and Speed Adjust. There is another effect at the circumference, where the colors appear to be rotating, while the pulsating effect is happening. Actually single color animation also works well (I had Yellow curve with black background, Animating H value). With the other animation parameters (A and B parameters), it seems you have to start them at certain spots to get differing effects. Nicely done by Josh. ---------------------------------------------------------------------- Josh · 2024-05-22 07:32 Fixes and extra controls for Anim based on V1 The Attached Project removed from this post, go down thread to get latest ---------------------------------------------------------------------- Josh · 2024-05-22 08:46 and for my 1300th post added option to turn off/on merge pen added option to draw a center linewhen line width >10 max line width updated to 100 edit Quick update, tidy up code. ---------------------------------------------------------------------- Boleeman · 2024-05-22 10:17 Yeeeee Harrrrrrr, 1300th post. Congratulations Josh Nice Going. ---------------------------------------------------------------------- Josh · 2024-05-22 10:28 setting the parameters to the pic then click animate.. the reason the colour cycles and gives the rotating effect is becaus i purposely did not reset the color index counter when redrawing.. I found it more effective ---------------------------------------------------------------------- AlexTP · 2024-05-22 10:35 Added to https://github.com/Alexey-T/Boleeman_Curves . ---------------------------------------------------------------------- Boleeman · 2024-05-22 10:47 AlexTP, getting those uploaded to share. Good. Josh. I set the program to those settings and got that nice Rotation effect. Then I did an Animate with Value H with those settings and got a TRIPPY Effect. Wow. Also click Animate Value A or Animate Value B just for a short time and then unclick those, while leaving Animate Value H still selected, and then .... THE MAGIC HAPPENS.  Even more interesting and varying psychedelic effects. Thanks for the great animation effects and extra features. That's it for me today. Take care. ---------------------------------------------------------------------- 440bx · 2024-05-22 10:57 Some really interesting curves and associated programs in this thread in addition to being good stuff, it's quite enjoyable.  Thank you to those who are participating and in particular to Boleeman and Josh. Since there seems to be some people interested in "interesting curves", I thought I'd mention one of my favorites (might actually be my favorite), it is a Loxodrome.  Google has a good number of renderings that range from "sure, that's fine" to Wow!!!. ---------------------------------------------------------------------- Josh · 2024-05-22 10:59 if you show it down then turn on merge, you get a psychedelic effect. Too Many options, but good fun ---------------------------------------------------------------------- Josh · 2024-05-23 01:56 @440bx Not sure, is this the type of thing ---------------------------------------------------------------------- 440bx · 2024-05-23 04:18 Quote from: Josh on May 23, 2024, 03:56:13 am@440bx Not sure, is this the type of thing Not sure either, I have not played with that curve represented in the complex plane.  I've played with its representation in the real plane.  I attached one of the renditions I made, about 14 years ago, using a free program called "Incendia".