Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {$loadlib pumbaa.dll}
- procedure DebugBitmap(bmp: Integer);
- var
- w, h: Integer;
- begin
- GetBitmapSize(bmp, w, h);
- DisplayDebugImgWindow(w, h);
- DrawBitmapDebugImg(bmp);
- end;
- function TPADiagonals2(bx: TBox): TPointArray;
- var
- x, y, z, l, r, w, h, e, o: Integer;
- c: TPoint;
- begin
- l := pp_BoxSize(bx);
- SetLength(Result, l);
- if (l > 0) then
- begin
- pp_BoxDimensions(bx, w, h);
- z := ((bx.X1 + h) - 1);
- c := Point(bx.X1, bx.Y1);
- e := 0;
- o := 0;
- repeat
- if (c.X > z) then
- e := (c.X - z);
- if (c.X > bx.X2) then
- o := (c.X - bx.X2);
- y := (bx.Y1 + o);
- for x := (c.X - o) downto (bx.X1 + e) do
- begin
- Result[r] := Point(x, y);
- if (y < bx.Y2) then
- y := (y + 1);
- r := (r + 1);
- end;
- c.X := (c.X + 1);
- until (c.X > (bx.X2 + h));
- end;
- end;
- function TPADiagonals(bx: TBox): TPointArray;
- var
- x, y, z, l, r, w, h, e, o: Integer;
- c: TPoint;
- begin
- l := pp_BoxSize(bx);
- SetLength(Result, l);
- if (l > 0) then
- begin
- pp_BoxDimensions(bx, w, h);
- z := ((bx.X1 + h) - 1);
- c := Point(bx.X1, bx.Y1);
- e := 0;
- o := 0;
- repeat
- if (c.X > z) then
- e := (c.X - z);
- if (c.X > bx.X2) then
- o := (c.X - bx.X2);
- y := (bx.Y2 - o);
- for x := (c.X - o) downto (bx.X1 + e) do
- begin
- Result[r] := Point(x, y);
- if (y > bx.Y1) then
- y := (y - 1);
- r := (r + 1);
- end;
- c.X := (c.X + 1);
- until (c.X > (bx.X2 + h));
- end;
- end;
- var
- bmp, w, h, i: Integer;
- TPA: TPointArray;
- bx: TBox;
- begin
- bx := IntToBox(0, 0, 350, 99);
- pp_BoxDimensions(bx, w, h);
- bmp := CreateBitmap(w, h);
- TPA := TPADiagonals2(bx);
- for i := 0 to High(TPA) do
- begin
- if ((i mod 2) = 0) then
- FastSetPixel(bmp, TPA[i].X, TPA[i].Y, 255)
- else
- FastSetPixel(bmp, TPA[i].X, TPA[i].Y, 16777215);
- DebugBitmap(bmp);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement