void NoteCanvas::read_internal(char *& st) { const char * p = st; QTextCodec* codec = QTextCodec::codecForLocale(); QTextStream stream(p); stream.setCodec(codec); QByteArray ba; stream >> ba; QString temp = QString::fromLocal8Bit(ba); char* test = read_string(st); Q_UNUSED(test); note = temp; char * k = read_keyword(st); read_color(st, "color", itscolor, k); read_font(st, "font", itsfont, k); read_color(st, "fg", fg_c, k); if (strcmp(k, "xyzwh")) wrong_keyword(k, "xyzwh"); read_xyzwh(st, this); width_scale100 = width(); height_scale100 = height(); set_center100(); show(); }
int my_parse(t_fdf *e, int ac, char **av) { int i; int fd; t_list *list; if ((fd = open(av[1], O_RDWR)) < 0 && ft_printf("fdf: %s: ", av[1])) { perror(""); return (0); } if ((i = my_filllist(&list, fd)) == -2) return (0); if (close(fd) && ft_printf("fdf: %s: ", av[1])) { perror(""); return (0); } if (!check_list(e, &list)) return (0); if (i == -1 || ac < 3) return ((i == -1) ? 0 : 1); if ((e->mic.col = read_color(av[2])) < 0) return ((e->mic.col = FDF_COL_MIN) + 1); if ((ac < 4 || (e->mac.col = read_color(av[3])) < 0)) return ((e->mac.col = e->mic.col) + 1); return (1); }
int read_controller(const char *device, struct controller *controller) { if (!read_capacity(device, &controller->capacity)) return 0; if (!read_color(device, "red", &controller->r)) return 0; if (!read_color(device, "green", &controller->g)) return 0; if (!read_color(device, "blue", &controller->b)) return 0; return 1; }
Volume* load_volume(tinyxml2::XMLElement *elem, VolumeCache &cache, const std::string &scene_file){ if (!elem->Attribute("name")){ std::cout << "Scene error: Volumes require a name" << std::endl; return nullptr; } if (!elem->Attribute("type")){ std::cout << "Scene error: Volumes require a type" << std::endl; return nullptr; } std::string name = elem->Attribute("name"); std::string type = elem->Attribute("type"); Volume *vol = cache.get(name); if (vol){ return vol; } Colorf sig_a, sig_s, emit; float phase_asym; read_color(elem->FirstChildElement("absorption"), sig_a); read_color(elem->FirstChildElement("scattering"), sig_s); read_color(elem->FirstChildElement("emission"), emit); read_float(elem->FirstChildElement("phase_asymmetry"), phase_asym); if (type == "homogeneous"){ Point min, max; read_point(elem->FirstChildElement("min"), min); read_point(elem->FirstChildElement("max"), max); return cache.add(name, std::make_unique<HomogeneousVolume>(sig_a, sig_s, emit, phase_asym, BBox{min, max})); } if (type == "exponential"){ float a = 0, b = 0; Vector up; Point min, max; read_float(elem->FirstChildElement("a"), a); read_float(elem->FirstChildElement("b"), b); read_vector(elem->FirstChildElement("up"), up); read_point(elem->FirstChildElement("min"), min); read_point(elem->FirstChildElement("max"), max); return cache.add(name, std::make_unique<ExponentialVolume>(sig_a, sig_s, emit, phase_asym, BBox{min, max}, a, b, up)); } if (type == "vol"){ std::string file = scene_file.substr(0, scene_file.rfind(PATH_SEP) + 1) + elem->Attribute("file"); float density_scale = 1; read_float(elem->FirstChildElement("density_scale"), density_scale); return cache.add(name, std::make_unique<GridVolume>(sig_a, sig_s, emit, phase_asym, file, density_scale)); } std::cout << "Scene error: Unrecognized volume type " << type << std::endl; return nullptr; }
PackageCanvas * PackageCanvas::read(char * & st, UmlCanvas * canvas, char * k) { if (!strcmp(k, "packagecanvas_ref")) return ((PackageCanvas *) dict_get(read_id(st), "packagecanvas", canvas)); else if (!strcmp(k, "packagecanvas")) { int id = read_id(st); BrowserNode * br = BrowserPackage::read_ref(st); UmlColor color = UmlDefaultColor; Uml3States in_tab = UmlDefaultState; ShowContextMode context = DefaultShowContextMode; Uml3States show_stereotype_properties = UmlDefaultState;; k = read_keyword(st); if (!strcmp(k, "name_in_tab")) { in_tab = state(read_keyword(st)); k = read_keyword(st); } if (!strcmp(k, "show_context_mode")) { context = context_mode(read_keyword(st)); k = read_keyword(st); } if (!strcmp(k, "show_stereotype_properties")) { show_stereotype_properties = state(read_keyword(st)); k = read_keyword(st); } read_color(st, "color", color, k); if (strcmp(k, "xyzwh")) wrong_keyword(k, "xyzwh"); int x = (int) read_double(st); PackageCanvas * result = new PackageCanvas(br, canvas, x, (int) read_double(st), id); read_zwh(st, result); if (read_file_format() >= 58) { k = read_keyword(st); result->read_stereotype_property(st, k); // updates k if (strcmp(k, "end")) wrong_keyword(k, "end"); } result->name_in_tab = in_tab; result->show_context_mode = context; result->show_stereotype_properties = show_stereotype_properties; result->itscolor = color; result->check_size(); result->set_center100(); result->show(); result->check_stereotypeproperties(); return result; } else return 0; }
SubjectCanvas * SubjectCanvas::read(char * & st, UmlCanvas * canvas, char * k) { if (!strcmp(k, "subject_ref")) return (SubjectCanvas *) dict_get(read_id(st), "subject", canvas); else if (!strcmp(k, "subject")) { int id = read_id(st); SubjectCanvas * result = new SubjectCanvas(canvas, 0, 0, id); result->name = toUnicode(read_string(st)); k = read_keyword(st); read_color(st, "color", result->itscolor, k); if (strcmp(k, "xyzwh")) wrong_keyword(k, "xyzwh"); read_xyzwh(st, result); result->check_size(); result->width_scale100 = result->width(); result->height_scale100 = result->height(); result->set_center100(); result->show(); return result; } else return 0; }
int f_antialias(ULONG *arg) { rsiCOLOR color; float fnum; rsiResult err; if (arg[1]) { fnum = (float)atof((char*)arg[1]); err = rsiSetAntialias(atoi((char *)arg[0]),rsiTAntiFilter,fnum,rsiTDone); if (err) return err; } if (arg[2]) { if (!read_color(&color,(char*)arg[2])) return ERROR_COLOREXP; err = rsiSetAntialias(atoi((char *)arg[0]),rsiTAntiContrast,&color,rsiTDone); if (err) return err; } return rsiSetAntialias(atoi((char *)arg[0]),rsiTDone); }
ULONG antialias(ULONG *arg) { rsiCOLOR color; float fnum; rsiResult err; err = rsiSetAntialias(CTXT, rsiTAntiSamples, *((int*)arg[0]), rsiTDone); if(err) return err; if(arg[1]) { fnum = (float)atof((char*)arg[1]); err = rsiSetAntialias(CTXT, rsiTAntiFilter,fnum, rsiTDone); if(err) return err; } if(arg[2]) { if(!read_color(&color,(char*)arg[2])) return ERROR_COLOR; err = rsiSetAntialias(CTXT, rsiTAntiContrast,&color, rsiTDone); if(err) return err; } return rsiERR_NONE; }
DeploymentNodeCanvas * DeploymentNodeCanvas::read(char * & st, UmlCanvas * canvas, char * k) { if (!strcmp(k, "deploymentnodecanvas_ref")) return ((DeploymentNodeCanvas *) dict_get(read_id(st), "deploymentnodecanvas", canvas)); else if (!strcmp(k, "deploymentnodecanvas")) { int id = read_id(st); BrowserNode * br = BrowserDeploymentNode::read_ref(st); QString iname; Uml3States write_horizontally = UmlDefaultState; Uml3States show_stereotype_properties = UmlDefaultState; k = read_keyword(st); if (!strcmp(k, "name")) { iname = read_string(st); k = read_keyword(st); } if (!strcmp(k, "write_horizontally") || !strcmp(k, "write_horizontaly")) { write_horizontally = state(read_keyword(st)); k = read_keyword(st); } if (!strcmp(k, "show_stereotype_properties")) { show_stereotype_properties = state(read_keyword(st)); k = read_keyword(st); } UmlColor color = UmlDefaultColor; read_color(st, "color", color, k); if (strcmp(k, "xyzwh")) wrong_keyword(k, "xyzwh"); int x = (int) read_double(st); DeploymentNodeCanvas * result = new DeploymentNodeCanvas(br, canvas, x, (int) read_double(st), id); read_zwh(st, result); if (read_file_format() >= 58) { k = read_keyword(st); result->read_stereotype_property(st, k); // updates k if (strcmp(k, "end")) wrong_keyword(k, "end"); } result->iname = iname; result->write_horizontally = write_horizontally; result->show_stereotype_properties = show_stereotype_properties; result->itscolor = color; result->check_size(); result->set_center100(); result->show(); result->check_stereotypeproperties(); return result; } else return 0; }
// set_nametag_attributes(self, attributes) int ObjectRef::l_set_nametag_attributes(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); ServerActiveObject *co = getobject(ref); if (co == NULL) return 0; ObjectProperties *prop = co->accessObjectProperties(); if (!prop) return 0; lua_getfield(L, 2, "color"); if (!lua_isnil(L, -1)) { video::SColor color = prop->nametag_color; read_color(L, -1, &color); prop->nametag_color = color; } lua_pop(L, 1); std::string nametag = getstringfield_default(L, 2, "text", ""); prop->nametag = nametag; co->notifyObjectPropertiesModified(); lua_pushboolean(L, true); return 1; }
// set_clouds(self, {density=, color=, ambient=, height=, thickness=, speed=}) int ObjectRef::l_set_clouds(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); RemotePlayer *player = getplayer(ref); if (!player) return 0; if (!lua_istable(L, 2)) return 0; CloudParams cloud_params = player->getCloudParams(); cloud_params.density = getfloatfield_default(L, 2, "density", cloud_params.density); lua_getfield(L, 2, "color"); if (!lua_isnil(L, -1)) read_color(L, -1, &cloud_params.color_bright); lua_pop(L, 1); lua_getfield(L, 2, "ambient"); if (!lua_isnil(L, -1)) read_color(L, -1, &cloud_params.color_ambient); lua_pop(L, 1); cloud_params.height = getfloatfield_default(L, 2, "height", cloud_params.height ); cloud_params.thickness = getfloatfield_default(L, 2, "thickness", cloud_params.thickness); lua_getfield(L, 2, "speed"); if (lua_istable(L, -1)) { v2f new_speed; new_speed.X = getfloatfield_default(L, -1, "x", 0); new_speed.Y = getfloatfield_default(L, -1, "y", 0); cloud_params.speed = new_speed; } lua_pop(L, 1); if (!getServer(L)->setClouds(player, cloud_params.density, cloud_params.color_bright, cloud_params.color_ambient, cloud_params.height, cloud_params.thickness, cloud_params.speed)) return 0; player->setCloudParams(cloud_params); lua_pushboolean(L, true); return 1; }
void NoteCanvas::read_internal(char * & st) { note = toUnicode(read_string(st)); char * k = read_keyword(st); read_color(st, "color", itscolor, k); read_font(st, "font", itsfont, k); read_color(st, "fg", fg_c, k); if (strcmp(k, "xyzwh")) wrong_keyword(k, "xyzwh"); read_xyzwh(st, this); width_scale100 = width(); height_scale100 = height(); set_center100(); show(); }
TileDef read_tiledef(lua_State *L, int index, u8 drawtype) { if(index < 0) index = lua_gettop(L) + 1 + index; TileDef tiledef; bool default_tiling = true; bool default_culling = true; switch (drawtype) { case NDT_PLANTLIKE: case NDT_FIRELIKE: default_tiling = false; // "break" is omitted here intentionaly, as PLANTLIKE // FIRELIKE drawtype both should default to having // backface_culling to false. case NDT_MESH: case NDT_LIQUID: default_culling = false; break; default: break; } // key at index -2 and value at index if(lua_isstring(L, index)){ // "default_lava.png" tiledef.name = lua_tostring(L, index); tiledef.tileable_vertical = default_tiling; tiledef.tileable_horizontal = default_tiling; tiledef.backface_culling = default_culling; } else if(lua_istable(L, index)) { // name="default_lava.png" tiledef.name = ""; getstringfield(L, index, "name", tiledef.name); getstringfield(L, index, "image", tiledef.name); // MaterialSpec compat. tiledef.backface_culling = getboolfield_default( L, index, "backface_culling", default_culling); tiledef.tileable_horizontal = getboolfield_default( L, index, "tileable_horizontal", default_tiling); tiledef.tileable_vertical = getboolfield_default( L, index, "tileable_vertical", default_tiling); // color = ... lua_getfield(L, index, "color"); tiledef.has_color = read_color(L, -1, &tiledef.color); lua_pop(L, 1); // animation = {} lua_getfield(L, index, "animation"); tiledef.animation = read_animation_definition(L, -1); lua_pop(L, 1); } return tiledef; }
ULONG transpar(ULONG *arg) { rsiCOLOR color; if(!surf) return rsiERR_SURFACE; if(!read_color(&color,(char*)arg[0])) return ERROR_COLOR; return rsiSetSurface(CTXT, surf->item,rsiTSurfTranspar,&color,rsiTDone); }
int f_reflect(ULONG *arg) { rsiCOLOR color; if (!surf) return rsiERR_SURFACE; if (!read_color(&color,(char*)arg[0])) return ERROR_COLOREXP; return rsiSetSurface(surf->item,rsiTSurfReflect,&color,rsiTDone); }
UcUseCaseCanvas * UcUseCaseCanvas::read(char * & st, UmlCanvas * canvas, char * k) { if (!strcmp(k, "usecasecanvas_ref")) return ((UcUseCaseCanvas *) dict_get(read_id(st), "usecasecanvas", canvas)); else if (!strcmp(k, "usecasecanvas")) { int id = read_id(st); BrowserNode * br = BrowserUseCase::read_ref(st); UmlColor color = UmlDefaultColor; k = read_keyword(st); read_color(st, "color", color, k); if (strcmp(k, "xyzwh")) wrong_keyword(k, "xyzwh"); int x = (int) read_double(st); UcUseCaseCanvas * result = new UcUseCaseCanvas(br, canvas, x, (int) read_double(st), id); result->itscolor = color; read_zwh(st, result); result->width_scale100 = result->width(); result->height_scale100 = result->height(); result->set_center100(); k = read_keyword(st); result->update_name(); read_xy(st, result->label); result->label->setZ(result->z() + 0.5); result->label->set_center100(); if (!strcmp(k, "label_xyz")) // old version read_double(st); else if (strcmp(k, "label_xy")) wrong_keyword(k, "label_xy/label_xyz"); if (read_file_format() >= 58) { k = read_keyword(st); result->read_stereotype_property(st, k); // updates k if (strcmp(k, "end")) wrong_keyword(k, "end"); } result->show(); result->check_stereotypeproperties(); return result; } else return 0; }
TextCanvas * TextCanvas::read(char *& st, UmlCanvas * canvas, char * k) { if (!strcmp(k, "textcanvas_ref")) return ((TextCanvas *) dict_get(read_id(st), "textcanvas", canvas)); else if (!strcmp(k, "textcanvas")) { int id = read_id(st); QString text = read_string(st); UmlFont font; UmlColor fg_c = UmlBlack; UmlColor bg_c = UmlTransparent; k = read_keyword(st); read_font(st, "font", font, k); read_color(st, "fg", fg_c, k); read_color(st, "bg", bg_c, k); if (strcmp(k, "xyzwh")) wrong_keyword(k, "xyzwh"); int x = (int) read_double(st); TextCanvas * result = new TextCanvas(canvas, x, (int) read_double(st), id); read_zwh(st, result); result->width_scale100 = result->width(); result->height_scale100 = result->height(); result->set_center100(); result->text = text; result->itsfont = font; result->fg_c = fg_c; result->bg_c = bg_c; result->show(); return result; } else return 0; }
ActivityPartitionCanvas * ActivityPartitionCanvas::read(char * & st, UmlCanvas * canvas, char * k) { if (!strcmp(k, "activitypartitioncanvas_ref")) return ((ActivityPartitionCanvas *) dict_get(read_id(st), "activitypartitioncanvas", canvas)); else if (!strcmp(k, "activitypartitioncanvas")) { int id = read_id(st); BrowserActivityPartition * br = BrowserActivityPartition::read_ref(st); ActivityPartitionCanvas * result = new ActivityPartitionCanvas(canvas, id); result->browser_node = br; connect(br->get_data(), SIGNAL(changed()), result, SLOT(modified())); connect(br->get_data(), SIGNAL(deleted()), result, SLOT(deleted())); k = read_keyword(st); read_color(st, "color", result->itscolor, k); // updates k if (! strcmp(k, "horiz")) { result->horiz = TRUE; k = read_keyword(st); } result->read_stereotype_property(st, k); // updates k if (!strcmp(k, "xyzwh")) read_xyzwh(st, result); else wrong_keyword(k, "xyzwh"); result->check_size(); result->width_scale100 = result->width(); result->height_scale100 = result->height(); result->set_center100(); result->show(); result->check_stereotypeproperties(); read_keyword(st, "end"); // result->force_sub_inside() useless if (canvas->paste()) result->remove_if_already_present(); return result; } else return 0; }
StateActionCanvas * StateActionCanvas::read(char * & st, UmlCanvas * canvas, char * k) { if (!strcmp(k, "stateactioncanvas_ref")) return ((StateActionCanvas *) dict_get(read_id(st), "stateactioncanvas", canvas)); else if (!strcmp(k, "stateactioncanvas")) { int id = read_id(st); BrowserStateAction * br = BrowserStateAction::read_ref(st); StateActionCanvas * result = new StateActionCanvas(canvas, id); result->browser_node = br; connect(br->get_data(), SIGNAL(changed()), result, SLOT(modified())); connect(br->get_data(), SIGNAL(deleted()), result, SLOT(deleted())); k = read_keyword(st); if (!strcmp(k, "language")) { result->language = drawing_language(read_keyword(st)); k = read_keyword(st); } if (!strcmp(k, "show_stereotype_properties")) { result->show_stereotype_properties = state(read_keyword(st)); k = read_keyword(st); } read_color(st, "color", result->itscolor, k); // updates k if (!strcmp(k, "xyzwh")) read_xyzwh(st, result); else wrong_keyword(k, "xyzwh"); if (read_file_format() >= 58) { k = read_keyword(st); result->read_stereotype_property(st, k); // updates k if (strcmp(k, "end")) wrong_keyword(k, "end"); } result->compute_size(); result->set_center100(); result->show(); result->check_stereotypeproperties(); return result; } else return 0; }
int main (int argc, char** argv) { if (argc == 3) { std::string filename = argv [1]; std::string output = argv [2]; std::string type = get_type (filename); if (type == "" || !find_type (type)) { type = "original"; } read_color (type_location (type)); print_highlight (filename, output); } }
SdDurationCanvas * SdDurationCanvas::read_internal(char * & st, UmlCanvas * canvas, int id, SdDurationSupport * sp) { UmlColor color = UmlDefaultColor; bool coreg = FALSE; char * k = read_keyword(st); if (!strcmp(k, "coregion")) { coreg = TRUE; k = read_keyword(st); } read_color(st, "color", color, k); if (strcmp(k, "xyzwh")) wrong_keyword(k, "xyzwh"); int x = (int) read_double(st); int y = (int) read_double(st); double z = read_double(st); (void) read_double(st); // width not used to bypass old bug SdDurationCanvas * result = new SdDurationCanvas(canvas, sp, x, y, DURATION_WIDTH, (int) read_double(st), id, coreg); result->itscolor = color; result->setZ(z); result->update_hpos(); // in case the current font is not the original one result->set_center100(); result->show(); if (read_file_format() >= 48) { k = read_keyword(st); while (!strcmp(k, "overlappingdurationcanvas")) { (void) read_internal(st, canvas, read_id(st), result); k = read_keyword(st); } if (strcmp(k, "end")) wrong_keyword(k, "end"); } return result; }
FragmentCanvas * FragmentCanvas::read(char * & st, UmlCanvas * canvas, char * k) { if (!strcmp(k, "fragment_ref")) return (FragmentCanvas *) dict_get(read_id(st), "fragment", canvas); else if (!strcmp(k, "fragment")) { int id = read_id(st); FragmentCanvas * result = new FragmentCanvas(canvas, 0, 0, id); result->name = read_string(st); k = read_keyword(st); read_color(st, "color", result->itscolor, k); if (!strcmp(k, "refer")) { result->refer = BrowserDiagram::read_diagram_ref(st); connect(result->refer->get_data(), SIGNAL(changed()), result, SLOT(modified())); connect(result->refer->get_data(), SIGNAL(deleted()), result, SLOT(modified())); k = read_keyword(st); } if (! strcmp(k, "form")) { result->form = read_string(st); k = read_keyword(st); } if (strcmp(k, "xyzwh")) wrong_keyword(k, "xyzwh"); read_xyzwh(st, result); result->check_size(); result->width_scale100 = result->width(); result->height_scale100 = result->height(); result->set_center100(); result->show(); if (read_file_format() >= 28) { while (strcmp(k = read_keyword(st), "end")) result->separators.append(FragmentSeparatorCanvas::read(st, canvas, k, result)); } return result; } else return 0; }
// set_nametag_attributes(self, attributes) int ObjectRef::l_set_nametag_attributes(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); PlayerSAO *playersao = getplayersao(ref); if (playersao == NULL) return 0; lua_getfield(L, 2, "color"); if (!lua_isnil(L, -1)) { video::SColor color = playersao->getNametagColor(); if (!read_color(L, -1, &color)) return 0; playersao->setNametagColor(color); } lua_pushboolean(L, true); return 1; }
ArtifactCanvas * ArtifactCanvas::read(char * & st, UmlCanvas * canvas, char * k) { if (!strcmp(k, "artifactcanvas_ref") || ((read_file_format() < 20) && !strcmp(k, "componentcanvas_ref"))) return ((ArtifactCanvas *) dict_get(read_id(st), "artifactcanvas", canvas)); else if (!strcmp(k, "artifactcanvas") || ((read_file_format() < 20) && !strcmp(k, "componentcanvas"))) { int id = read_id(st); BrowserArtifact * br = BrowserArtifact::read_ref(st, read_keyword(st)); ArtifactCanvas * result = new ArtifactCanvas(canvas, id); result->browser_node = br; connect(br->get_data(), SIGNAL(changed()), result, SLOT(modified())); connect(br->get_data(), SIGNAL(deleted()), result, SLOT(deleted())); k = read_keyword(st); read_color(st, "color", result->itscolor, k); // updates k if (strcmp(k, "xyz")) wrong_keyword(k, "xyz"); read_xyz(st, result); if (read_file_format() >= 58) { k = read_keyword(st); result->read_stereotype_property(st, k); // updates k if (strcmp(k, "end")) wrong_keyword(k, "end"); } result->compute_size(); result->set_center100(); result->show(); result->check_stereotypeproperties(); return result; } else return 0; }
// set_sky(self, bgcolor, type, list, clouds = true) int ObjectRef::l_set_sky(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); RemotePlayer *player = getplayer(ref); if (player == NULL) return 0; video::SColor bgcolor(255,255,255,255); read_color(L, 2, &bgcolor); std::string type = luaL_checkstring(L, 3); std::vector<std::string> params; if (lua_istable(L, 4)) { lua_pushnil(L); while (lua_next(L, 4) != 0) { // key at index -2 and value at index -1 if (lua_isstring(L, -1)) params.push_back(lua_tostring(L, -1)); else params.push_back(""); // removes value, keeps key for next iteration lua_pop(L, 1); } } if (type == "skybox" && params.size() != 6) throw LuaError("skybox expects 6 textures"); bool clouds = true; if (lua_isboolean(L, 5)) clouds = lua_toboolean(L, 5); if (!getServer(L)->setSky(player, bgcolor, type, params, clouds)) return 0; lua_pushboolean(L, true); return 1; }
ParameterSetCanvas * ParameterSetCanvas::read(char * & st, UmlCanvas * canvas, char * k, ActivityActionCanvas * a) { if (!strcmp(k, "parametersetcanvas_ref")) return ((ParameterSetCanvas *) dict_get(read_id(st), "parametersetcanvas", canvas)); else if (!strcmp(k, "parametersetcanvas")) { int id = read_id(st); BrowserParameterSet * br = BrowserParameterSet::read_ref(st); ParameterSetCanvas * result = new ParameterSetCanvas(br, canvas, id, a); k = read_keyword(st); read_color(st, "color", result->itscolor, k); // updates k if (!strcmp(k, "xyz")) read_xyz(st, result); else wrong_keyword(k, "xyz"); // note : width_scale100 & height_scale100 useless, position depend on pins result->update(); result->show(); k = read_keyword(st); result->read_stereotype_property(st, k); // updates k if (strcmp(k, "end")) wrong_keyword(k, "end"); result->check_stereotypeproperties(); return result; } else return 0; }
static void nautilus_file_background_read_desktop_settings (char **color, char **image, EelBackgroundImagePlacement *placement) { GConfClient *client; gboolean enabled; GdkColor primary, secondary; gchar *tmp, *filename; char *end_color; char *start_color; gboolean use_gradient; gboolean is_horizontal; filename = NULL; client = gconf_client_get_default (); /* Get the image filename */ enabled = gconf_client_get_bool (client, BG_PREFERENCES_DRAW_BACKGROUND, NULL); if (enabled) { tmp = gconf_client_get_string (client, BG_PREFERENCES_PICTURE_FILENAME, NULL); if (tmp != NULL) { if (g_utf8_validate (tmp, -1, NULL) && g_file_test (tmp, G_FILE_TEST_EXISTS)) { filename = g_strdup (tmp); } else { filename = g_filename_from_utf8 (tmp, -1, NULL, NULL, NULL); } } g_free (tmp); if (filename != NULL && filename[0] != '\0') { *image = g_filename_to_uri (filename, NULL, NULL); } else { *image = NULL; } g_free (filename); } else { *image = NULL; } /* Get the placement */ tmp = gconf_client_get_string (client, BG_PREFERENCES_PICTURE_OPTIONS, NULL); if (tmp != NULL) { if (strcmp (tmp, "wallpaper") == 0) { *placement = EEL_BACKGROUND_TILED; } else if (strcmp (tmp, "centered") == 0) { *placement = EEL_BACKGROUND_CENTERED; } else if (strcmp (tmp, "scaled") == 0) { *placement = EEL_BACKGROUND_SCALED_ASPECT; } else if (strcmp (tmp, "stretched") == 0) { *placement = EEL_BACKGROUND_SCALED; } else if (strcmp (tmp, "zoom") == 0) { *placement = EEL_BACKGROUND_ZOOM; } else if (strcmp (tmp, "spanned") == 0) { *placement = EEL_BACKGROUND_SPANNED; } else if (strcmp (tmp, "none") == 0) { g_free (*image); *placement = EEL_BACKGROUND_CENTERED; *image = NULL; } else { *placement = EEL_BACKGROUND_CENTERED; } } else { *placement = EEL_BACKGROUND_CENTERED; } g_free (tmp); /* Get the color */ tmp = gconf_client_get_string (client, BG_PREFERENCES_COLOR_SHADING_TYPE, NULL); if (tmp != NULL) { if (strcmp (tmp, "solid") == 0) { use_gradient = FALSE; is_horizontal = FALSE; } else if (strcmp (tmp, "vertical-gradient") == 0) { use_gradient = TRUE; is_horizontal = FALSE; } else if (strcmp (tmp, "horizontal-gradient") == 0) { use_gradient = TRUE; is_horizontal = TRUE; } else { use_gradient = FALSE; is_horizontal = FALSE; } } else { use_gradient = FALSE; is_horizontal = FALSE; } g_free (tmp); read_color (client, BG_PREFERENCES_PRIMARY_COLOR, &primary); read_color (client, BG_PREFERENCES_SECONDARY_COLOR, &secondary); start_color = eel_gdk_rgb_to_color_spec (eel_gdk_color_to_rgb (&primary)); end_color = eel_gdk_rgb_to_color_spec (eel_gdk_color_to_rgb (&secondary)); if (use_gradient) { *color = eel_gradient_new (start_color, end_color, is_horizontal); } else { *color = g_strdup (start_color); } g_free (start_color); g_free (end_color); }
static void replay(struct _gfxdevice*dev, gfxdevice_t*out, reader_t*r, gfxfontlist_t**fontlist) { internal_t*i = 0; if(dev) { i = (internal_t*)dev->internal; } gfxfontlist_t*_fontlist=0; if(!fontlist) { fontlist = &_fontlist; } state_t state; memset(&state, 0, sizeof(state)); while(1) { unsigned char op; if(r->read(r, &op, 1)!=1) break; unsigned char flags = op&0xf0; op&=0x0f; switch(op) { case OP_END: goto finish; case OP_SETPARAM: { msg("<trace> replay: SETPARAM"); char*key; char*value; key = reader_readString(r); value = reader_readString(r); out->setparameter(out, key, value); free(key); free(value); break; } case OP_STARTPAGE: { msg("<trace> replay: STARTPAGE"); U16 width = reader_readU16(r); U16 height = reader_readU16(r); out->startpage(out, width, height); break; } case OP_ENDPAGE: { msg("<trace> replay: ENDPAGE"); out->endpage(out); break; } case OP_FINISH: { msg("<trace> replay: FINISH"); break; } case OP_STROKE: { msg("<trace> replay: STROKE"); double width = reader_readDouble(r); double miterlimit = reader_readDouble(r); gfxcolor_t color = readColor(r, &state); gfx_capType captype; int v = reader_readU8(r); switch (v) { case 0: captype = gfx_capButt; break; case 1: captype = gfx_capRound; break; case 2: captype = gfx_capSquare; break; } gfx_joinType jointtype; v = reader_readU8(r); switch (v) { case 0: jointtype = gfx_joinMiter; break; case 1: jointtype = gfx_joinRound; break; case 2: jointtype = gfx_joinBevel; break; } gfxline_t* line = readLine(r, &state); out->stroke(out, line, width, &color, captype, jointtype,miterlimit); gfxline_free(line); break; } case OP_STARTCLIP: { msg("<trace> replay: STARTCLIP"); gfxline_t* line = readLine(r, &state); out->startclip(out, line); gfxline_free(line); break; } case OP_ENDCLIP: { msg("<trace> replay: ENDCLIP"); out->endclip(out); break; } case OP_FILL: { msg("<trace> replay: FILL"); gfxcolor_t color = readColor(r, &state); gfxline_t* line = readLine(r, &state); out->fill(out, line, &color); gfxline_free(line); break; } case OP_FILLBITMAP: { msg("<trace> replay: FILLBITMAP"); gfximage_t img = readImage(r, &state); gfxmatrix_t matrix = readMatrix(r, &state); gfxline_t* line = readLine(r, &state); gfxcxform_t* cxform = readCXForm(r, &state); out->fillbitmap(out, line, &img, &matrix, cxform); gfxline_free(line); if(cxform) free(cxform); free(img.data);img.data=0; break; } case OP_FILLGRADIENT: { msg("<trace> replay: FILLGRADIENT"); gfxgradienttype_t type; int v = reader_readU8(r); switch (v) { case 0: type = gfxgradient_radial; break; case 1: type = gfxgradient_linear; break; } gfxgradient_t*gradient = readGradient(r, &state); gfxmatrix_t matrix = readMatrix(r, &state); gfxline_t* line = readLine(r, &state); out->fillgradient(out, line, gradient, type, &matrix); break; } case OP_DRAWLINK: { msg("<trace> replay: DRAWLINK"); gfxline_t* line = readLine(r, &state); char* s = reader_readString(r); out->drawlink(out,line,s); gfxline_free(line); free(s); break; } case OP_ADDFONT: { msg("<trace> replay: ADDFONT out=%08x(%s)", out, out->name); gfxfont_t*font = readFont(r, &state); if(!gfxfontlist_hasfont(*fontlist, font)) { *fontlist = gfxfontlist_addfont(*fontlist, font); out->addfont(out, font); } else { gfxfont_free(font); } break; } case OP_DRAWCHAR: { U32 glyph = reader_readU32(r); gfxmatrix_t m = {1,0,0, 0,1,0}; char* id = 0; if(!(flags&FLAG_ZERO_FONT)) id = read_string(r, &state, op, flags); gfxcolor_t color = read_color(r, &state, op, flags); gfxmatrix_t matrix = read_matrix(r, &state, op, flags); gfxfont_t*font = id?gfxfontlist_findfont(*fontlist, id):0; if(i && !font) { font = gfxfontlist_findfont(i->fontlist, id); } msg("<trace> replay: DRAWCHAR font=%s glyph=%d", id, glyph); out->drawchar(out, font, glyph, &color, &matrix); if(id) free(id); break; } } } finish: state_clear(&state); r->dealloc(r); if(_fontlist) gfxfontlist_free(_fontlist, 0); }
Glyph* read_idraw_graphic ( FILE* file, const Brush* pb, const Color* pfg, const Color* pbg, const Font* pf, Stipple* ps ) { skip(file); Transformer tx; Glyph* glyph = nil; const LayoutKit& layout = *LayoutKit::instance(); if (fscanf(file, "%s", buffer) != EOF) { figure& fig = figures[which(figures, buffer)]; if (strcmp(fig.name, "Idraw") == 0) { fscanf(file, "%d", &drawing_version); figures = versions[drawing_version]; } const Brush* b = (fig.brush) ? read_brush(file) : nil; const Color* fg = (fig.foreground) ? read_color(file) : nil; const Color* bg = (fig.background) ? read_color(file) : nil; const Font* f = (fig.font) ? read_font(file) : nil; Stipple* s = (fig.pattern) ? read_stipple(file) : nil; if (fig.transformer) { read_transformer(file, tx); } if (pb) b = pb; if (pfg) fg = pfg; if (pbg) bg = pbg; if (pf) f = pf; if (ps) s = ps; if (fig.name == nil) { ; // error } else if ( strcmp(fig.name, "Idraw") == 0 || strcmp(fig.name, "Pict") == 0 ) { Glyph* pic = layout.overlay(); Glyph* g; do { g = read_idraw_graphic(file, b, fg, bg, f, s); if (g != nil) { pic->append(g); } } while (g != nil); glyph = pic; } else if (strcmp(fig.name, "eop") == 0) { glyph = nil; } else if (strcmp(fig.name, "Text") == 0) { skip(file); fscanf(file, "%s", buffer); getc(file); PolyGlyph* col = layout.vbox_first_aligned(); PolyGlyph* line = layout.hbox_first_aligned(); FontBoundingBox bbox; f->font_bbox(bbox); Coord lineheight = bbox.font_ascent() + bbox.font_descent(); if (_idraw_font_metrics) { lineheight /= fixtextscale; } int c; while ((c = getc(file)) != ']') { if (c == '\n') { line->append(layout.strut(f)); col->append( layout.v_fixed_span(line, lineheight) ); line = layout.hbox(); } else if (c == ' ') { if (_idraw_font_metrics) { line->append( layout.shape_of(new Character(' ', f, fg)) ); } else { line->append(new Character(' ', f, fg)); } } else if (c != ')' && c != '(') { if (c == '\\') { c = getc(file); if (isdigit(c)) { c -= '0'; c = (c * 8) + getc(file) - '0'; c = (c * 8) + getc(file) - '0'; } } line->append(new Character(c, f, fg)); } } Transformer fixtext; if (_idraw_font_metrics) { fixtext.scale(fixtextscale, fixtextscale); } fixtext.translate(0, bbox.font_descent() - lineheight); glyph = new TransformSetter(col, fixtext); } else { skip(file); int c = fig.coords; if (c == -1) { fscanf(file, "%d", &c); } Coord xx, yy; Coord* x = new Coord[c]; Coord* y = new Coord[c]; for (int i = 0; i < c; ++i) { fscanf(file, "%g %g", &xx, &yy); x[i] = xx; y[i] = yy; } const Brush* brush = (b != no_brush) ? b : nil; const Color* stroke = fg; const Color* fill = ( (s != no_stipple) ? dither_color(fg, bg, s->_dither) : nil ); if (strcmp(fig.name, "Line") == 0) { glyph = new Line(brush, stroke, fill, x[0], y[0], x[1], y[1]); } else if (strcmp(fig.name, "BSpl") == 0) { glyph = new Open_BSpline(brush, stroke, fill, x, y, c); } else if (strcmp(fig.name, "CBSpl") == 0) { glyph = new Closed_BSpline(brush, stroke, fill, x, y, c); } else if (strcmp(fig.name, "MLine") == 0) { glyph = new Polyline(brush, stroke, fill, x, y, c); } else if (strcmp(fig.name, "Poly") == 0) { glyph = new Polygon(brush, stroke, fill, x, y, c); } else if (strcmp(fig.name, "Rect") == 0) { glyph = new Rectangle(brush, stroke, fill,x[0],y[0],x[1],y[1]); } else if (strcmp(fig.name, "Circ") == 0) { fscanf(file, "%f", &xx); glyph = new Circle(brush, stroke, fill, x[0], y[0], xx); } else if (strcmp(fig.name, "Elli") == 0) { fscanf(file, "%f %f", &xx, &yy); glyph = new Ellipse(brush, stroke, fill, x[0], y[0], xx, yy); } else { glyph = nil; } delete x; delete y; } for (int extra = fig.skip; extra > 0; --extra) { skip(file); } } if (glyph != nil && !tx.identity()) { glyph = new TransformSetter(glyph, tx); } return glyph; }
ULONG star(ULONG *arg) { rsiResult err; void *star; float f, range, diff; float *intensities; int i,j,spikes, randseed, step, h; rsiCOLOR color; BOOL update; update = FALSE; if (!light) return ERROR_NOLIGHT; err = rsiCreateStar(CTXT, light, &star); if (err) return err; if (arg[0]) { spikes = (int)*(LONG*)arg[0]; update = TRUE; } else spikes = 4; err = rsiSetStar(CTXT, star, rsiTStarSpikes, spikes, rsiTDone); if (err) return err; if (arg[1]) { f = (float)atof((char*)arg[1])/100; err = rsiSetStar(CTXT, star, rsiTStarRadius, f, rsiTDone); if (err) return err; } if (arg[2]) { f = (float)atof((char*)arg[2])/100; err = rsiSetStar(CTXT, star, rsiTStarHaloRadius, f, rsiTDone); if (err) return err; } if (arg[3]) { f = (float)atof((char*)arg[3])/100; err = rsiSetStar(CTXT, star, rsiTStarInnerHaloRadius, f, rsiTDone); if (err) return err; } if (arg[4]) { range = (float)atof((char*)arg[4])/100; update = TRUE; } else range = 0; if (arg[5]) { randseed = *(ULONG*)arg[5]; update = TRUE; } else randseed = 0; if (arg[6]) { f = (float)atof((char*)arg[7]); err = rsiSetStar(CTXT, star, rsiTStarTilt, f, rsiTDone); if (err) return err; } if (arg[7]) { if (!read_color(&color, (char*)arg[7])) return ERROR_COLOR; err = rsiSetStar(CTXT, star, rsiTStarColor, &color, rsiTDone); if (err) return err; } if (arg[8]) { if (!read_color(&color, (char*)arg[8])) return ERROR_COLOR; err = rsiSetStar(CTXT, star, rsiTStarRingColor, &color, rsiTDone); if (err) return err; } if (arg[9]) { f = (float)atof((char*)arg[9]); err = rsiSetStar(CTXT, star, rsiTStarNoise, f, rsiTDone); if (err) return err; } if (arg[10]) { f = (float)atof((char*)arg[100]); err = rsiSetStar(CTXT, star, rsiTStarBrightness, f, rsiTDone); if (err) return err; } if (update) { intensities = new float[spikes]; if (!intensities) return ERROR_MEM; // calculate no. of sub-spike lengths // i.e. a star with 8 spikes has two lengths. One for the four main directions // and the other length for the spikes between them h = int(log(float(spikes))/log(2.)); if (h > 2) diff = range/(h - 2); else { h++; diff = range; } // generate the spikes step = 1; for (j = 1; j < h; j++) { for (i = 0; i < spikes; i += step) { if (j == 1) intensities[i] = 1. - range; else intensities[i] += diff; } step += step; } // apply random length if (randseed > 0) { srand(randseed); for (i = 0; i < spikes; i++) { intensities[i]+= (float(rand())/RAND_MAX) * range - range; if (intensities[i] < 0.) intensities[i] = 0.; if (intensities[i] > 1.) intensities[i] = 1.; } } err = rsiSetStar(CTXT, star, rsiTStarIntensities, intensities, rsiTDone); delete intensities; if (err) return err; } return rsiERR_NONE; }