CIRCLE.PAS 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. Uses Mytpu,CRT,Graph;
  2. Const
  3. MaxValues = 6;
  4. Type ValType = record
  5. n : integer;
  6. p : real;
  7. end;
  8. Var
  9. values : array [1..MaxValues] of ValType;
  10. SumVal : Word;
  11. I : byte;
  12. LastArc : Word;
  13. Coords : ArcCoordsType;
  14. {--------====================--------------}
  15. Procedure Iniit;
  16. Var
  17. i:byte;
  18. Begin
  19. InitVGA;
  20. SumVal := 0;
  21. for i:=1 to MaxValues do
  22. begin
  23. values[i].n:=GetValue('Вводите значения',GetMaxX div 2,GetMaxY div 2,1,32767);
  24. SumVal := SumVal + values[i].n;
  25. end;
  26. for i := 1 to MaxValues do values[i].p :=values[i].n/SumVal;
  27. End;{Iniit}
  28. {---------------------------}
  29. Procedure Show3dSlice(StAng,EAng:integer;Show:boolean);
  30. var t:byte;
  31. Begin
  32. Arc(300,200,stang,eang,100);
  33. PieSlice(300,200,stang,eang,100);
  34. SetColor(white);
  35. GetArcCoords(Coords);
  36. With coords do
  37. begin
  38. SetColor(White);
  39. Line(300,200,xstart,ystart);
  40. Line(300,200,xend,yend);
  41. if stang > 180 then Line(xstart,Ystart,Xstart,Ystart+30);
  42. if eang > 180 then Line(xend,Yend,Xend,Yend+30);
  43. if eang > 180 then
  44. if stang > 180 then
  45. for t := 1 to 30 do
  46. begin
  47. if (t = 1) or (t=30) then Setcolor(white) else SetColor(i);
  48. Arc(300,199+t,stang,eang,100)
  49. end
  50. else
  51. for t := 1 to 30 do
  52. begin
  53. if (t = 1) or (t=30) then Setcolor(white) else SetColor(i);
  54. Arc(300,199+t,180,eang,100);
  55. end;
  56. end;
  57. End;
  58. {---------------------------}
  59. Begin
  60. Iniit;
  61. SetAspectRatio(3,5);
  62. For i := 1 to MaxValues do
  63. begin
  64. SetColor(i);
  65. SetFillStyle(solidfill,i);
  66. Show3dslice(LastArc,round(LastArc+360*values[i].p),false);
  67. LastArc:=round(LastArc+360*values[i].p);
  68. end;
  69. Line(200,200,200,230);
  70. ReadKey;
  71. CloseVGA
  72. End.