📄 animate_a.cpp
字号:
}void animate_attrs::get_values(std::vector<int>& v) { if(m_animtype == "values") { const char *pvalues = m_node->get_attribute("values"); std::list<std::string> c; if(pvalues) lib::split_trim_list(pvalues, c, ';'); for(std::list<std::string>::iterator it=c.begin();it!=c.end();it++) v.push_back(safeatoi((*it).c_str())); } else if(m_animtype == "from-to") { const char *pfrom = m_node->get_attribute("from"); const char *pto = m_node->get_attribute("to"); v.push_back(safeatoi(pfrom)); v.push_back(safeatoi(pto)); } else if(m_animtype == "from-by") { const char *pfrom = m_node->get_attribute("from"); const char *pby = m_node->get_attribute("by"); int v1 = safeatoi(pfrom); int dv = safeatoi(pby); v.push_back(v1); v.push_back(v1+dv); } else if(m_animtype == "to") { const char *pto = m_node->get_attribute("to"); v.push_back(safeatoi(pto)); } else if(m_animtype == "by") { const char *pby = m_node->get_attribute("by"); v.push_back(0); v.push_back(safeatoi(pby)); } else { assert(false); }}double animate_attrs::safeatof(const char *p) { if(!p) return 0; return atof(p);}void animate_attrs::get_values(std::vector<double>& v) { if(m_animtype == "values") { const char *pvalues = m_node->get_attribute("values"); std::list<std::string> c; if(pvalues) lib::split_trim_list(pvalues, c, ';'); for(std::list<std::string>::iterator it=c.begin();it!=c.end();it++) v.push_back(safeatof((*it).c_str())); } else if(m_animtype == "from-to") { const char *pfrom = m_node->get_attribute("from"); const char *pto = m_node->get_attribute("to"); v.push_back(safeatof(pfrom)); v.push_back(safeatof(pto)); } else if(m_animtype == "from-by") { const char *pfrom = m_node->get_attribute("from"); const char *pby = m_node->get_attribute("by"); double v1 = safeatof(pfrom); double dv = safeatof(pby); v.push_back(v1); v.push_back(v1+dv); } else if(m_animtype == "to") { const char *pto = m_node->get_attribute("to"); v.push_back(safeatof(pto)); } else if(m_animtype == "by") { const char *pby = m_node->get_attribute("by"); v.push_back(0); v.push_back(safeatof(pby)); } else { assert(false); }}void animate_attrs::get_values(std::vector<std::string>& v) { if(m_animtype == "values") { const char *pvalues = m_node->get_attribute("values"); std::list<std::string> c; if(pvalues) lib::split_trim_list(pvalues, c, ';'); for(std::list<std::string>::iterator it=c.begin();it!=c.end();it++) v.push_back(*it); } else if(m_animtype == "from-to") { const char *pfrom = m_node->get_attribute("from"); const char *pto = m_node->get_attribute("to"); v.push_back(pfrom); v.push_back(pto); } else if(m_animtype == "from-by") { assert(false); } else if(m_animtype == "to") { const char *pto = m_node->get_attribute("to"); v.push_back(pto); } else if(m_animtype == "by") { assert(false); } else { assert(false); }}// common::region_dim ::= S? (int|dec) ((px)? | %)common::region_dim animate_attrs::to_region_dim(const std::string& s) { lib::region_dim_p parser; std::string::const_iterator b = s.begin(); std::string::const_iterator e = s.end(); std::ptrdiff_t d = parser.parse(b, e); if(d == -1) { m_logger->trace("<%s id=\"%s\">: invalid region dim \"%s\"", m_tag.c_str(), m_id.c_str(), s.c_str()); m_logger->warn(gettext("Error in SMIL animation")); return common::region_dim(); } if(parser.is_relative()) return common::region_dim(parser.get_relative_val()); return common::region_dim(parser.get_px_val());}void animate_attrs::get_values(std::vector<common::region_dim>& v) { if(m_animtype == "values") { const char *pvalues = m_node->get_attribute("values"); std::list<std::string> c; if(pvalues) lib::split_trim_list(pvalues, c, ';'); for(std::list<std::string>::iterator it=c.begin();it!=c.end();it++) v.push_back(to_region_dim(*it)); } else if(m_animtype == "from-to") { const char *pfrom = m_node->get_attribute("from"); const char *pto = m_node->get_attribute("to"); v.push_back(to_region_dim(pfrom)); v.push_back(to_region_dim(pto)); } else if(m_animtype == "from-by") { const char *pfrom = m_node->get_attribute("from"); const char *pby = m_node->get_attribute("by"); common::region_dim v1 = to_region_dim(pfrom); common::region_dim dv = to_region_dim(pby); v.push_back(v1); v.push_back(v1+dv); } else if(m_animtype == "to") { const char *pto = m_node->get_attribute("to"); v.push_back(to_region_dim(pto)); } else if(m_animtype == "by") { const char *pby = m_node->get_attribute("by"); v.push_back(common::region_dim(0)); v.push_back(to_region_dim(pby)); } else { assert(false); }}void animate_attrs::get_values(std::vector<lib::color_t>& v) { using lib::to_color; if(m_animtype == "values") { const char *pvalues = m_node->get_attribute("values"); std::list<std::string> c; if(pvalues) lib::split_trim_list(pvalues, c, ';'); for(std::list<std::string>::iterator it=c.begin();it!=c.end();it++) v.push_back(to_color((*it).c_str())); } else if(m_animtype == "from-to") { const char *pfrom = m_node->get_attribute("from"); const char *pto = m_node->get_attribute("to"); v.push_back(to_color(pfrom)); v.push_back(to_color(pto)); } else if(m_animtype == "from-by") { const char *pfrom = m_node->get_attribute("from"); const char *pby = m_node->get_attribute("by"); lib::color_t v1 = to_color(pfrom); lib::color_t dv = to_color(pby); v.push_back(v1); v.push_back(v1+dv); } else if(m_animtype == "to") { const char *pto = m_node->get_attribute("to"); v.push_back(to_color(pto)); } else if(m_animtype == "by") { const char *pby = m_node->get_attribute("by"); v.push_back(0); v.push_back(to_color(pby)); } else { assert(false); }}void animate_attrs::get_values(std::vector<common::sound_alignment>& v) { common::sound_alignment sa = common::sa_default; if(m_animtype == "to") { const char *pto = m_node->get_attribute("to"); assert(pto); if (strcmp(pto, "left") == 0) sa = common::sa_left; else if (strcmp(pto, "right") == 0) sa = common::sa_right; else if (strcmp(pto, "both") == 0) sa = common::sa_both; else if (strcmp(pto, "default") == 0) sa = common::sa_default; else { m_logger->error("<%s id=\"%s\">: invalid soundAlign \"%s\"", m_tag.c_str(), m_id.c_str(), pto); } } else { assert(false); } v.push_back(sa);}// point := S? (? x S? , S? y S? )?lib::point animate_attrs::to_point(const std::string& s) { lib::point_p parser; std::string::const_iterator b = s.begin(); std::string::const_iterator e = s.end(); std::ptrdiff_t d = parser.parse(b, e); if(d == -1) { m_logger->error("<%s id=\"%s\">: invalid point \"%s\"", m_tag.c_str(), m_id.c_str(), s.c_str()); m_logger->warn(gettext("Error in SMIL animation")); return lib::point(); } return lib::point(parser.get_x(), parser.get_y());}void animate_attrs::get_values(std::vector<lib::point>& v) { if(m_animtype == "path") { const char *ppath = m_node->get_attribute("path"); lib::gpath_descr pd(ppath?ppath:"m 0 0"); lib::polyline_builder builder; lib::gpath *path = builder.build_path(&pd); path->get_pivot_points(v); } else if(m_animtype == "values") { const char *pvalues = m_node->get_attribute("values"); std::list<std::string> c; if(pvalues) lib::split_trim_list(pvalues, c, ';'); for(std::list<std::string>::iterator it=c.begin();it!=c.end();it++) v.push_back(to_point(*it)); } else if(m_animtype == "from-to") { const char *pfrom = m_node->get_attribute("from"); const char *pto = m_node->get_attribute("to"); v.push_back(to_point(pfrom)); v.push_back(to_point(pto)); } else if(m_animtype == "from-by") { const char *pfrom = m_node->get_attribute("from"); const char *pby = m_node->get_attribute("by"); lib::point v1 = to_point(pfrom); lib::point dv = to_point(pby); v.push_back(v1); v.push_back(v1+dv); } else if(m_animtype == "to") { const char *pto = m_node->get_attribute("to"); v.push_back(to_point(pto)); } else if(m_animtype == "by") { const char *pby = m_node->get_attribute("by"); v.push_back(lib::point(0, 0)); v.push_back(to_point(pby)); } else { assert(false); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -