3
어떻게 Graphics32를 사용하여 앤티 앨리어싱 된 둥근 모서리 사각형을 그릴 수 있습니까?Delphi - Graphics32, 앤티 엘리 어싱 된 둥근 사각형을 그립니다.
TPolygon을 사용하여 일반적인 사각형을 bitmap32 캔버스에 만들었지 만 둥근 모서리를 그리는 데 대한 참조를 찾을 수 없습니다. 몇 가지 코드를 고맙게 생각합니다.
어떻게 Graphics32를 사용하여 앤티 앨리어싱 된 둥근 모서리 사각형을 그릴 수 있습니까?Delphi - Graphics32, 앤티 엘리 어싱 된 둥근 사각형을 그립니다.
TPolygon을 사용하여 일반적인 사각형을 bitmap32 캔버스에 만들었지 만 둥근 모서리를 그리는 데 대한 참조를 찾을 수 없습니다. 몇 가지 코드를 고맙게 생각합니다.
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의 일부가 아닌 것 같습니다. – hikari
그래픽 32 용 GR32_Lines 라이브러리 (GR32_Misc 장치). http://www.angusj.com/delphi/gr32_lines.php – pani
에서 다운로드 할 수 있습니다. 고마워요. 이것에 약간의 시간이 필요합니다. Extension은 TPibergon32를 제거하고 모든 코드와 충돌하는 공식 1.91보다는 최신 SVN 파일이 필요합니다 .- 오늘 나중에 확인하고 다시 얻을 것입니다. – hikari