fork(2) download
  1. procedure TForm1.Button23Click(Sender: TObject);
  2. var
  3. First, Second, Green: TRect;
  4. fl, ft, fb, fr, fw, fh: Integer;
  5. sl, st, sb, sr, sw, sh: Integer;
  6. gl, gt, gb, gr: Integer;
  7. dcy, dcx, dy, dx: Integer;
  8. Flag: Boolean;
  9. begin
  10. Canvas.Brush.Color := Color;
  11. Canvas.FillRect(ClientRect);
  12. fl := 100;
  13. ft := 100;
  14. fw := 100;
  15. fh := 100;
  16. fr := fl + fw;
  17. fb := ft + fh;
  18. First := Rect(fl, ft, fr, fb);
  19. Canvas.Pen.Color := clBlack;
  20. Canvas.Brush.Color := clGray;
  21. Canvas.Rectangle(First);
  22. Canvas.Brush.Style := bsClear;
  23. sl := 60 + Random(185);
  24. st := 60 + Random(180);
  25. sw := 30 + Random(150);
  26. sh := 30 + Random(150);
  27. sr := sl + sw;
  28. sb := st + sh;
  29. Second := Rect(sl, st, sr, sb);
  30. Canvas.Pen.Color := clBlue;
  31. Canvas.Rectangle(Second);
  32.  
  33. dcy := (sb + st) - (fb + ft); //doubled center y-difference
  34. dcx := (sl + sr) - (fl + fr);
  35. if (Abs(dcx) >= fw + sw) or ((Abs(dcy) >= fh + sh)) then //no intersection
  36. Exit;
  37.  
  38. dx := fw + sw - Abs(dcx); //doubled needed x-shift
  39. dy := fh + sh - Abs(dcy);
  40.  
  41. if dx > dy then begin
  42. if dcy < 0 then
  43. dy := - dy div 2
  44. else
  45. dy := dy div 2; //needed y-shift accounting for direction
  46. dx := 0;
  47. end else begin
  48. if dcy < 0 then
  49. dx := - dx div 2
  50. else
  51. dx := dx div 2;
  52. dy := 0;
  53. end;
  54.  
  55. Green := Second;
  56. OffsetRect(Green, dx, dy);
  57. Canvas.Pen.Color := clGreen;
  58. Canvas.Rectangle(Green);
  59.  
  60. end;
  61.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Free Pascal Compiler version 3.0.0+dfsg-10 [2016/12/12] for x86_64
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling prog.pas
prog.pas(1,11) Error: Identifier not found "TForm1"
prog.pas(1,11) Error: class identifier expected
prog.pas(3,25) Error: Identifier not found "TRect"
prog.pas(3,30) Error: Error in type definition
prog.pas(10,3) Error: Identifier not found "Canvas"
prog.pas(10,25) Error: Identifier not found "Color"
prog.pas(11,3) Error: Identifier not found "Canvas"
prog.pas(11,19) Error: Identifier not found "ClientRect"
prog.pas(18,12) Error: Identifier not found "Rect"
prog.pas(19,3) Error: Identifier not found "Canvas"
prog.pas(19,23) Error: Identifier not found "clBlack"
prog.pas(20,3) Error: Identifier not found "Canvas"
prog.pas(20,25) Error: Identifier not found "clGray"
prog.pas(21,3) Error: Identifier not found "Canvas"
prog.pas(22,3) Error: Identifier not found "Canvas"
prog.pas(22,25) Error: Identifier not found "bsClear"
prog.pas(29,13) Error: Identifier not found "Rect"
prog.pas(30,3) Error: Identifier not found "Canvas"
prog.pas(30,23) Error: Identifier not found "clBlue"
prog.pas(31,3) Error: Identifier not found "Canvas"
prog.pas(56,3) Error: Identifier not found "OffsetRect"
prog.pas(57,3) Error: Identifier not found "Canvas"
prog.pas(57,23) Error: Identifier not found "clGreen"
prog.pas(58,3) Error: Identifier not found "Canvas"
prog.pas(61) Fatal: Syntax error, "BEGIN" expected but "end of file" found
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode
stdout
Standard output is empty