Delphi-Graphics32,绘制抗锯齿圆角矩形
如何使用Graphics32绘制抗锯齿圆角矩形 我设法在bitmap32画布上绘制了一个带有TPolygon的普通矩形,但找不到任何绘制圆角的参考。如果你能给我一些代码就好了Delphi-Graphics32,绘制抗锯齿圆角矩形,delphi,antialiasing,graphics32,Delphi,Antialiasing,Graphics32,如何使用Graphics32绘制抗锯齿圆角矩形 我设法在bitmap32画布上绘制了一个带有TPolygon的普通矩形,但找不到任何绘制圆角的参考。如果你能给我一些代码就好了 function GetRoundedFixedRectanglePoints(const Rect: TFloatRect; dx, dy: single): TArrayOfFixedPoint; var i, j, k, arcLen: integer; arcs: array [0 .. 3] of TAr
function GetRoundedFixedRectanglePoints(const Rect: TFloatRect; dx, dy: single): TArrayOfFixedPoint;
var
i, j, k, arcLen: integer;
arcs: array [0 .. 3] of TArrayOfFixedPoint;
begin
//nb: it's simpler to construct the rounded rect in an anti-clockwise
//direction because that's the direction in which the arc points are returned.
with Rect do
begin
arcs[0] := GetArcPointsEccentric(
FloatRect(Left, Bottom -dy*2, Left+dx*2, Bottom), rad180, rad270);
arcs[1] := GetArcPointsEccentric(
FloatRect(Right-dx*2, Bottom -dy*2, Right, Bottom), rad270, 0);
arcs[2] := GetArcPointsEccentric(
FloatRect(Right - dx*2, Top, Right, Top + dy*2), 0, rad90);
arcs[3] := GetArcPointsEccentric(
FloatRect(Left, top, Left+dx*2, Top+dy*2), rad90, rad180);
//close the rectangle
SetLength(arcs[3], Length(arcs[3])+1);
arcs[3][Length(arcs[3])-1] := arcs[0][0];
end;
//calculate the final number of points to return
j := 0;
for i := 0 to 3 do
Inc(j, Length(arcs[i]));
SetLength(Result, j);
j := 0;
for i := 0 to 3 do
begin
arcLen := Length(arcs[i]);
for k := 0 to arcLen -1 do
Result[j+k] := arcs[i][k];
Inc(j, arcLen);
end;
end;
用法:
var
pts: TArrayOfFixedPoint;
begin
pts := GetRoundedFixedRectanglePoints(FloatRect(Left+2, Top+2, Left + Width-2, Top + Height-2), 5, 5);
SimpleFill(ABitmap32, pts, 0, Color32(clBlack));
这些程序都是从哪里来的?它似乎不是GR32.GR32_Graphics32线库(GR32_杂项单元)的一部分。你可以从我这里下载,谢谢。这需要一点时间,似乎扩展需要最新的SVN文件,而不是官方的1.91,它删除了TPolygon32,并与我的所有代码冲突-将检查并在今天晚些时候返回给您。