Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //forumla by Garrett
- function ExpandPoly(poly:TPointArray; incr:Int32): TPointArray;
- var
- i,j,size: Int32;
- x,y,r: Double;
- b,m: array of Double;
- begin
- SetLength(B, Length(poly));
- SetLength(M, Length(poly));
- size := Length(poly);
- for i:=0 to size-1 do
- begin
- j := (i+1) mod size;
- r := incr / Hypot(poly[i].x-poly[j].x, poly[i].y-poly[j].y);
- x := r * (poly[j].y - poly[i].y);
- y := r * (poly[i].x - poly[j].x);
- m[i] := ((poly[j].y + y) - (poly[i].y + y)) / ((poly[j].x + x) - (poly[i].x + x)); //fix me vertical lines
- b[i] := (poly[i].y + y) - (m[i] * (poly[i].x + x));
- end;
- SetLength(Result, Length(poly));
- for i:=0 to size-1 do
- begin
- j := (i+1) mod size;
- x := (b[j] - b[i]) / (m[i] - m[j]);
- Result[i].x := Round(x);
- Result[i].y := Round((x * m[i]) + b[i]);
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement