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