Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program new;
- {$I SRL/OSR.simba}
- {$I RSWalker/Walker.simba}
- function MinBoxInRotated(B: TBox; angle: Double): TBox;
- var
- sinA,cosA,ss,ls,wr,hr: Double;
- W,H: Int32;
- begin
- W := B.x2-B.x1+1;
- H := B.y2-B.y1+1;
- ls := W;
- ss := H;
- if w < h then Swap(ls,ss);
- sinA := Abs(Sin(angle));
- cosA := Abs(Cos(angle));
- if (ss <= 2.0*sinA*cosA*ls) or (abs(sinA-cosA) < 0.00001) then
- begin
- wr := (0.5*ss)/sinA;
- hr := (0.5*ss)/cosA;
- if (w < h) then Swap(wr,hr);
- end else
- begin
- wr := (W*cosA - H*sinA) / (Sqr(cosA) - Sqr(sinA));
- hr := (H*cosA - W*sinA) / (Sqr(cosA) - Sqr(sinA));
- end;
- with B.Middle() do
- Result := [Ceil(X-wr/2), Ceil(Y-hr/2), Trunc(X+wr/2), Trunc(Y+hr/2)];
- end;
- var
- BMP: TMufasaBitmap;
- B,B1: TBox;
- R: TRectangle;
- TPA: TPointArray;
- a: Double;
- begin
- BMP.Init(client.GetMBitmaps);
- BMP.SetSize(500,500);
- BMP.Debug();
- B1 := [100,100,420,300];
- while True do
- begin
- a += 0.02;
- R := B1.ToRectangle.Rotate(a);
- B := MinBoxInRotated(B1, a);
- //WriteLn(B);
- BMP.DrawBox(B, $00FF00);
- BMP.DrawRect(R, 255);
- BMP.UpdateDebugImage();
- BMP.Clear();
- end;
- BMP.Debug();
- BMP.Free();
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement