Advertisement
Guest User

Bublik

a guest
Jan 7th, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 3.09 KB | None | 0 0
  1. procedure TForm1.Button4Click(Sender: TObject);
  2. var
  3.  bit: TBitMap;
  4.  
  5.  z: TXXXL;
  6.  
  7.  i: Integer;
  8.  
  9.  aa: Integer;
  10.  
  11.  xGraphics: IGPGraphics;
  12.  
  13.  xLayer: TPNGGraphic;
  14.  xBack: TPNGGraphic;
  15.  
  16.  {$DEFINE USEGDIP}
  17.  
  18.  procedure add(a: Word; c: TColor);
  19.  var
  20.   d: integer;
  21.  begin
  22.   d:=Length(z);
  23.   SetLength(z, d+1);
  24.  
  25.   z[d].A:=Round(360*(a / 100));
  26.   z[d].C:=c;
  27.  end;
  28.  
  29.  
  30.  procedure DrawSector(x1, y1, x2, y2: Integer; Color: TColor);
  31.  begin
  32.   bit.Canvas.Brush.Color:=Color;
  33.   bit.Canvas.Pen.Color:=Color;
  34.   bit.Canvas.Pie(0, 0, 200, 200, x1, y1, x2, y2);
  35.  end;
  36.  
  37.  procedure DrawSector2(x0, y0, r: Integer; a1, a2: Real; Color: TColor);
  38.  var
  39.   x1, y1, x2, y2: Integer;
  40.   rx1, ry1, rx2, ry2: Integer;
  41.  
  42.   function IntToStr2(v: Integer): WideString;
  43.   var
  44.    vs: WideString;
  45.    l, lx, i: Integer;
  46.   begin
  47.    vs:=IntToStr(v);
  48.    l:=length(vs);
  49.  
  50.    Result:='';
  51.  
  52.    lx:=6-l;
  53.  
  54.    for I := 0 to lx do
  55.     Result:=Result+' ';
  56.  
  57.    Result:=Result+vs;
  58.   end;
  59.  begin
  60.   rx1:=round(r*cos(a1));
  61.   x1:=x0+rx1;
  62.  
  63.   ry1:=round(r*sin(a1));
  64.   y1:=y0-ry1;
  65.  
  66.   rx2:=round(r*cos(a2));
  67.   x2:=x0+rx2;
  68.  
  69.   ry2:=round(r*sin(a2));
  70.   y2:=y0-ry2;
  71.  
  72.   sRichEdit1.Lines.Add('['+FloatToStr(a1)+'/'+FloatToStr(a2)+']'+sLineBreak+IntToStr2(rx1)+' '+IntToStr2(ry1)+' '+IntToStr2(rx2)+' '+IntToStr2(ry2)+' '+IntToStr2(x1)+' '+IntToStr2(y1)+' '+IntToStr2(x2)+' '+IntToStr2(y2));
  73.  
  74.   DrawSector(x1, y1, x2, y2, Color);
  75.  end;
  76.  
  77.  procedure DrawSector3(x0, y0, r: Integer; a1, a2: Integer; Color: TColor);
  78.  var
  79.   ar1, ar2: Real;
  80.  begin
  81.   ar1:=a1 * (PI / 180);
  82.   ar2:=a2 * (PI / 180);
  83.  
  84.   DrawSector2(x0, y0, r, ar1, ar2, Color);
  85.  end;
  86.  
  87.  {$IFDEF USEGDIP}
  88.  procedure DrawSector4(x0, y0, r: Integer; sa, da: Integer; Color: TColor);
  89.  begin
  90.   xGraphics.FillPie(TGPSolidBrush.Create(TGPColor.CreateFromColorRef(Color)), 0, 0, 200, 200, sa, da);
  91.  end;
  92.  {$ELSE}
  93.  procedure DrawSector4(x0, y0, r: Integer; sa, da: Integer; Color: TColor);
  94.  begin
  95.   DrawSector3(x0, y0, r, sa, sa+da, Color);
  96.  end;
  97.  {$ENDIF}
  98. begin
  99.  bit:=TBitmap.Create;
  100.  bit.Width:=400;
  101.  bit.Height:=400;
  102.  
  103.  bit.TransparentMode:=tmFixed;
  104.  bit.TransparentColor:=clLime;
  105.  bit.Transparent:=False;
  106.  
  107.  bit.Canvas.Brush.Color:=clLime;
  108.  bit.Canvas.FillRect(Rect(0, 0, 400, 400));
  109.  
  110.  xGraphics:=bit.Canvas.ToGPGraphics;
  111.  xGraphics.SmoothingMode:=SmoothingModeHighQuality;
  112.  
  113.  add(5, clRed);
  114.  add(10, $FFA500);
  115.  add(15, clYellow);
  116.  add(25, clGreen);
  117.  add(35, clBlue);
  118.  add(10, clPurple);
  119.  
  120.  //add(100, clGray);
  121.  
  122.  aa:=0;
  123.  
  124.  for I := 0 to length(z)-1 do
  125.   begin
  126.    DrawSector4(100, 100, 100, aa, z[i].A, z[i].C);
  127.  
  128.    aa:=aa + z[i].A;
  129.   end;
  130.  
  131.  {$IFNDEF USEGDIP}
  132.  bit.Canvas.Brush.Color:=clLime;
  133.  bit.Canvas.Pen.Color:=clLime;
  134.  bit.Canvas.Ellipse(50, 50, 150, 150);
  135.  {$ELSE}
  136.  xGraphics.FillEllipse(TGPSolidBrush.Create(TGPColor.CreateFromColorRef(clLime)), 50, 50, 100, 100);
  137.  {$ENDIF}
  138.  
  139.  xBack:=TPNGGraphic.Create;
  140.  xBack.Width:=400;
  141.  xBack.Height:=400;
  142.  
  143.  xBack.Canvas.Draw(0,0, bit);
  144.  
  145.  xLayer:=TPNGGraphic.Create;
  146.  xLayer.LoadFromFile('Layer.png');
  147.  
  148.  xBack.Canvas.Draw(0, 0, xLayer);
  149.  
  150.  Image1.Picture.Graphic:=xBack;
  151.  //Image1.Transparent:=True;
  152. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement