Forum > Graphics

Solved: Draw stars inside polygons and Get Rid of extra vertical line

(1/2) > >>

Boleeman:
Corrected version is attached in the 4th REPLY BELOW.

G'Day All.

I converted some CSharp code ( from http://www.csharphelper.com/howtos/howto_draw_ngon_stars.html  ) to Lazarus and have added a scalefactor to scale the smaller images that get drawn around the center image..

I was trying to get rid of a small vertical line at the bottom, which happens for even values of number of vertices but somehow I cannot find how (as shown in the attached picture).

How to get rid of that small vertical line is what I am trying to do?



Paweld was able to fix this for me in next thread. Thank you Paweld.

paweld:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.DrawScaledStar(ACanvas: TCanvas; x, y: Integer; orig_pts: array of TPoint; skip: Integer; AscaleFactor: Double);var  pts: array of TPoint;  i, pointIndex: Integer;begin  SetLength(pts, NumPoints);  for i := 0 to NumPoints - 1 do  begin    if (skip * 2) = NumPoints then      continue;    pointIndex := (i * skip) mod NumPoints;    pts[i] := Point(Round(x + orig_pts[pointIndex].X * AscaleFactor), Round(y + orig_pts[pointIndex].Y * AscaleFactor));  end;  for i := 0 to High(pts) - 1 do  begin      ACanvas.Line(pts[i].X, pts[i].Y, pts[i + 1].X, pts[i + 1].Y);  end;  ACanvas.Line(pts[High(pts)].X, pts[High(pts)].Y, pts[0].X, pts[0].Y);end;

Boleeman:
Paweld to the Rescue. "if (skip * 2) = NumPoints then"   Cant believe it.

It was driving me crazy, trying to remove that one little vertical line.

Thanks for helping me out Paweld.

440bx:

--- Quote from: Boleeman on May 19, 2024, 11:27:28 am ---Paweld to the Rescue. "if (skip * 2) = NumPoints then"   Cant believe it.

It was driving me crazy, trying to remove that one little vertical line.

Thanks for helping me out Paweld.

--- End quote ---
Just a suggestion: post a corrected version of your program so people don't have to remember that it requires a manual correction to operate properly.

Boleeman:
OK 440bx

Attached below is the fixed up version.

Navigation

[0] Message Index

[#] Next page

Go to full version