Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>_pg_setpalette() set palette characteristics</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _pg_setpalette()        Set palette characteristics

 #include   <pgchart.h>

 short _pg_setpalette(palette);
 paletteentry _far *palette;            Paletteentry variable

    _pg_setpalette() sets palette colors, line styles, and fill patterns
    for all palettes. The pointer palette points to an array of palette
    structures like this one:

        typedef struct {
        unsigned short color;
        unsigned short style;
        fillmap        fill;
        char           plotchar;
        } paletteentry;

    Returns:         0 for success; _BADSCREENMODE otherwise.

    Portability:     MS-DOS only, true MDPA, CGA, EGA, MCGA, or VGA video
                     compatibles

   -------------------------------- Example ---------------------------------

    This program puts a variety of Presentation Graphics charts on the
    screen.

    #include <conio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <graph.h>
    #include <pgchart.h>

    float _far my2data[2][4] = {{45.0,  52.0,  61.0,   35.0},
                                {53.0,  41.0,  41.0,   43.0}};
    char  _far *months[4] =  {"April",  "May", "June", "July"};
    char  _far *nations[2] = { "USA", "USSR" };
    float _far my1data[4] =    {45.0,  52.0,  61.0,   35.0};
    float _far Peanuts[4]  = {123.0, 134.0, 432.0, 345.0};
    float _far Soybeans[4] = {322.0, 321.0, 524.0, 331.0};
    char  _far *catgs[4] = { "USA", "UK", "USSR", "DDR" };
    short _far explode[5] = {0, 0, 1, 0, 0 };

    void main()
    {
        fillmap myfil = { 0x99, 0x33, 0x66, 0xCC, 0x99, 0x33, 0x66, 0xCC };
            palettetype mypal;
        styleset mystyle;
        chartenv myenv;

        _setvideomode(_MAXRESMODE); /* Set style */
        _pg_initchart();
        _pg_getstyleset(mystyle);
        mystyle[1] = 0x5050;
        _pg_setstyleset(mystyle);
        _pg_defaultchart(&myenv, _PG_BARCHART, _PG_PLAINBARS);
        strcpy(myenv.maintitle.title, "Soybean Consumption");
        _pg_chartms(&myenv,months,(float _far *)my2data,2,4,4,nations);
        getch();

        _pg_getpalette(mypal);      /* Set palette */
        memcpy(mypal[1].fill, myfil, 8);
        mypal[1].plotchar = 16;
        mypal[1].color = 3;
        mypal[1].style = 0x5A5A;
        _pg_setpalette(mypal);

        _pg_defaultchart(&myenv, _PG_LINECHART, _PG_POINTANDLINE);
        strcpy(myenv.maintitle.title, "Soybean Consumption");
        _pg_chartms(&myenv,months,(float _far *)my2data,2,4,4,nations);
        _pg_hlabelchart(&myenv, (short)(myenv.chartwindow.x2 * .77F),
                        (short)(myenv.chartwindow.y2 * .30F), 13, "USSR");
        _pg_vlabelchart(&myenv, (short)(myenv.chartwindow.x2 * .77F),
                        (short)(myenv.chartwindow.y2 * .50F), 12, "USA");
        getch();
        _clearscreen(_GCLEARSCREEN);

        _pg_resetpalette();           /* Default palette  */
        _pg_resetstyleset();          /* Default styleset */

        _pg_defaultchart(&myenv, _PG_PIECHART, _PG_PERCENT);
        strcpy(myenv.maintitle.title, "Soybean Consumption");
        _pg_chartpie(&myenv, catgs, my1data, explode, 4);
        getch();
        _clearscreen(_GCLEARSCREEN);

        _pg_defaultchart(&myenv, _PG_COLUMNCHART, _PG_PLAINBARS);
        strcpy(myenv.maintitle.title, "Soybean Consumption");
        _pg_chart(&myenv, catgs, my1data, 4);
        getch();
        _clearscreen(_GCLEARSCREEN);

        _pg_defaultchart (&myenv, _PG_SCATTERCHART, _PG_POINTONLY);
        strcpy(myenv.maintitle.title, "Soybeans vs. Peanuts");
        strcpy(myenv.xaxis.axistitle.title, "Peanuts");
        strcpy(myenv.yaxis.axistitle.title, "Soybeans");
        _pg_chartscatter(&myenv, Peanuts, Soybeans, 4);
        getch();
        _clearscreen(_GCLEARSCREEN);

        _setvideomode(_DEFAULTMODE);
    }

See Also: _pg_getpalette() _pg_initchart() _pg_resetpalette()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson