19,468
社区成员
发帖
与我相关
我的任务
分享
VOID Example_DrawArc(HDC hdc)
{
Graphics graphics(hdc);
// Set up the arc.
Pen redPen(Color::Red, 3);
Rect ellipseRect(0, 0, 200, 100);
REAL startAngle = 0.0f;
REAL sweepAngle = 90.0f;
// Draw the arc.
graphics.DrawArc(&redPen, ellipseRect, startAngle, sweepAngle);
}
Syntax
Status DrawArc( const Pen *pen,
const Rect &rect,
REAL startAngle,
REAL sweepAngle
);
Parameters
pen
[in] Pointer to a pen that is used to draw the arc.
rect
[in] Reference to the rectangle that bounds the ellipse that contains the arc.
startAngle
[in] Real number that specifies the angle between the x-axis and the starting point of the arc.
sweepAngle
[in] Real number that specifies the angle between the starting and ending points of the arc.
Syntax
Status DrawArc( const Pen *pen,
const RectF &rect,
REAL startAngle,
REAL sweepAngle
);
Parameters
pen
[in] Pointer to a pen that is used to draw the arc.
rect
[in] Reference to the rectangle that bounds the ellipse that contains the arc.
startAngle
[in] Real number that specifies the angle between the x-axis and the starting point of the arc.
sweepAngle
[in] Real number that specifies the angle between the starting and ending points of the arc.
Return Value
Syntax
Status DrawArc( const Pen *pen,
REAL x,
REAL y,
REAL width,
REAL height,
REAL startAngle,
REAL sweepAngle
);
Parameters
pen
[in] Pointer to a pen that is used to draw the arc.
x
[in] Real number that specifies the x-coordinate of the upper-left corner of the bounding rectangle for the ellipse that contains the arc.
y
[in] Real number that specifies the y-coordinate of the upper-left corner of the bounding rectangle for the ellipse that contains the arc.
width
[in] Real number that specifies the width of the ellipse that contains the arc.
height
[in] Real number that specifies the height of the ellipse that contains the arc.
startAngle
[in] Real number that specifies the angle between the x-axis and the starting point of the arc.
sweepAngle
[in] Real number that specifies the angle between the starting and ending points of the arc.
Syntax
Status DrawArc( const Pen *pen,
INT x,
INT y,
INT width,
INT height,
REAL startAngle,
REAL sweepAngle
);
Parameters
pen
[in] Pointer to a pen that is used to draw the arc.
x
[in] Integer that specifies the x-coordinate of the upper-left corner of the bounding rectangle for the ellipse that contains the arc.
y
[in] Integer that specifies the y-coordinate of the upper-left corner of the bounding rectangle for the ellipse that contains the arc.
width
[in] Integer that specifies the width of the ellipse that contains the arc.
height
[in] Integer that specifies the height of the ellipse that contains the arc.
startAngle
[in] Real number that specifies the angle between the x-axis and the starting point of the arc.
sweepAngle
[in] Real number that specifies the angle between the starting and ending points of the arc.
//GDI+
Rect nRect(Front_Left.x,Front_Left.y,m_rc_FrontArea.Width(),m_rc_FrontArea.Height());
Graphics graphics(pDc->m_hDC);
graphics.SetPageUnit(UnitPixel);
graphics.SetSmoothingMode(SmoothingModeAntiAlias);
graphics.SetClip(nRect);
graphics.TranslateTransform(0,0);
Pen pen(Color::Red, 1);
for (i=0;i<10;i++)
{
if (i>7 || i<3)
{
continue;
}
line =(0.1*i*lineL);
startpoint.x = OriginFront_Left.x + line*cos(fstartangle*pi/180);
startpoint.y = OriginFront_Left.y + line*sin(fstartangle*pi/180);
startpoint = RectangularcoordinateToOrigin(startpoint,Front_Left);
CPoint Opoint = RectangularcoordinateToOrigin(OriginFront_Left,Front_Left);
pDc->MoveTo(startpoint);
pDc->SetBrushOrg(startpoint);
//pDc->SetArcDirection(AD_CLOCKWISE);
//pDc->AngleArc(Opoint.x,Opoint.y,line,fstartangle,m_f_Arc_Angle);
//pDc->SetArcDirection(AD_COUNTERCLOCKWISE);
graphics.DrawArc(&pen,m_rc_FrontArea.left,m_rc_FrontArea.top,80,80,0,360);
}
#pragma comment(lib,"user32")
#pragma comment(lib,"gdi32")
#pragma comment(lib, "gdiplus.lib")
#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;
VOID OnPaint(HDC hdc) {
Graphics graphics(hdc);
Pen redPen(Color::Red, 3);
Rect ellipseRect;
REAL startAngle;
REAL sweepAngle;
graphics.SetSmoothingMode(SmoothingModeHighQuality);
ellipseRect=Rect(0, 0, 100, 100);
startAngle = 0.0f;
sweepAngle = 45.0f;
graphics.DrawArc(&redPen, ellipseRect, startAngle, sweepAngle);
ellipseRect=Rect(150, 0, 100, 100);
startAngle = 180.0f;
sweepAngle = -45.0f;
graphics.DrawArc(&redPen, ellipseRect, startAngle, sweepAngle);
ellipseRect=Rect(0, 150, 100, 100);
startAngle = 0.0f;
sweepAngle = -45.0f;
graphics.DrawArc(&redPen, ellipseRect, startAngle, sweepAngle);
ellipseRect=Rect(150, 150, 100, 100);
startAngle = 180.0f;
sweepAngle = 45.0f;
graphics.DrawArc(&redPen, ellipseRect, startAngle, sweepAngle);
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
HDC hdc;
PAINTSTRUCT ps;
switch(message) {
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
OnPaint(hdc);
EndPaint(hWnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
}
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, INT iCmdShow) {
HWND hWnd;
MSG msg;
WNDCLASS wndClass;
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = hInstance;
wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = TEXT("GettingStarted");
RegisterClass(&wndClass);
hWnd = CreateWindow(
TEXT("GettingStarted"), // window class name
TEXT("Getting Started"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL); // creation parameters
ShowWindow(hWnd, iCmdShow);
UpdateWindow(hWnd);
while(GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
GdiplusShutdown(gdiplusToken);
return 0;
}
Const STRETCH_HALFTONE = 4
Private Declare Function SetStretchBltMode Lib "gdi32" (ByVal hdc As Long, ByVal nStretchMode As Long) As Long
Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Dim sDisplay As String
Private Sub Form_Load()
sDisplay = "字体反锯齿前"
pDest.Cls
pDest.Print
pDest.Print sDisplay
sDisplay = "字体反锯齿后"
pFont.Cls
pFont.Print sDisplay
SetStretchBltMode pDest.hdc, STRETCH_HALFTONE
StretchBlt pDest.hdc, 0, 0, pDest.TextWidth(sDisplay), pDest.TextHeight(sDisplay), pFont.hdc, 0, 0, pFont.TextWidth(sDisplay), pFont.TextHeight(sDisplay), vbSrcCopy
End Sub
for (i=0;i<10;i++)
{
if (i>7 || i<3)
{
continue;
}
line =(0.1*i*lineL);
startpoint.x = OriginFront_Left.x + line*cos(fstartangle*pi/180);
startpoint.y = OriginFront_Left.y + line*sin(fstartangle*pi/180);
startpoint = RectangularcoordinateToOrigin(startpoint,Front_Left);
CPoint Opoint = RectangularcoordinateToOrigin(OriginFront_Left,Front_Left);
pDc->MoveTo(startpoint);
pDc->SetArcDirection(AD_CLOCKWISE);
pDc->AngleArc(Opoint.x,Opoint.y,line,fstartangle,m_f_Arc_Angle);
pDc->SetArcDirection(AD_COUNTERCLOCKWISE);
// graphics.DrawArc(&pen,Front_Left.x,Front_Left.y,50,50,0,720);
}