畫弧線DrawArc的研究-我自己 -- 直線交接圓角


 

procedure TForm4.Button7Click(Sender: TObject);
var
  pwith: Integer; //畫筆的寬度
  hx1, hy1: Integer; //橫線第一個點
  hx2, hy2: Integer; //橫線的終點
  sx1, sy1: Integer; //豎線第一個點
  sx2, sy2: Integer; //豎線終點
  r: Integer; //圓的半徑
  yleft: Integer;// 圓左側的left
  ytop: Integer; // 圓頂部的top
  g: TGPGraphics;
  p: TGPPen;
begin
  pwith := 10;
  g := TGPGraphics.Create(Canvas.Handle);
  p := TGPPen.Create(aclBlueViolet, pwith);

  hx1 := 100;
  hy1 := 100;
  hx2 := 400;
  hy2 := 100;
  sx1 := 430;
  sy1 := 130;
  sx2 := 430;
  sy2 := 500;

  //x軸上的距離就是半徑.
  r := sx2 - hx2;

  g.DrawLine(p, hx1, hy1, hx2, hy2);
  g.DrawLine(p, sx1, sy1, sx2, sy2);

  g.DrawArc(p, hx2 - r, hy1, r*2, r*2, 270,  90);
  //g.DrawArc(p, 370, 100 -1, 60,60, 270 - 10,  90+10+2); 這樣可以看似完美

  p.Free;
  g.Free;
end;

procedure TForm4.Button8Click(Sender: TObject);
var
  g: TGPGraphics;
  p: TGPPen;
begin
  g := TGPGraphics.Create(Canvas.Handle);
  p := TGPPen.Create(aclBlueViolet, 20);

  //第一個參數是圓最左側,左邊距即left,第二個參數是圓的最上坐標即top,
  //第三個參數 是圓的橫向直徑,第四個參數是圓的縱向直徑,如果橫向與縱向不一致的話
  //畫出來就是橢圓。第五個參數是畫弧的起始度數,是順時針的,第6個參數是畫多少度,即擴展度數。
  g.DrawArc(p, Button8.Left, Button8.Top + Button8.Height, Button8.Width,Button8.Width, 0, 360);

  p.Free;
  g.Free;
end;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM