The GDI + function is extended in terms of painting brush. It supports linear and gradient painting brush, and can fill in graphics, paths, and areas. the gradient Paint Brush can also be used to draw straight lines, curves, and paths. therefore, you can use a path to set the gradient color. in VC ++. use GDI + in net2005. h contains <gdiplus. h> header file, and then add gdiplus to the property> connector> additional reference library. lib file. then in the Application Program Oninitapplication () in, initialize the gdiplus device, Code As follows:
Using namespace gdiplus;
Gdiplusstartupinput ginput;
Gdiplusstartup (& m_gdiplustoken, & ginput, null );
After the application exits, add the following functions to the exitinstance:
Using namespace gdiplus;
Gdipusshutdown (m_gdiplustoken );
Next, you can use GDI +. Add the following code to ondraw:
Using namespace gdiplus;
Graphics g (PDC-> m_hdc );
Point Points [] = point points [] = {point (), point ),
Point (150,150), point (75,100), point (0,150), point (50, 50 )};
Graphicspath path;
Path. addlines (points, 10 );
Pathgradientbrush pgbrush (& Path );
Pgbrush. setcentercolor (color (255,255, 0 ));
Color Colors [] = {color (, 0,), color ),
Color (255,255,255,255,), color ),
Color (,), color ),
Color (0,255, 255,255,255,255), color ),
Color (,), color )};
Int COUNT = 10;
Pgbrush. setsurroundcolors (colors, & COUNT );
G. fillpath (& pgbrush, & Path );