InIn Windows, the method of painting points is very simple. You only need to call colorref cdc: SetPixel (int x, int y, COLORREF crColor) to specify the color of the point and return the original color. Colorref cdc: GetPixel (int x, int y) to obtain the color of the specified vertex. In Windows, do not use point-of-painting functions because the execution efficiency is relatively low.
Brush and paint brushWindows plotting is the most commonly used GUI object. This section describes how to use brushes and brushes while also writing Basic plotting functions.
The system uses the currentDC paint brush, so you must select it into DC after creating the paint brush to produce results during drawing. A paint brush can be generated by using a CPen object and created by calling CPen: CreatePen (int nPenStyle, int nWidth, COLORREF crColor. Here, nPenStyle refers to the paint brush style, which can be the following values:
- PS_SOLIDSolid line Creates a solid pen.
- PS_DASHDotted line. the width must be Creates a dashed pen. Valid only when the pen width is 1 or less, in device units.
- PS_DOTPoint Line, the width must be Creates a dotted pen. Valid only when the pen width is 1 or less, in device units.
- PS_DASHDOTDash. the width must be Creates a pen with alternating dashes and dots. Valid only when the pen width is 1 or less, in device units.
- PS_DASHDOTDOTDouble-dot dash. the width must be Creates a pen with alternating dashes and double dots. Valid only when the pen width is 1 or less, in device units.
- PS_NULLNull Line. No Creates a null pen is generated during use.
- PS_ENDCAP_ROUNDThe End is a circular End caps are round.
- PS_ENDCAP_SQUAREEnd is square End caps are square.
NWidth and crColor are the width and color of the line.
A brush is the color used to fill a closed curve. For example, when you draw a circle or square, the system will fill the interior with the current brush. Available brushesCBrush object generation. Use the following functions to create a brush:
- BOOL CreateSolidBrush (COLORREF crColor); creates a fixed-color brush.
- BOOL CreateHatchBrush (int nIndex, COLORREF crColor); Create a brush with the specified color and grid. The nIndex value can be the following:
- HS_BDIAGONALDownward hatch (left to right) at 45 degrees
- HS_CROSSHorizontal and vertical crosshatch
- HS_DIAGCROSSCrosshatch at 45 degrees
- HS_FDIAGONALUpward hatch (left to right) at 45 degrees