The gradual discoloration of GDI + learning------

Source: Internet
Author: User

Graphics Graphics (DC. GETSAFEHDC ()); graphics. Clear (Color::white); Defines three colors that participate in the gradient color colors[] ={    color::red,    //Red    Color::green,  //Transition color green    color::blue    //Blue} ;
Define the position of three colors float positions[] ={    0.0f,   //from Red    0.3f,//   green starting from the brush length of One-third    1.0f    //To Blue stop}; Constructs a gradient brush from black to white LinearGradientBrush Lingrbrush (Point    (0, 0), point    (0),    color::black,color:: White); Sets the gradient brush's multicolor gradient information lingrbrush.setinterpolationcolors (colors, positions, 3);
Fills the target area graphics with a multi-color gradient brush. FillRectangle (&lingrbrush, 0, 0, 180, 100); Use a common method for multi-color gradients//from red to green, length 60LinearGradientBrush linGrBrush1 (Point    (0, 0), point    (0),    color::red,    Color::green);
From green to blue, length 120LinearGradientBrush linGrBrush2 (Point    (0), point    (181, 0),    color::green,    Color :: Blue);
Fill two adjacent areas with two brushes to form a multi-color gradient graphics. FillRectangle (&LINGRBRUSH1, 0, +), graphics. FillRectangle (&LINGRBRUSH2, 60, 120, 120, 100);



Example 2:

Defines a linear gradient brush that LinearGradientBrush Lingrbrush in a straight line (0, point, RC2. Height ()/2), color (255, 255, 0, 0), color (255, 0, 0, 255)); Color colors[] = {color (255, 255,0, 0),//red color (255, 255,255, 0),//yellow color (255, 0,0, 255),//blue color (255,  0,255, 0)//green}; According to the order of red, yellow, and blue green four colors gradient, four colors, each accounted for One-fourth real positions[] = {0.0f,0.33f,0.66f,1.0f};// Set interpolation color (interpolation method) lingrbrush.setinterpolationcolors (colors, positions, 4);//fills the specified area rectangle gdiplus::graphics Graphics (pdc->m _HDC);; Graphics. FillRectangle (&lingrbrush, RC2. Width ()/2, 0, RC2. Height ()/2); Set font drawing text Gdiplus::P en Pen (gdiplus::color (255, 0, 0, 255)); Gdiplus::solidbrush Brush (Gdiplus::color (255, 0, 0, 255)); Set color and transparency (0 fully transparent)/r/g/bgdiplus::fontfamily family (L "Microsoft Jas Black"); Set the font FontFamily FontFamily (L "Arial"); Gdiplus::font Font (&family, Gdiplus::fontstyleregular, Gdiplus::unitpixel); Fontstylebold: Bold; Fontstyleitalic: Oblique body; Fontstyleunderline: underline CRect RT; GetClientRect (&RT); Gdiplus::P ointf PointF (Rt. Width ()/2, Rt. HeiGht ()/2); graphics. DrawString (L "GDI + program Schematic",-1, &font, PointF, &brush);


The gradual discoloration of GDI + learning------

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.