Drawing with dots, brushes, and pens

Source: Internet
Author: User

 

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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.