/*
          __
         / /_______________  ____  ___
        / __/ ___/ ___/ __ \/ __ \/ _ \
       / /_(__  ) /__/ /_/ / /_/ /  __/
       \__/____/\___/\____/ .___/\___/
                         /_/

    graphics2.c
    using the return value of parameter functions
*/

#include <tscope.h>


// prints some text in a new color, and restores the color
void function_a()
{
    int oldcolor;
    oldcolor = ts_fgcolor(RED);
    ts_printf_centre(0, 80, "function A prints in red");
    ts_printf_centre(0, 60, "and restores the old color value");
    ts_fgcolor(oldcolor);
}

// prints some text in a new color, doesn't restore old color
void function_b()
{
    ts_fgcolor(BLUE);
    ts_printf_centre(0, 80, "function B prints in blue");
    ts_printf_centre(0, 60, "and doesn't restore the old color value");
}


int main()
{
    ts_init();

    // call function A
    ts_printf_centre(0, 100, "default, text is white");
    function_a();
    ts_printf_centre(0, 40, "function A has no influence on the");
    ts_printf_centre(0, 20, "text/drawing done by other functions");
    ts_button(XMAX - 20, -YMAX + 20);
    ts_clrscr();

    // call function B
    ts_printf_centre(0, 100, "default, text is white");
    function_b();
    ts_printf_centre(0, 40, "all subsequent text/drawing");
    ts_printf_centre(0, 20, "will have function B's color");

    ts_button(XMAX - 20, -YMAX + 20);
    return 0;
}

END_OF_MAIN();


top
Persoonlijke pagina Universiteit GentTscope
Allegro | Cygwin | Gcc
© See license.html for copyright information