Janilabo

asd

Sep 12th, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.20 KB | None | 0 0
  1. {$loadlib tpaconvexhull.dll}
  2. {$loadlib pumbaa.dll}
  3.  
  4. {==============================================================================]
  5.   Explanation: Sets points from TPA that are inside bmp as color.
  6. [==============================================================================}
  7. procedure SetPixels(bmp: Integer; TPA: TPointArray; color: Integer);
  8. var
  9.   a, z, w, h: Integer;
  10. begin
  11.   z := High(TPA);
  12.   if (z > -1) then
  13.   begin
  14.     GetBitmapSize(bmp, w, h);
  15.     for a := 0 to z do
  16.       if ((TPA[a].X >= 0) and (TPA[a].Y >= 0) and (TPA[a].X < w) and (TPA[a].Y < h)) then
  17.         FastSetPixel(bmp, TPA[a].X, TPA[a].Y, color);
  18.   end;
  19. end;
  20.  
  21. var
  22.   TPA, p, t: TPointArray;
  23.   bmp: Integer;
  24.  
  25. begin
  26.   bmp := CreateBitmap(500, 500);
  27.   TPA := [Point(10, 50), Point(50, 10), Point(140, 100), Point(100, 180), Point(10, 10), Point(50, 50), Point(30, 25), Point(40, 54), Point(15, 15), Point(18, 39)];
  28.   t := CopyTPA(TPA);
  29.   SetPixels(bmp, t, 13655361);
  30.   TPAConvexHull(TPA);
  31.   pp_Append(TPA, TPA[0]); // Just to make sure we get it enclosed.. :)
  32.   pp_TPAFromFlexibleLine(TPA, p);
  33.   SetPixels(bmp, p, 255);
  34.   SetPixels(bmp, TPA, 16777215);
  35.   DisplayDebugImgWindow(500, 500);
  36.   DrawBitmapDebugImg(bmp);
  37. end.
Advertisement
Add Comment
Please, Sign In to add comment