本文整理汇总了C++中SVGLength::newValueSpecifiedUnits方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGLength::newValueSpecifiedUnits方法的具体用法?C++ SVGLength::newValueSpecifiedUnits怎么用?C++ SVGLength::newValueSpecifiedUnits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGLength
的用法示例。
在下文中一共展示了SVGLength::newValueSpecifiedUnits方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fromCSSPrimitiveValue
SVGLength SVGLength::fromCSSPrimitiveValue(CSSPrimitiveValue* value)
{
ASSERT(value);
SVGLengthType svgType;
switch (value->primitiveType()) {
case CSSPrimitiveValue::CSS_NUMBER:
svgType = LengthTypeNumber;
break;
case CSSPrimitiveValue::CSS_PERCENTAGE:
svgType = LengthTypePercentage;
break;
case CSSPrimitiveValue::CSS_EMS:
svgType = LengthTypeEMS;
break;
case CSSPrimitiveValue::CSS_EXS:
svgType = LengthTypeEXS;
break;
case CSSPrimitiveValue::CSS_PX:
svgType = LengthTypePX;
break;
case CSSPrimitiveValue::CSS_CM:
svgType = LengthTypeCM;
break;
case CSSPrimitiveValue::CSS_MM:
svgType = LengthTypeMM;
break;
case CSSPrimitiveValue::CSS_IN:
svgType = LengthTypeIN;
break;
case CSSPrimitiveValue::CSS_PT:
svgType = LengthTypePT;
break;
case CSSPrimitiveValue::CSS_PC:
svgType = LengthTypePC;
break;
case CSSPrimitiveValue::CSS_UNKNOWN:
default:
svgType = LengthTypeUnknown;
break;
};
if (svgType == LengthTypeUnknown)
return SVGLength();
TrackExceptionState exceptionState;
SVGLength length;
length.newValueSpecifiedUnits(svgType, value->getFloatValue(), exceptionState);
if (exceptionState.hadException())
return SVGLength();
return length;
}
示例2: newValueSpecifiedUnitsCallback
static v8::Handle<v8::Value> newValueSpecifiedUnitsCallback(const v8::Arguments& args)
{
INC_STATS("DOM.SVGLength.newValueSpecifiedUnits");
V8SVGPODTypeWrapper<SVGLength>* impWrapper = V8SVGPODTypeWrapper<SVGLength>::toNative(args.Holder());
SVGLength impInstance = *impWrapper;
SVGLength* imp = &impInstance;
EXCEPTION_BLOCK(int, unitType, toUInt32(args[0]));
EXCEPTION_BLOCK(float, valueInSpecifiedUnits, static_cast<float>(args[1]->NumberValue()));
imp->newValueSpecifiedUnits(unitType, valueInSpecifiedUnits);
SVGElement* context = V8Proxy::svgContext(impWrapper);
impWrapper->commitChange(impInstance, context);
return v8::Handle<v8::Value>();
}
示例3: fromCSSPrimitiveValue
SVGLength SVGLength::fromCSSPrimitiveValue(CSSPrimitiveValue& value)
{
SVGLengthType svgType;
switch (value.primitiveType()) {
case CSSPrimitiveValue::CSS_NUMBER:
svgType = LengthTypeNumber;
break;
case CSSPrimitiveValue::CSS_PERCENTAGE:
svgType = LengthTypePercentage;
break;
case CSSPrimitiveValue::CSS_EMS:
svgType = LengthTypeEMS;
break;
case CSSPrimitiveValue::CSS_EXS:
svgType = LengthTypeEXS;
break;
case CSSPrimitiveValue::CSS_PX:
svgType = LengthTypePX;
break;
case CSSPrimitiveValue::CSS_CM:
svgType = LengthTypeCM;
break;
case CSSPrimitiveValue::CSS_MM:
svgType = LengthTypeMM;
break;
case CSSPrimitiveValue::CSS_IN:
svgType = LengthTypeIN;
break;
case CSSPrimitiveValue::CSS_PT:
svgType = LengthTypePT;
break;
case CSSPrimitiveValue::CSS_PC:
svgType = LengthTypePC;
break;
case CSSPrimitiveValue::CSS_UNKNOWN:
default:
svgType = LengthTypeUnknown;
break;
};
if (svgType == LengthTypeUnknown)
return SVGLength();
ExceptionCode ec = 0;
SVGLength length;
length.newValueSpecifiedUnits(svgType, value.getFloatValue(), ec);
if (ec)
return SVGLength();
return length;
}
示例4: if
//.........这里部分代码省略.........
float v1 = l.computeValue();
l = values.getItem(i+1);
float v2 = l.computeValue();
_keyFrames.push_back(KeyFrame(KeyFrame::ValueType(v1,v2), t));
t+=dt;
}
}
}
else {
unicode::String* fromstr = GET_SIMPLE_VAL(From);
unicode::String* tostr = GET_SIMPLE_VAL(To);
unicode::String* bystr = GET_SIMPLE_VAL(By);
//std::cerr << DBGVAR(attrName) << DBGVAR(attrType) << DBGVAR(fromstr) << DBGVAR(tostr) << __FL__;
SVGList<SVGLength> from, to, by;
bool fromb=false, tob=false, byb=false;
svgl::read(fromstr,from);
svgl::read(tostr,to);
svgl::read(bystr,by);
fromb = (from.numberOfItems()>0);
tob = (to.numberOfItems()>0);
byb = (by.numberOfItems()>0);
// std::cerr << DBGVAR(fromb) << DBGVAR(tob) << DBGVAR(byb) << __FL__;
if( !(fromb||tob||byb) ) {
std::cerr << "'from', 'to' and 'by' are unset" << __FL__;
return;
}
if(fromb && from.numberOfItems()!=2) {
std::cerr << "'from' for 'animateMotion' must be a pair of length" << __FL__;
return;
}
if(tob && to.numberOfItems()!=2) {
std::cerr << "'to' for 'animateMotion' must be a pair of length" << __FL__;
return;
}
if(byb && by.numberOfItems()!=2) {
std::cerr << "'by' for 'animateMotion' must be a pair of length" << __FL__;
return;
}
// FIXME
// from is not computed with right dpi...
if(!fromb) {
static unicode::String
*x_string = unicode::String::internString("x"),
*y_string = unicode::String::internString("y");
svgl::AnimateAdapter* x = _elementToAnimate->getAttributeByName(x_string);
if(x==0 || !x->canBeSetAsDouble()) {
std::cerr << "attribute 'x' of the element referenced by 'animateMotion' can not be set as double" << __FL__;
return;
}
svgl::AnimateAdapter* y = _elementToAnimate->getAttributeByName(y_string);
if(y==0 || !y->canBeSetAsDouble()) {
std::cerr << "attribute 'y' of the element referenced by 'animateMotion' can not be set as double" << __FL__;
return;
}
SVGLength l;
l.newValueSpecifiedUnits(SVGLength::SVG_LENGTHTYPE_NUMBER, x->getBaseVal());
from.replaceItem(l,0);
l.newValueSpecifiedUnits(SVGLength::SVG_LENGTHTYPE_NUMBER, y->getBaseVal());
from.replaceItem(l,1);
fromb=true;
}
if(!tob) {
if(byb) {
to.replaceItem(from.getItem(0)+by.getItem(0), 0);
to.replaceItem(from.getItem(1)+by.getItem(1), 1);
}
#if 0
else {
STDDBG;
return;
}
#endif
}
if(fromb)
_keyFrames.push_back(KeyFrame( KeyFrame::ValueType(from.getItem(0).GET_SIMPLE_VAL(Value), from.getItem(1).GET_SIMPLE_VAL(Value)), 0));
_keyFrames.push_back(KeyFrame( KeyFrame::ValueType(to.getItem(0).GET_SIMPLE_VAL(Value), to.getItem(1).GET_SIMPLE_VAL(Value)), 1));
}
#if 0
STDDBG;
for(unsigned int j=0; j<_keyFrames.size(); ++j) {
std::cerr << "( <" << _keyFrames[j].value.first << "," << _keyFrames[j].value.second << ">, " << _keyFrames[j].time << ")";
}
std::cerr << std::endl;
#endif
}