void createStatColors() { init_color(_NORM_BACK, 0, 0, 0); init_color(_NORM_TEXT, 900, 900, 900); init_pair(Color::norm, _NORM_TEXT, _NORM_BACK); }
void set_gbase_surf(t_mod *mod, t_obj *obj) { t_base *base; (void)mod; if (!obj) error(NUL, "set_gbase.c", "obj", TXT_YELLOW); base = &(obj->g_base); base->o.x = -120.; base->o.y = mod->dist; base->o.z = -60.; base->o.col = NULL; if (!(base->o.col = init_color(NULL, WHITE))) error(MALLOC, "set_gbase.c", "o.col", TXT_YELLOW); base->i.x = -120.309082; base->i.y = mod->dist + 0.950684; base->i.z = -60.000031; base->i.col = NULL; if (!(base->i.col = init_color(NULL, RED))) error(MALLOC, "set_gbase.c", "i.col", TXT_YELLOW); base->j.x = -120.904053; base->j.y = mod->dist - (1. - 0.706299); base->j.z = -60.308853; base->j.col = NULL; if (!(base->j.col = init_color(NULL, BLUE))) error(MALLOC, "set_gbase.c", "j.col", TXT_YELLOW); base->k.x = -120.293945; base->k.y = mod->dist - (1. - 0.904541); base->k.z = -59.048950; base->k.col = NULL; if (!(base->k.col = init_color(NULL, BLUE))) error(MALLOC, "set_gbase.c", "k.col", TXT_YELLOW); }
void init_colored_cursing () { TRACEIN; if (has_colors() == false) { terminate_cursing(); fprintf(stderr, "Your terminal does not support colors.\n"); fail(); } if (can_change_color() == false) { terminate_cursing(); fprintf(stderr, "Your terminal does not support change_color.\n"); fail(); } start_color (); assert (COLOR_PAIRS > 10); /* RGB vals found in http://cloford.com/resources/colours/500col.htm */ init_color(BLUE1, 202, 225, 255); init_color(BLUE2, 72, 118, 255); init_color(BLUE3, 65, 105, 225); init_color(BLUE4, 61, 89, 171); init_color(BLUE5, 25, 25, 112); init_pair(COLPAIR4TEXT, COLOR_BLACK, -1); init_pair(COLPAIR1VAL, BLUE1, -1); init_pair(COLPAIR2VAL, BLUE2, -1); init_pair(COLPAIR3VAL, BLUE3, -1); init_pair(COLPAIR4VAL, BLUE4, -1); init_pair(COLPAIR5VAL, BLUE5, -1); attron(COLOR_PAIR(COLPAIR4TEXT)); TRACEOUT; }
int main(const int ac, const char **av) { if (ac != 1) std::cerr << "Error: " << av[0] << " too many arguments." << std::endl; initscr(); //init ncurses if (has_colors() == FALSE) return (0); start_color(); init_color(COLOR_BLUE, 956, 529, 529); init_color(COLOR_MAGENTA, 1000, 974, 533); init_color(COLOR_CYAN, 416, 965, 686); init_pair(1, COLOR_RED, COLOR_BLACK); //Display Player init_pair(2, COLOR_CYAN, COLOR_BLACK); //DISPLAY ENEMY UNIT init_pair(3, COLOR_GREEN, COLOR_BLACK); //DISPLAY ENEMY UNIT MISSILE init_pair(4, COLOR_MAGENTA, COLOR_BLACK); //DISPLAY OBSTACLE init_pair(5, COLOR_YELLOW, COLOR_BLACK); //DISPLAY PLAYER MISSILE noecho(); srand(static_cast<unsigned int>(time(0))); // raw(); //do not set while debuging or tests curs_set(FALSE); setlocale(LC_ALL, ""); //handle special symbol as 卐 timeout(60); //to do set a timeout define keypad(stdscr, TRUE);// add special chars as F{1-12} gameLoop(); endwin(); //end window return (0); }
//TODO: Come up with a solution that is guaranteed to work when multiple threads are running void sighandler(int sig) { init_color(COLOR_WHITE, white.r, white.g, white.b); init_color(COLOR_BLACK, black.r, black.g, black.b); int ret1 = init_color(COLOR_RED, red.r, red.g, red.b); init_color(COLOR_GREEN, green.r, green.g, green.b); init_color(COLOR_YELLOW, yellow.r, yellow.g, yellow.b); //FILE *fp; //fp = fopen("/home/dobyrch/Documents/termboy/out.log", "w"); //fprintf(fp, "In handler\n"); //fprintf(fp, "Setting color: %d\n", ret1); endwin(); //fprintf(fp, "Closed window\n"); init_color(COLOR_WHITE, white.r, white.g, white.b); init_color(COLOR_BLACK, black.r, black.g, black.b); int ret2 = init_color(COLOR_RED, red.r, red.g, red.b); init_color(COLOR_GREEN, green.r, green.g, green.b); init_color(COLOR_YELLOW, yellow.r, yellow.g, yellow.b); //fprintf(fp, "Setting color: %d\n", ret2); inputManager->restoreKeyboard(); //fprintf(fp, "Restored keyboard\n"); utility->unload(); //fprintf(fp, "Unloaded game\n"); //fprintf(fp, "Caught signal: %d\n", sig); //fprintf(fp, "Printed signal\n"); //fclose(fp); exit(0); }
void *InitRender(void) { int gcol[] = { COLOR_RED, COLOR_GREEN, COLOR_MAGENTA, COLOR_CYAN, }; int i; initscr(); cbreak(); noecho(); nodelay(stdscr, TRUE); curs_set(0); if (has_colors()) { fprintf(stderr, "Color console in use\n"); start_color(); init_pair(PC_PACMAN, COLOR_YELLOW, COLOR_BLACK); init_pair(PC_WALL, COLOR_BLUE, COLOR_BLACK); init_pair(PC_EDIBLE_GHOST, COLOR_MAGENTA, COLOR_BLACK); init_pair(PC_PILL, COLOR_CYAN, COLOR_BLACK); init_pair(PC_POWERPILL, COLOR_WHITE, COLOR_BLACK); init_pair(PC_WHITE, COLOR_WHITE, COLOR_BLACK); if (can_change_color()) { init_color(COLOR_GREEN, 1000,644,888); init_color(COLOR_MAGENTA, 1000,888,970); init_color(COLOR_CYAN, 1000,644,285); } else { fprintf(stderr, "Ghosts colors will not be accurate because TTY doesn't support init_color\n"); } for(i=0; i<MAX_GHOSTS; i++) init_pair(PC_GHOST+i, gcol[i%sizeof(gcol)], COLOR_BLACK); } else { fprintf(stderr, "Black and white console in use\n"); } return NULL; }
void color_init(void) { start_color(); init_color(COLOR_WHITE, 999, 999, 999); init_color(COLOR_MAGENTA, 400, 400, 400); init_color(COLOR_YELLOW, 999, 500, 0); init_color(COLOR_BLUE, 0, 400, 999); init_color(COLOR_GREEN, 0, 500, 0); init_pair(1, COLOR_RED, COLOR_BLACK); init_pair(5, COLOR_WHITE, COLOR_RED); init_pair(2, COLOR_GREEN, COLOR_BLACK); init_pair(6, COLOR_WHITE, COLOR_GREEN); init_pair(3, COLOR_YELLOW, COLOR_BLACK); init_pair(7, COLOR_WHITE, COLOR_YELLOW); init_pair(4, COLOR_BLUE, COLOR_BLACK); init_pair(8, COLOR_WHITE, COLOR_BLUE); init_pair(10, COLOR_MAGENTA, COLOR_MAGENTA); init_pair(11, COLOR_MAGENTA, COLOR_BLACK); init_pair(12, COLOR_WHITE, COLOR_BLACK); init_pair(13, COLOR_BLACK, COLOR_MAGENTA); init_pair(14, COLOR_BLACK, COLOR_RED); init_pair(15, COLOR_BLACK, COLOR_GREEN); init_pair(16, COLOR_BLACK, COLOR_YELLOW); init_pair(17, COLOR_BLACK, COLOR_BLUE); }
OutputVisualizer::OutputVisualizer(utils::GeneralOptions general_options) { // Initialize console window initscr(); // Disable character echoing noecho(); // Hide cursor this->original_cursor_state_ = curs_set(0); // Activate special keyboard keys keypad(stdscr, TRUE); // Disable input line buffering cbreak(); // Make input calls non-blocking nodelay(stdscr, true); // Initialize colors if (has_colors()) { start_color(); // Define color pair 1 as white on blue init_pair(1, COLOR_WHITE, COLOR_BLUE); // Define color pair 2 as blue on white init_pair(2, COLOR_BLUE, COLOR_WHITE); /* * Redefine colors if terminal supports it * (We only have 8 colors available, so the names might be a bit unfitting) */ init_color(COLOR_RED, 933, 461, 0); // Dark Orange init_color(COLOR_YELLOW, 1000, 645, 0); // Light Orange // Define color pair 3 and 4 for use in the diagram init_pair(3, COLOR_WHITE, COLOR_RED); init_pair(4, COLOR_WHITE, COLOR_YELLOW); int rows, cols; // retrieve window size getmaxyx(stdscr, rows, cols); this->rows_ = rows; this->cols_ = cols; refresh(); create_top_window(); create_main_window(); } else { failed_ = true; } }
void curses_init_nhcolors() { #ifdef TEXTCOLOR if (has_colors()) { use_default_colors(); init_pair(1, COLOR_BLACK, -1); init_pair(2, COLOR_RED, -1); init_pair(3, COLOR_GREEN, -1); init_pair(4, COLOR_YELLOW, -1); init_pair(5, COLOR_BLUE, -1); init_pair(6, COLOR_MAGENTA, -1); init_pair(7, COLOR_CYAN, -1); init_pair(8, -1, -1); if (COLORS >= 16) { init_pair(9, COLOR_WHITE, -1); init_pair(10, COLOR_RED + 8, -1); init_pair(11, COLOR_GREEN + 8, -1); init_pair(12, COLOR_YELLOW + 8, -1); init_pair(13, COLOR_BLUE + 8, -1); init_pair(14, COLOR_MAGENTA + 8, -1); init_pair(15, COLOR_CYAN + 8, -1); init_pair(16, COLOR_WHITE + 8, -1); } if (can_change_color()) { init_color(COLOR_YELLOW, 500, 300, 0); init_color(COLOR_WHITE, 600, 600, 600); if (COLORS >= 16) { init_color(COLOR_RED + 8, 1000, 500, 0); init_color(COLOR_GREEN + 8, 0, 1000, 0); init_color(COLOR_YELLOW + 8, 1000, 1000, 0); init_color(COLOR_BLUE + 8, 0, 0, 1000); init_color(COLOR_MAGENTA + 8, 1000, 0, 1000); init_color(COLOR_CYAN + 8, 0, 1000, 1000); init_color(COLOR_WHITE + 8, 1000, 1000, 1000); #ifdef USE_DARKGRAY if (COLORS > 16) { init_color(CURSES_DARK_GRAY, 300, 300, 300); } #endif } else { /* Set flag to use bold for bright colors */ } } } #endif }
// general: cleanup void cleanup_terminal_ncurses(void) { echo(); system("setfont >/dev/null 2>&1"); system("setfont /usr/share/consolefonts/Lat2-Fixed16.psf.gz >/dev/null 2>&1"); system("setterm -blank 10"); init_color(1, 1000, 0, 0); init_color(2, 0, 1000, 0); endwin(); system("clear"); }
void init_term_gui(void) { /* Fix ESC key */ set_escdelay(25); initscr(); start_color(); cbreak(); noecho(); if (can_change_color()) { init_color(XS_COLOR_BLUE, 43, 180, 349); init_color(XS_COLOR_RED, 886, 27, 124); init_pair(XS_COLOR_PAIR_1, COLOR_WHITE, XS_COLOR_RED); init_pair(XS_COLOR_PAIR_2, COLOR_WHITE, XS_COLOR_BLUE); } else{ init_pair(XS_COLOR_PAIR_1, COLOR_WHITE, COLOR_RED); init_pair(XS_COLOR_PAIR_2, COLOR_WHITE, COLOR_BLUE); } /* int max_rows; */ /* int max_cols; */ /* getmaxyx(stdscr, max_rows, max_cols); */ show_recent_apps(); prepare_for_new_results(False); mvprintw(0, 0, "$"); mvwprintw(window, MAX_Y - 2, 0, "Loading paths..."); refresh(); field[0] = new_field( 1, // columns 20, // width 0, // pos y 2, // pos x 0, 0 ); /* Hide cursor */ curs_set(0); set_field_fore(field[0], COLOR_PAIR(XS_COLOR_PAIR_2)); field[1] = NULL; form = new_form(field); post_form(form); wrefresh(window); }
void vm_nc_init_color(void) { init_color(COL_GREY, 300, 300, 300); init_color(COL_RED, 600, 0, 0); init_color(COL_LIGHT_RED, 1000, 300, 300); init_color(COL_GREEN, 0, 600, 0); init_color(COL_LIGHT_GREEN, 300, 1000, 300); init_color(COL_BLUE, 0, 0, 600); init_color(COL_LIGHT_BLUE, 300, 300, 1000); init_color(COL_YELLOW, 600, 600, 0); init_color(COL_LIGHT_YELLOW, 1000, 1000, 300); init_color(COL_WHITE, 1000, 1000, 1000); vm_nc_init_pair(); }
void preferences_dialog_init (void) { // General preferences init_toggle ("echo_checkbutton", PREF_ECHO); init_toggle ("sneak_checkbutton", PREF_AUTO_SNEAK); init_toggle ("log_checkbutton", PREF_AUTO_LOG); init_spin ("text_buffer_size_spinbutton", PREF_TEXT_BUFFER_SIZE); init_spin ("command_size_spinbutton", PREF_COMMAND_SIZE); init_spin ("history_size_spinbutton", PREF_COMMAND_HISTORY_SIZE); init_entry ("script_prefix_entry", PREF_SCRIPT_PREFIX); // Colors init_color ("monster_text_box", PREF_MONSTER_TEXT_COLOR); init_color ("monster_base_box", PREF_MONSTER_BASE_COLOR); init_font ("monster_font_box", PREF_MONSTER_FONT); init_color ("title_text_box", PREF_TITLE_TEXT_COLOR); init_color ("title_base_box", PREF_TITLE_BASE_COLOR); init_font ("title_font_box", PREF_TITLE_FONT); init_color ("echo_text_box", PREF_ECHO_TEXT_COLOR); init_color ("echo_base_box", PREF_ECHO_BASE_COLOR); init_font ("echo_font_box", PREF_ECHO_FONT); init_color ("default_text_box", PREF_DEFAULT_TEXT_COLOR); init_color ("default_base_box", PREF_DEFAULT_BASE_COLOR); init_font ("default_font_box", PREF_DEFAULT_FONT); // Paths init_file ("script_path_filechooserbutton", PREF_SCRIPT_PATH); init_file ("log_path_filechooserbutton", PREF_LOG_PATH); }
PRIVATE void viewP_initColor() { short bg, fg, i; colorSupport = (has_colors() << 0) | (can_change_color() << 1); if (!colorSupport) return; start_color(); /* Colores por defecto en el '0' */ use_default_colors(); init_pair(0, -1, -1); /* Paleta de colores basicos, definidos en la cabezera */ init_color(0, 0, 0, 0); /* BLACK */ init_color(1, 1000, 0, 0); /* RED */ init_color(2, 0, 1000, 0); /* GREEN */ init_color(3, 1000, 1000, 0); /* YELLOW */ init_color(4, 0, 0, 1000); /* BLUE */ init_color(5, 1000, 0, 1000); /* MAGENTA */ init_color(6, 0, 1000, 1000); /* CYAN */ init_color(7, 1000, 1000, 1000); /* WHITE */ /* Inicializacion colores de usuario */ for (i = 0; i < 8; i++) viewG_defColor(i, 0, 0, 0); /* Creacion de paleta de colores (256 en total) */ for (bg=0x0; bg <= 0xF; bg++) for (fg=0x0; fg <= 0xF; fg++) { if (fg || bg) init_pair((short)((bg<<4)|fg), fg, bg); } }
int init_terminal_ncurses(char *color, char *bcolor, int predefcol, int predefbgcol) { struct cols col, bgcol; initscr(); curs_set(0); timeout(0); noecho(); start_color(); use_default_colors(); double magic = 1000 / 255.0; int colp = 0, bgcolp = 0; col = parse_color(color); bgcol = parse_color(bcolor); if (col.col == -2) { init_color(1, (int)(col.R * magic), (int)(col.G * magic), (int)(col.B * magic)); } if (bgcol.col == -2) { init_color(2, (int)(bgcol.R * magic), (int)(bgcol.G * magic), (int)(bgcol.B * magic)); } switch (col.col) { case -2: colp = 1; break; case -1: colp = DEFAULTCOL; break; default: colp = predefcol; } switch (bgcol.col) { case -2: bgcolp = 2; break; case -1: bgcolp = DEFAULTBGCOL; break; default: bgcolp = predefbgcol; } init_pair(1, colp, bgcolp); if (bgcolp != -1) bkgd(COLOR_PAIR(1)); attron(COLOR_PAIR(1)); // attron(A_BOLD); return 0; }
void Program::init_curses() { setlocale(LC_ALL, ""); //window = subwin(initscr(), 200, 200, 0, 0); window= initscr(); start_color(); timeout(0); noecho(); /*if (!has_colors() || ! can_change_color()) { //TODO: Add descriptive error message, clean up exit(EXIT_FAILURE); }*/ color_content(COLOR_WHITE, &white.r, &white.g, &white.b); color_content(COLOR_BLACK, &black.r, &black.g, &black.b); color_content(COLOR_RED, &red.r, &red.g, &red.b); color_content(COLOR_GREEN, &green.r, &green.g, &green.b); color_content(COLOR_YELLOW, &yellow.r, &yellow.g, &yellow.b); init_pair(1, COLOR_BLACK, COLOR_BLACK); init_pair(2, COLOR_BLACK, COLOR_RED); init_pair(3, COLOR_BLACK, COLOR_GREEN); init_pair(4, COLOR_BLACK, COLOR_YELLOW); init_pair(5, COLOR_RED, COLOR_BLACK); init_pair(6, COLOR_RED, COLOR_RED); init_pair(7, COLOR_RED, COLOR_GREEN); init_pair(8, COLOR_RED, COLOR_YELLOW); init_pair(9, COLOR_GREEN, COLOR_BLACK); init_pair(10, COLOR_GREEN, COLOR_RED); init_pair(11, COLOR_GREEN, COLOR_GREEN); init_pair(12, COLOR_GREEN, COLOR_YELLOW); init_pair(13, COLOR_YELLOW, COLOR_BLACK); init_pair(14, COLOR_YELLOW, COLOR_RED); init_pair(15, COLOR_YELLOW, COLOR_GREEN); init_pair(16, COLOR_YELLOW, COLOR_YELLOW); init_color(COLOR_WHITE, 0, 0, 0); init_color(COLOR_BLACK, 0, 0, 0); init_color(COLOR_RED, 333, 333, 333); init_color(COLOR_GREEN, 667, 667, 667); init_color(COLOR_YELLOW, 1000, 1000, 1000); erase(); }
void Window::open( void ) { if (opened == true) return ; opened = true; initscr(); struct winsize w; ioctl(0, TIOCGWINSZ, &w); main_window = newwin(w.ws_row, w.ws_col, 0, 0); keypad(main_window, TRUE); window_white = derwin(main_window, w.ws_row, w.ws_col, 0, 0); start_color(); init_color(COLOR_ORANGE, 1000, 549, 0); init_color(COLOR_VIOLET, 580, 0, 827); init_color(COLOR_GREY, 302, 302, 302); init_pair(1, COLOR_RED, COLOR_BLACK); init_pair(2, COLOR_GREEN, COLOR_BLACK); init_pair(3, COLOR_BLUE, COLOR_BLACK); init_pair(4, COLOR_YELLOW, COLOR_BLACK); init_pair(5, COLOR_WHITE, COLOR_BLACK); init_pair(6, COLOR_MAGENTA, COLOR_BLACK); init_pair(7, COLOR_CYAN, COLOR_BLACK); init_pair(8, COLOR_BLACK, COLOR_RED); init_pair(9, COLOR_BLACK, COLOR_GREEN); init_pair(10, COLOR_BLACK, COLOR_BLUE); init_pair(11, COLOR_BLACK, COLOR_YELLOW); init_pair(12, COLOR_BLACK, COLOR_WHITE); init_pair(13, COLOR_BLACK, COLOR_MAGENTA); init_pair(14, COLOR_BLACK, COLOR_CYAN); init_pair(15, COLOR_ORANGE, COLOR_BLACK); init_pair(16, COLOR_BLACK, COLOR_ORANGE); init_pair(17, COLOR_VIOLET, COLOR_BLACK); init_pair(18, COLOR_BLACK, COLOR_VIOLET); init_pair(19, COLOR_GREY, COLOR_BLACK); init_pair(20, COLOR_BLACK, COLOR_GREY); noecho(); curs_set(FALSE); nodelay(main_window, TRUE); }
SysinfoPlugin* sysinfo_data_plugin_init() { //repetition if the plugin is loaded up multiple times, but it's really //quite irrelevant logscale = 1/log(1.8); SysinfoPlugin* plugin = g_new(SysinfoPlugin, 1); plugin->plugin_name = "Net Load"; plugin->num_data = DATA_FIELDS; plugin->data_names = data_names; init_color(plugin); plugin->plugin_data = init_data(); plugin->close = &close; plugin->get_data = &get_data; plugin->get_range = &get_range; plugin->reset_colors = &net_reset_colors; plugin->get_tooltip = &net_get_tooltip; return plugin; }
static void term_refresh() { // to set up a 256-color terminal, see: // http://push.cx/2008/256-color-xterms-in-ubuntu if (0 && can_change_color()) { int i; for (i = 0; i < 16; i++) { short r = palette[i].r * 1000; short g = palette[i].g * 1000; short b = palette[i].b * 1000; if (r < 0) r = 0; if (g < 0) g = 0; if (b < 0) b = 0; init_color(i + 1, r, g, b); } } if (0) { int i; short r, g, b; for (i = 0; i < 8; i++) { color_content(i, &r, &g, &b); palette[i].r = r * .001; palette[i].g = g * .001; palette[i].b = b * .001; } } if (colormode == coerce_256) { buffer_render_256(); } refresh(); }
/* * React to changes */ static errr Term_xtra_gcu_react(void) { #ifdef A_COLOR int i; /* Cannot handle color redefinition */ if (!can_fix_color) return (0); /* Set the colors */ for (i = 0; i < 16; i++) { /* Set one color (note scaling) */ init_color(i, angband_color_table[i][1] * 1000 / 255, angband_color_table[i][2] * 1000 / 255, angband_color_table[i][3] * 1000 / 255); } #endif /* Success */ return (0); }
static bool get_color (const ui_file_style::color &color, int *result) { if (color.is_none ()) *result = -1; else if (color.is_basic ()) *result = curses_colors[color.get_value ()]; else { auto it = color_map.find (color); if (it == color_map.end ()) { /* The first 8 colors are standard. */ int next = color_map.size () + 8; if (next >= COLORS) return false; uint8_t rgb[3]; color.get_rgb (rgb); /* We store RGB as 0..255, but curses wants 0..1000. */ if (init_color (next, rgb[0] * 1000 / 255, rgb[1] * 1000 / 255, rgb[2] * 1000 / 255) == ERR) return false; color_map[color] = next; *result = next; } else *result = it->second; } return true; }
void calc_light(t_param *param, t_info *info, t_list *spot) { t_info *light; t_spot *o_spot; t_lum lum; int *s_color; if (info->distance < 0) return ; s_color = init_color(); while (spot) { o_spot = (t_spot *)spot->content; light = init_light(info, o_spot); calc_intersection(param, light); if (point_cmp(info->r_pos, light->r_pos) == 1) { lum.fading = ft_abs(calc_fading(light->r_line.vec, info->vec_n)); lum.shining = ft_abs(calc_shining(info->vec_n, light->r_line.vec)); info->light += o_spot->value * lum.fading; info->light += o_spot->value * lum.shining * lum.fading; calc_color(&s_color, o_spot->color, o_spot->value, lum.fading); } spot = spot->next; } info->color = retrieve_col(s_color, damer(param, info, info->s_pos), get_shine(info)); }
void TUNNEL::CreateNewCube() { if (frand > creation_properties.creation_chance) return; float radius = creation_properties.radius.span*frand+creation_properties.radius.min; float angle = frand*2*pi; D3DXVECTOR3 init_pos( -creation_properties.boundary, radius*cos(angle), radius*sin(angle)); D3DXVECTOR3 init_scale( creation_properties.scale.span.x*frand+creation_properties.scale.min.x, creation_properties.scale.span.y*frand+creation_properties.scale.min.y, creation_properties.scale.span.z*frand+creation_properties.scale.min.z); D3DXCOLOR init_color( creation_properties.color.span.r*frand+creation_properties.color.min.r, creation_properties.color.span.g*frand+creation_properties.color.min.g, creation_properties.color.span.b*frand+creation_properties.color.min.b, 1.0f); //D3DXCOLOR(0.909f, 0.0f, 0.592f, 1.0f);// CUBE* new_cube = new CUBE( graphics, init_pos, init_scale, init_color, creation_properties.speed.span*frand+creation_properties.speed.min, creation_properties.boundary); cube_array.push_back(new_cube); }
void check_arg(char **av, t_img *img, t_frac *frac) { if (av[2]) frac->max_iter = ft_atoi(av[2]); init_color(frac, av); if (ft_strequ(av[1], "mandel") == 1) { set_mandel(frac); draw_mandelbrot(img, frac); } else if (ft_strequ(av[1], "julia") == 1) { set_julia(frac); draw_julia(img, frac); } else if (ft_strequ(av[1], "ship") == 1) { set_ship(frac); draw_ship(img, frac); } else if (ft_strequ(av[1], "triangle") == 1) { set_triangle(frac); draw_sierpinski(img, frac); } else exit(0); }
void print_map(t_info *s) { t_point p1; t_point p2; while (s->y < s->x_lines) { while (s->x < s->y_lines) { p1 = calcul(s->x, s->y, s->tab[s->y][s->x], s); s->x++; init_color(s, s->tab[s->y][s->x]); if (s->x < s->y_lines) { p2 = calcul(s->x, s->y, s->tab[s->y][s->x], s); print_trace(p1, p2, s); } if (s->y < s->x_lines - 1) { p2 = calcul(s->x - 1, s->y + 1, s->tab[s->y + 1][s->x - 1], s); print_trace(p1, p2, s); } } s->x = 0; s->y++; } }
int main(int argc, char **argv) { (void)argc; (void)argv; /* open connection with the server */ nil_.con = xcb_connect(0, 0); if (xcb_connection_has_error(nil_.con)) { NIL_ERR("xcb_connect %p", (void *)nil_.con); exit(1); } /* 1st stage */ if ((init_screen() != 0) || (init_key() != 0) || (init_mouse() != 0)) { xcb_disconnect(nil_.con); exit(1); } /* 2nd stage */ if ((init_cursor() != 0) || (init_color() != 0) != (init_font() != 0) || (init_bar() != 0) || (init_wm() != 0)) { cleanup(); exit(1); } xcb_flush(nil_.con); recv_events(); cleanup(); return 0; }
/******* Fonction à écrire par les etudiants ******/ Color compute_direct_lighting (Ray ray_, Isect isect_) { /** * \todo : compute here direct lighting * * Le rôle de la fonction compute_direct_lighting() est de calculer la somme, pour chaque source de lumière de la scène, de l'éclairage * élémentaire dû à cette source. Cette somme est calculée en ajoutant à une couleur noire (triplet \b RGB [0, 0, 0], élément neutre de * l'addition des couleurs), la valeur de l'éclairage direct lié à chaque source de la scène. La fonction compute_direct_lighting() * utilise pour cela les fonctions des modules \ref SceneAPI (pour accéder à l'ensemble des sources lumineuses de la scène), * \ref RayAPI (pour calculer la visibilité entre un point et une source de lumière) et \ref LightAPI (pour calculer l'éclairage direct). */ Color l; int i, isVisi; Light* light_; l = init_color (0.f, 0.f, 0.f); for (i=0; i<nb_lights(); i++){ light_ = get_light(i); isVisi = test_visibility ( isect_, light_); if (isVisi!=0){ l = l+direct_lighting (ray_, isect_, light_); } } return l; }
t_color apply_refraction(t_ray *start, t_scene *scene, t_hit drawn_pixel, double noise) { double refract_indice; t_color tmp_color; int test; tmp_color = drawn_pixel.color; if (drawn_pixel.t_max == drawn_pixel.t) { refract_indice = drawn_pixel.ref_index; test = -1; } else { test = 1; refract_indice = 1.0 / drawn_pixel.ref_index; } *start = find_refract_vect(start, drawn_pixel, refract_indice, test); if (get_length(start->dir) != 0) { if (scene->is_real == CARTOON && is_black_edge(&drawn_pixel)) { tmp_color = init_color(0, 0, 0); return (tmp_color); } else tmp_color = add_color(tmp_color, color_render(scene, start, noise, NULL)); } check_color(&tmp_color); return (tmp_color); }
/** * Setup the colors used in the game. */ static void init_colors(void) { if (has_colors() != FALSE) { start_color(); } if (can_change_color()) { init_color(COLOR_MAGENTA, 1000, 600, 1000); init_color(COLOR_GREY, 300, 300, 300); } /* define used color pairs */ init_pair(ColorMagenta, COLOR_MAGENTA, COLOR_BLACK); init_pair(ColorRed, COLOR_RED, COLOR_BLACK); init_pair(ColorYellow, COLOR_YELLOW, COLOR_BLACK); init_pair(ColorBlue, COLOR_BLUE, COLOR_BLACK); init_pair(ColorGrey, COLOR_GREY, COLOR_BLACK); }
void PlantsWindow::set_color() { QString color_str = toQString(selected_plant().get_color_str()); QColor init_color(color_str); QColor color = color_dialog->getColor(init_color, this); selected_plant().set_color_str(fromQString(color.name())); emit timeline_need_update(); }