t_color get_reflect(t_scene scene, t_vector ray, t_obj object, t_point inter) { t_color color; t_color new_col; double dist; color = new_color(0, 0, 0); scene.refl *= object.brightness; if (scene.depth-- == 0 || scene.refl < 0.01) return (color); dist = -1; ray.dir = vec_dir(inter, get_symetric(ray.origin, new_vector(inter, object.normal(object, inter, ray)))); ray.origin = inter; if (find_closest_inter(scene.lst_obj, &object, &dist, ray) < 0) return (color); inter = new_point(ray.origin.x + dist * ray.dir.x, ray.origin.y + dist * ray.dir.y, ray.origin.z + dist * ray.dir.z); new_col = get_first_ray(scene, ray, object, inter); color = get_ambiant_light(scene, ray, object, inter); color = new_color(scene.refl * new_col.red + color.red, scene.refl * new_col.blue + color.blue, scene.refl * new_col.green + color.green); return (new_color(new_col.red + color.red, new_col.blue + color.blue, new_col.green + color.green)); }
void load_scene5_lights(t_scene *scene) { scene->amb_intensity = 0.3; scene->amb_color = new_color(BLUE); add_light(scene, new_light(SPOT, 1, new_vector(-20, 15, 10), new_color(WHITE))); add_light(scene, new_light(DIR, 0.5, new_vector(0, -1, -1), new_color(WHITE))); }
void load_scene5_objects(t_scene *scene) { add_object(scene, new_object(CONE, new_cone(new_vector(0, 1, -0.5), new_vector(8, 4, -5), 30), new_color(LIGHT_BLUE), 100)); add_object(scene, new_object(CYLINDER, new_cylinder(new_vector(0, 1, -0.3), new_vector(-10, 0, -5), 2), new_color(PASTEL_BLUE), 100)); add_object(scene, new_object(SPHERE, new_sphere(-1, 3, 2, 2), new_color(BLUE), 100)); add_object(scene, new_object(PLANE, new_plane(0, -1, 0, 0), new_color(DARK_GREY), 100)); }
t_color get_first_ray(t_scene scene, t_vector ray, t_obj object, t_point inter) { t_color reflect; t_color refract; if (scene.depth-- == 0 || scene.refl < 0.01) return (new_color(0, 0, 0)); reflect = get_reflect(scene, ray, object, inter); refract = get_refract(scene, ray, object, inter); return (new_color(reflect.red + refract.red, reflect.blue + refract.blue, reflect.green + refract.green)); }
bool is_tile_solid_color(const graphics::texture& t, int tile_num, graphics::color& col) { bool first = true; const int width = std::max<int>(t.width(), t.height()); const int xpos = 16*(tile_num%(width/16)); const int ypos = 16*(tile_num/(width/16)); for(int y = 0; y != 16; ++y) { const int v = ypos + y; for(int x = 0; x != 16; ++x) { const int u = xpos + x; const unsigned char* color = t.color_at(u, v); ASSERT_LOG(color != NULL, "COULD NOT FIND COLOR IN TEXTURE"); graphics::color new_color(color[0], color[1], color[2], color[3]); if(new_color.a() != 0xFF) { return false; } if(first || col.rgba() == new_color.rgba()) { col = new_color; first = false; } else { return false; } } } return true; }
t_color get_ambiant_light(t_scene scene, t_vector ray, t_obj object, t_point inter) { t_llst *tmp; t_point light_inter; double norm; tmp = scene.lst_light; scene.color = new_color(0, 0, 0); while (tmp) { light_inter = new_point(inter.x - tmp->light->body.center.x, inter.y - tmp->light->body.center.y, inter.z - tmp->light->body.center.z); norm = sqrt(pow(light_inter.x, 2) + pow(light_inter.y, 2) + pow(light_inter.z, 2)); scene.normal = object.normal(object, inter, ray); light_inter = new_point((double)light_inter.x / norm, light_inter.y / norm, light_inter.z / norm); scene.scal = scalar_prod(light_inter, scene.normal); scene.ray = ray.dir; if (norm_is_shit(scene, *(tmp->light), inter, norm) && scene.scal >= 0.000000000000000000001) scene.color = calc_color(get_spec(scene, *(tmp->light), light_inter, object), object.texturing(object, inter, ray), *(tmp->light), scene.scal); tmp = tmp->next; } return (scene.color); }
void PLAYER::init(int id, int faction, int start_resources) { this->id = id; this->faction = faction; resources = start_resources; color = new_color(id); }
static int k_any(Ihandle *ih, int c) { switch(c) { case K_m: IupSetGlobal("PARENTDIALOG", "_MAIN_DIALOG_TEST_"); IupMessage("IupMessage Test", "Message Text\nSecond Line."); IupSetGlobal("PARENTDIALOG", NULL); break; case K_e: new_message("ERROR", NULL); break; case K_i: new_message("INFORMATION", NULL); break; case K_w: new_message("WARNING", "OKCANCEL"); break; case K_q: new_message("QUESTION", "YESNO"); break; case K_c: new_color(); break; case K_f: new_font(); break; case K_o: new_file("OPEN", 0); break; case K_O: new_file("OPEN", 1); break; case K_G: new_file("OPEN", 2); break; case K_s: new_file("SAVE", 0); break; case K_d: new_file("DIR", 0); break; case K_a: new_alarm(); break; case K_g: new_getfile(); break; case K_t: new_gettext(); break; case K_l: new_list(); break; case K_ESC: IupDestroy(ih); return IUP_IGNORE; } return IUP_DEFAULT; }
void IllusionExcelFile::SetCellColor(long irow, long icolumn,long color){ COleVariant new_color((long)color); excel_current_range_.ReleaseDispatch(); excel_current_range_ = excel_work_sheet_.get_Range(COleVariant(RCString(irow,icolumn)),covOptional); CFont0 font = excel_current_range_.get_Font(); font.put_Color(new_color); }
void IllusionExcelFile::SetCellBackground(int red,int green,int blue){ if(red>255)red=255;else if(red<0)red = 0; if(green>255)green=255;else if(green<0)green = 0; if(blue>255)blue=255;else if(blue<0)blue = 0; COleVariant new_color((long)(blue<<16)|(green<<8)|red); Cnterior it; it.AttachDispatch(excel_current_range_.get_Interior()); it.put_Color(new_color); }
void OptionDlg::rgbChange() { if (m_loading) return; QColor new_color(m_wRed->value(), m_wGreen->value(), m_wBlue->value()); m_wColorEdit->setText(new_color.name()); updateColorFace(); updateExColor(true); }
void load_scene5(t_env *e) { if (e->scene) delete_scene(e->scene); e->scene_type = SCENE_5; e->scene = new_scene(new_color(BLACK), new_camera(0, 4, 20)); load_scene5_objects(e->scene); load_scene5_lights(e->scene); }
static t_color calc_color(t_color color, t_color obj_color, t_light light, double scalar) { return (new_color(color.red + obj_color.red * scalar * light.color.red / 255 * light.intensity, color.blue + obj_color.blue * scalar * light.color.blue / 255 * light.intensity, color.green + obj_color.green * scalar * light.color.green / 255 * light.intensity)); }
void IllusionExcelFile::SetCellColor(long irow, long icolumn, int red, int green, int blue){ if(red>255)red=255;else if(red<0)red = 0; if(green>255)green=255;else if(green<0)green = 0; if(blue>255)blue=255;else if(blue<0)blue = 0; COleVariant new_color((long)(blue<<16)|(green<<8)|red); excel_current_range_.ReleaseDispatch(); excel_current_range_ = excel_work_sheet_.get_Range(COleVariant(RCString(irow,icolumn)),covOptional); CFont0 font = excel_current_range_.get_Font(); font.put_Color(new_color); }
// A helper function reading a lua subtable of 4 float values. Color ParticleManager::_ReadColor(hoa_script::ReadScriptDescriptor& particle_script, const std::string& param_name) { std::vector<float> float_vec; particle_script.ReadFloatVector(param_name, float_vec); if (float_vec.size() < 4) { IF_PRINT_WARNING(VIDEO_DEBUG) << "Invalid color read" << std::endl; return Color(); } Color new_color(float_vec[0], float_vec[1], float_vec[2], float_vec[3]); return new_color; }
void ft_init(t_draw_suite *val) { val->reflectray = malloc(sizeof(t_pos)); val->final_color = malloc(sizeof(t_color)); val->final_color = new_color(); val->lightray = malloc(sizeof(t_ray)); val->impact = malloc(sizeof(t_ray)); val->kdiff = 0; val->kspec = 0; val->final_color->r = 0; val->final_color->g = 0; val->final_color->b = 0; }
// A helper function reading a lua subtable of 4 float values. Color ParticleEffect::_ReadColor(hoa_script::ReadScriptDescriptor& particle_script, const std::string& param_name) { std::vector<float> float_vec; particle_script.ReadFloatVector(param_name, float_vec); if (float_vec.size() < 4) { PRINT_WARNING << "Invalid color read in parameter: " << param_name << " for file: " << particle_script.GetFilename() << std::endl; return Color(); } Color new_color(float_vec[0], float_vec[1], float_vec[2], float_vec[3]); return new_color; }
static ColorData* reduce_color (void) { ColorData *color = NULL; int size = dyn_array_ptr_size (&color_merge_array); if (size == 0) color = NULL; else if (size == 1) { color = dyn_array_ptr_get (&color_merge_array, 0); } else color = new_color (FALSE); return color; }
static void change_color() { if(rc < r) ++rc; else if(rc > r) --rc; if(gc < g) ++gc; else if(gc > g) --gc; if(bc < b) ++bc; else if(bc > b) --bc; if(rc == r && gc == g && bc == b) new_color(); }
void BGHash::RefreshColor(bool skip_animation) { if (override_color_.alpha > 0.0f) { TransitionToNewColor(override_color_, skip_animation); return; } // XXX: move this part to PluginAdapter Atom real_type; gint result; gint real_format; gulong items_read; gulong items_left; gchar* colors; Display* display; GdkRGBA color_gdk; colors = nullptr; display = gdk_x11_display_get_xdisplay(gdk_display_get_default()); gdk_error_trap_push(); result = XGetWindowProperty (display, GDK_ROOT_WINDOW(), COLORS_ATOM, 0L, G_MAXLONG, False, XA_STRING, &real_type, &real_format, &items_read, &items_left, (guchar **) &colors); gdk_flush (); gdk_error_trap_pop_ignored (); if (result == Success && items_read) { gdk_rgba_parse(&color_gdk, colors); nux::Color new_color(color_gdk.red, color_gdk.green, color_gdk.blue, 1.0f); TransitionToNewColor(MatchColor(new_color), skip_animation); } XFree(colors); }
static void mystify_init(){ back = ttk_makecol(BLACK); new_color(); rc = r; gc = g; bc = b; aa = 1; paused = 0; sleep_time = 3; fifo_init(&polygons); polygon_move_init(&move); polygon_init(&leading_polygon); }
static void dotext(double x, double y, obj *p) /* print text strings of p in proper vertical spacing */ { double h, v, w, dely, *bnd; int i, j, m, n, t; int nt2 = p->o_nt2; bnd = text_bounds(p); v = bnd[3]; /* includes ABOVE/BELOW attributes */ j = text[p->o_nt1].t_line; new_color(p->o_text); for (h = w = 0, i = p->o_nt1; i < nt2; h = w = 0) { /* calculate position of baseline for this line--assumed to be down 3/4 of maximum character height from top of line */ for (m = 0, n = i; n < nt2 && text[n].t_line == j; n++) { w += text[n].t_width*72/pgscale; if (abs(text[n].t_size) > m) m = abs(text[n].t_size); } dely = (double) m / pgscale; /* max size, in inches */ t = text[i].t_type; #if 0 /* Note the adjustments for ABOVE and BELOW are permanent--affect all subsequent strings in this object */ if (t & ABOVE) v += dely / 2; else if (t & BELOW) v -= dely / 2; #endif dely *= .75; if (t & RJUST) h = w; else if (t & CENTER) h = w/2; newlabel(t, text[i].t_val, abs(text[i].t_font), x-h, y + v - dely, text[i].t_size / pgscale, text[i].t_width * 72 / pgscale); v -= (double) abs(text[i].t_space) / pgscale; while (++i < n) addlabel(text[i].t_type, text[i].t_val, text[i].t_font, text[i].t_size / pgscale, text[i].t_width * 72 / pgscale); j = text[i].t_line; /* line numbers not necessarily consecutive! */ } }
/* get register values from ports */ void get_register() { color = new_color(); // update color outp(0x20, 0x0B); print(inp(0x20),0,"ISR1"); outp(0x20, 0x0A); print(inp(0x20),20,"IRR1"); print(inp(0x21),40,"IMR1"); outp(0xA0, 0x0B); print(inp(0xA0),80,"ISR2"); outp(0xA0, 0x0A); print(inp(0xA0),100,"IRR2"); print(inp(0xA1),120,"IMR2"); }
int main(void) { gui *g; widget *w, *c1, *c2, *l, *plot, *tl; int tlcol; g = gui_init(); c1 = new_container(g, VERTICAL); c2 = new_container(g, HORIZONTAL); l = new_label(g, "this is a good label"); widget_add_child(g, c2, l, 0); l = new_label(g, "this is another good label"); widget_add_child(g, c2, l, -1); l = new_label(g, "OH! WHAT A LABEL!"); widget_add_child(g, c1, l, -1); widget_add_child(g, c1, c2, 0); plot = new_xy_plot(g, 100, 100, "xy plot test", 30); #if 0 c2 = new_container(g, HORIZONTAL); widget_add_child(g, c2, plot, -1); widget_add_child(g, c1, c2, -1); #else widget_add_child(g, c1, plot, -1); #endif tlcol = new_color(g, "#ddf"); tl = new_textlist(g, 300, 10, tlcol); widget_add_child(g, c1, tl, -1); textlist_add(g, tl, "hello", -1, FOREGROUND_COLOR); textlist_add(g, tl, "world", -1, FOREGROUND_COLOR); w = new_toplevel_window(g, 500, 400, "test window"); widget_add_child(g, w, c1, 0); gui_loop(g); return 0; }
static void parsing_options(char **tab, t_env *rt, int i) { if (!tab[0] || !tab[1]) ft_exit("\033[31mWrong format for an object\n"); missing_parameter_obj(tab); if (!ft_strcmp(tab[0], "radius")) { if (ATOF(2) <= 0 && rt->object[i].name != PLANE && rt->object[i].name != HYPERBOL) ft_exit("\033[31mRadius must be positive\n"); rt->object[i].radius = ATOF(2); } else if (!ft_strcmp(tab[0], "pos")) rt->object[i].center = new_vector(ATOF(2), ATOF(3), ATOF(4)); else if (!ft_strcmp(tab[0], "color")) { check_color(ATOF(2), ATOF(3), ATOF(4)); rt->object[i].color = new_color(ATOF(2), ATOF(3), ATOF(4)); } }
static t_color get_spec(t_scene scene, t_light light, t_point light_inter, t_obj object) { t_point r; float dot; float reflet; reflet = 2.0f * scene.scal; r = new_point(light_inter.x - reflet * scene.normal.x, light_inter.y - reflet * scene.normal.y, light_inter.z - reflet * scene.normal.z); dot = scalar_prod(scene.ray, r); if (dot < 0.0f) { reflet = powf(dot, 20) * object.spec * light.intensity; scene.color = new_color(scene.color.red + reflet * light.color.red, scene.color.blue + reflet * light.color.blue, scene.color.green + reflet * light.color.green); } return (scene.color); }
static void vcd_main_gui(gui *g, event_handler *h, void *database) { int i, j; int n; int nb_functions = 0; char **ids; widget *win; widget *container; widget *w; view *timeview; view *subview; logger *timelog; /* get number of vcd functions - look for all events VCD_FUNCTION_xxx */ n = database_get_ids(database, &ids); for (i = 0; i < n; i++) { if (strncmp(ids[i], "VCD_FUNCTION_", 13) != 0) continue; nb_functions++; } win = new_toplevel_window(g, 1000, 5 * nb_functions, "VCD tracer"); container = new_container(g, VERTICAL); widget_add_child(g, win, container, -1); w = new_timeline(g, 1000, nb_functions, 5); widget_add_child(g, container, w, -1); for (i = 0; i < nb_functions; i++) timeline_set_subline_background_color(g, w, i, new_color(g, i & 1 ? "#ddd" : "#eee")); timeview = new_view_time(3600, 10, g, w); i = 0; for (j = 0; j < n; j++) { if (strncmp(ids[j], "VCD_FUNCTION_", 13) != 0) continue; timelog = new_timelog(h, database, ids[j]); subview = new_subview_time(timeview, i, FOREGROUND_COLOR, 3600*1000); logger_add_view(timelog, subview); i++; } free(ids); }
void Values_delegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { if(index.column() == Values_list::Color) { ColorListEditor* coloreditor = qobject_cast<ColorListEditor*>(editor); if(coloreditor) { model->setData(index, coloreditor->color()); emit new_color(index); } } else if(index.column() == Values_list::Value) { QLineEdit* lineedit = qobject_cast<QLineEdit*>(editor); if(lineedit) { model->setData(index, lineedit->text().toDouble()); emit new_value(index); } } else QItemDelegate::setModelData(editor, model, index); }
void calcul_light(t_env *rt, int i2) { int i; i = 0; rt->color = new_color(0, 0, 0); while (i < rt->nblight) { light(rt, rt->object[i2], rt->light[i]); i++; } if (rt->nblight != 0) { rt->color.r /= rt->nblight; rt->color.g /= rt->nblight; rt->color.b /= rt->nblight; } rt->color.r = (rt->color.r > 0xff) ? (0xff) : (rt->color.r); rt->color.g = (rt->color.g > 0xff) ? (0xff) : (rt->color.g); rt->color.b = (rt->color.b > 0xff) ? (0xff) : (rt->color.b); rt->color.r = (rt->color.r < 0) ? (0) : (rt->color.r); rt->color.g = (rt->color.g < 0) ? (0) : (rt->color.g); rt->color.b = (rt->color.b < 0) ? (0) : (rt->color.b); }
void draw(t_tool *t, double x, double y) { t_ray *ray; double x0; double y0; t_color *final_color; final_color = new_color(); x0 = x; while (x0 <= x + 0.5) { y0 = y; while (y0 <= y + 0.5) { ray = get_ray(t, x0, y0); add_color(final_color, draw_suite(ray, t)); y0 += 0.5; } x0 += 0.5; } div_color(final_color, 4); normalize_color(final_color); pixel_put_to_image(t, x, y, final_color); }