本文整理汇总了C++中SVGTransform::type方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGTransform::type方法的具体用法?C++ SVGTransform::type怎么用?C++ SVGTransform::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGTransform
的用法示例。
在下文中一共展示了SVGTransform::type方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addSVGTransform
void SVGTransformDistance::addSVGTransform(const SVGTransform& transform, bool absoluteValue)
{
// If this is the first add, set the type for this SVGTransformDistance
if (m_type == SVGTransform::SVG_TRANSFORM_UNKNOWN)
m_type = transform.type();
ASSERT(m_type == transform.type());
switch (m_type) {
case SVGTransform::SVG_TRANSFORM_UNKNOWN:
return;
case SVGTransform::SVG_TRANSFORM_MATRIX:
m_transform *= transform.matrix(); // FIXME: what does 'distance' between two transforms mean? how should we respect 'absoluteValue' here?
return;
case SVGTransform::SVG_TRANSFORM_ROTATE:
m_angle += absoluteValue ? fabsf(transform.angle()) : transform.angle();
m_cx += absoluteValue ? fabsf(transform.rotationCenter().x()) : transform.rotationCenter().x();
m_cy += absoluteValue ? fabsf(transform.rotationCenter().y()) : transform.rotationCenter().y();
// fall through
case SVGTransform::SVG_TRANSFORM_TRANSLATE:
{
float dx = absoluteValue ? fabsf(transform.translate().x()) : transform.translate().x();
float dy = absoluteValue ? fabsf(transform.translate().y()) : transform.translate().y();
m_transform.translate(dx, dy);
return;
}
case SVGTransform::SVG_TRANSFORM_SCALE:
{
float scaleX = absoluteValue ? fabsf(transform.scale().width()) : transform.scale().width();
float scaleY = absoluteValue ? fabsf(transform.scale().height()) : transform.scale().height();
m_transform.scaleNonUniform(scaleX, scaleY);
return;
}
case SVGTransform::SVG_TRANSFORM_SKEWX:
case SVGTransform::SVG_TRANSFORM_SKEWY:
m_angle += absoluteValue ? fabsf(transform.angle()) : transform.angle();
return;
}
ASSERT_NOT_REACHED();
return;
}
示例2: addSVGTransforms
SVGTransform SVGTransformDistance::addSVGTransforms(const SVGTransform& first, const SVGTransform& second)
{
ASSERT(first.type() == second.type());
SVGTransform transform;
switch (first.type()) {
case SVGTransform::SVG_TRANSFORM_UNKNOWN:
return SVGTransform();
case SVGTransform::SVG_TRANSFORM_ROTATE:
{
transform.setRotate(first.angle() + second.angle(), first.rotationCenter().x() + second.rotationCenter().x(),
first.rotationCenter().y() + second.rotationCenter().y());
return transform;
}
case SVGTransform::SVG_TRANSFORM_MATRIX:
transform.setMatrix(first.matrix() * second.matrix());
return transform;
case SVGTransform::SVG_TRANSFORM_TRANSLATE:
{
float dx = first.translate().x() + second.translate().x();
float dy = first.translate().y() + second.translate().y();
transform.setTranslate(dx, dy);
return transform;
}
case SVGTransform::SVG_TRANSFORM_SCALE:
{
FloatSize scale = first.scale() + second.scale();
transform.setScale(scale.width(), scale.height());
return transform;
}
case SVGTransform::SVG_TRANSFORM_SKEWX:
transform.setSkewX(first.angle() + second.angle());
return transform;
case SVGTransform::SVG_TRANSFORM_SKEWY:
transform.setSkewY(first.angle() + second.angle());
return transform;
}
ASSERT_NOT_REACHED();
return SVGTransform();
}
示例3: valueAsString
String SVGTransformList::valueAsString() const
{
// TODO: We may want to build a real transform string, instead of concatting to a matrix(...).
SVGTransform transform = concatenate();
if (transform.type() == SVGTransform::SVG_TRANSFORM_MATRIX) {
TransformationMatrix matrix = transform.matrix();
return String::format("matrix(%f %f %f %f %f %f)", matrix.a(), matrix.b(), matrix.c(), matrix.d(), matrix.e(), matrix.f());
}
return String();
}
示例4: ASSERT
SVGTransformDistance::SVGTransformDistance(const SVGTransform& fromSVGTransform, const SVGTransform& toSVGTransform)
: m_type(fromSVGTransform.type())
, m_angle(0)
, m_cx(0)
, m_cy(0)
{
ASSERT(m_type == toSVGTransform.type());
switch (m_type) {
case SVGTransform::SVG_TRANSFORM_UNKNOWN:
return;
case SVGTransform::SVG_TRANSFORM_MATRIX:
// FIXME: need to be able to subtract to matrices
return;
case SVGTransform::SVG_TRANSFORM_ROTATE:
{
FloatSize centerDistance = toSVGTransform.rotationCenter() - fromSVGTransform.rotationCenter();
m_angle = toSVGTransform.angle() - fromSVGTransform.angle();
m_cx = centerDistance.width();
m_cy = centerDistance.height();
return;
}
case SVGTransform::SVG_TRANSFORM_TRANSLATE:
{
FloatSize translationDistance = toSVGTransform.translate() - fromSVGTransform.translate();
m_transform.translate(translationDistance.width(), translationDistance.height());
return;
}
case SVGTransform::SVG_TRANSFORM_SCALE:
{
float scaleX = toSVGTransform.scale().width() - fromSVGTransform.scale().width();
float scaleY = toSVGTransform.scale().height() - fromSVGTransform.scale().height();
m_transform.scaleNonUniform(scaleX, scaleY);
return;
}
case SVGTransform::SVG_TRANSFORM_SKEWX:
case SVGTransform::SVG_TRANSFORM_SKEWY:
m_angle = toSVGTransform.angle() - fromSVGTransform.angle();
return;
}
}
示例5: calculateDistance
float SVGAnimateTransformElement::calculateDistance(const String& fromString, const String& toString)
{
// FIXME: This is not correct in all cases. The spec demands that each component (translate x and y for example)
// is paced separately. To implement this we need to treat each component as individual animation everywhere.
SVGTransform from = parseTransformValue(fromString);
if (!from.isValid())
return -1.f;
SVGTransform to = parseTransformValue(toString);
if (!to.isValid() || from.type() != to.type())
return -1.f;
if (to.type() == SVGTransform::SVG_TRANSFORM_TRANSLATE) {
FloatSize diff = to.translate() - from.translate();
return sqrtf(diff.width() * diff.width() + diff.height() * diff.height());
}
if (to.type() == SVGTransform::SVG_TRANSFORM_ROTATE)
return fabsf(to.angle() - from.angle());
if (to.type() == SVGTransform::SVG_TRANSFORM_SCALE) {
FloatSize diff = to.scale() - from.scale();
return sqrtf(diff.width() * diff.width() + diff.height() * diff.height());
}
return -1.f;
}
示例6: ASSERT
SVGTransformDistance::SVGTransformDistance(const SVGTransform& fromSVGTransform, const SVGTransform& toSVGTransform)
: m_type(fromSVGTransform.type())
, m_angle(0)
, m_cx(0)
, m_cy(0)
{
ASSERT(m_type == toSVGTransform.type());
switch (m_type) {
case SVGTransform::SVG_TRANSFORM_MATRIX:
ASSERT_NOT_REACHED();
case SVGTransform::SVG_TRANSFORM_UNKNOWN:
break;
case SVGTransform::SVG_TRANSFORM_ROTATE: {
FloatSize centerDistance = toSVGTransform.rotationCenter() - fromSVGTransform.rotationCenter();
m_angle = toSVGTransform.angle() - fromSVGTransform.angle();
m_cx = centerDistance.width();
m_cy = centerDistance.height();
break;
}
case SVGTransform::SVG_TRANSFORM_TRANSLATE: {
FloatSize translationDistance = toSVGTransform.translate() - fromSVGTransform.translate();
m_transform.translate(translationDistance.width(), translationDistance.height());
break;
}
case SVGTransform::SVG_TRANSFORM_SCALE: {
float scaleX = toSVGTransform.scale().width() - fromSVGTransform.scale().width();
float scaleY = toSVGTransform.scale().height() - fromSVGTransform.scale().height();
m_transform.scaleNonUniform(scaleX, scaleY);
break;
}
case SVGTransform::SVG_TRANSFORM_SKEWX:
case SVGTransform::SVG_TRANSFORM_SKEWY:
m_angle = toSVGTransform.angle() - fromSVGTransform.angle();
break;
}
}
示例7: addToSVGTransform
SVGTransform SVGTransformDistance::addToSVGTransform(const SVGTransform& transform) const
{
ASSERT(m_type == transform.type() || transform == SVGTransform());
SVGTransform newTransform(transform);
switch (m_type) {
case SVGTransform::SVG_TRANSFORM_UNKNOWN:
return SVGTransform();
case SVGTransform::SVG_TRANSFORM_MATRIX:
return SVGTransform(transform.matrix() * m_transform);
case SVGTransform::SVG_TRANSFORM_TRANSLATE:
{
FloatPoint translation = transform.translate();
translation += FloatSize::narrowPrecision(m_transform.e(), m_transform.f());
newTransform.setTranslate(translation.x(), translation.y());
return newTransform;
}
case SVGTransform::SVG_TRANSFORM_SCALE:
{
FloatSize scale = transform.scale();
scale += FloatSize::narrowPrecision(m_transform.a(), m_transform.d());
newTransform.setScale(scale.width(), scale.height());
return newTransform;
}
case SVGTransform::SVG_TRANSFORM_ROTATE:
{
// FIXME: I'm not certain the translation is calculated correctly here
FloatPoint center = transform.rotationCenter();
newTransform.setRotate(transform.angle() + m_angle,
center.x() + m_cx,
center.y() + m_cy);
return newTransform;
}
case SVGTransform::SVG_TRANSFORM_SKEWX:
newTransform.setSkewX(transform.angle() + m_angle);
return newTransform;
case SVGTransform::SVG_TRANSFORM_SKEWY:
newTransform.setSkewY(transform.angle() + m_angle);
return newTransform;
}
ASSERT_NOT_REACHED();
return SVGTransform();
}