本文整理汇总了C++中KeyframeVector::append方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyframeVector::append方法的具体用法?C++ KeyframeVector::append怎么用?C++ KeyframeVector::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyframeVector
的用法示例。
在下文中一共展示了KeyframeVector::append方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setTiming
void InspectorAnimationAgent::setTiming(ErrorString* errorString, const String& animationId, double duration, double delay)
{
Animation* animation = assertAnimation(errorString, animationId);
if (!animation)
return;
AnimationType type = m_idToAnimationType.get(animationId);
if (type == AnimationType::CSSTransition) {
KeyframeEffect* effect = toKeyframeEffect(animation->effect());
KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect->model());
const AnimatableValueKeyframeEffectModel* oldModel = toAnimatableValueKeyframeEffectModel(model);
// Refer to CSSAnimations::calculateTransitionUpdateForProperty() for the structure of transitions.
const KeyframeVector& frames = oldModel->getFrames();
ASSERT(frames.size() == 3);
KeyframeVector newFrames;
for (int i = 0; i < 3; i++)
newFrames.append(toAnimatableValueKeyframe(frames[i]->clone().get()));
// Update delay, represented by the distance between the first two keyframes.
newFrames[1]->setOffset(delay / (delay + duration));
model->setFrames(newFrames);
AnimationEffectTiming* timing = animation->effect()->timing();
UnrestrictedDoubleOrString unrestrictedDuration;
unrestrictedDuration.setUnrestrictedDouble(duration + delay);
timing->setDuration(unrestrictedDuration);
} else if (type == AnimationType::WebAnimation) {
AnimationEffectTiming* timing = animation->effect()->timing();
UnrestrictedDoubleOrString unrestrictedDuration;
unrestrictedDuration.setUnrestrictedDouble(duration);
timing->setDuration(unrestrictedDuration);
timing->setDelay(delay);
}
}
示例2: normalizedKeyframes
KeyframeEffectModelBase::KeyframeVector KeyframeEffectModelBase::normalizedKeyframes(const KeyframeVector& keyframes)
{
double lastOffset = 0;
KeyframeVector result;
result.reserveCapacity(keyframes.size());
for (size_t i = 0; i < keyframes.size(); ++i) {
double offset = keyframes[i]->offset();
if (!isNull(offset)) {
ASSERT(offset >= 0);
ASSERT(offset <= 1);
ASSERT(offset >= lastOffset);
lastOffset = offset;
}
result.append(keyframes[i]->clone());
}
if (result.isEmpty()) {
return result;
}
if (isNull(result.last()->offset()))
result.last()->setOffset(1);
if (result.size() > 1 && isNull(result[0]->offset()))
result[0]->setOffset(0);
size_t lastIndex = 0;
lastOffset = result[0]->offset();
for (size_t i = 1; i < result.size(); ++i) {
double offset = result[i]->offset();
if (!isNull(offset)) {
for (size_t j = 1; j < i - lastIndex; ++j)
result[lastIndex + j]->setOffset(lastOffset + (offset - lastOffset) * j / (i - lastIndex));
lastIndex = i;
lastOffset = offset;
}
}
return result;
}
示例3: normalizedKeyframes
KeyframeEffectModelBase::KeyframeVector KeyframeEffectModelBase::normalizedKeyframes(const KeyframeVector& keyframes)
{
// keyframes [beginIndex, endIndex) will remain after removing all keyframes if they are not
// loosely sorted by offset, and after removing keyframes with positional offset outide [0, 1].
size_t beginIndex = 0;
size_t endIndex = keyframes.size();
// Becomes the most recent keyframe with an explicit offset.
size_t lastIndex = endIndex;
double lastOffset = std::numeric_limits<double>::quiet_NaN();
for (size_t i = 0; i < keyframes.size(); ++i) {
double offset = keyframes[i]->offset();
if (!isNull(offset)) {
if (lastIndex < i && offset < lastOffset) {
// The keyframes are not loosely sorted by offset. Exclude all.
endIndex = beginIndex;
break;
}
if (offset < 0) {
// Remove all keyframes up to and including this keyframe.
beginIndex = i + 1;
} else if (offset > 1) {
// Remove all keyframes from this keyframe onwards. Note we must complete our checking
// that the keyframes are loosely sorted by offset, so we can't exit the loop early.
endIndex = std::min(i, endIndex);
}
lastIndex = i;
lastOffset = offset;
}
}
KeyframeVector result;
if (beginIndex != endIndex) {
result.reserveCapacity(endIndex - beginIndex);
for (size_t i = beginIndex; i < endIndex; ++i) {
result.append(keyframes[i]->clone());
}
if (isNull(result[result.size() - 1]->offset()))
result[result.size() - 1]->setOffset(1);
if (result.size() > 1 && isNull(result[0]->offset()))
result[0]->setOffset(0);
lastIndex = 0;
lastOffset = result[0]->offset();
for (size_t i = 1; i < result.size(); ++i) {
double offset = result[i]->offset();
if (!isNull(offset)) {
if (lastIndex + 1 < i) {
for (size_t j = 1; j < i - lastIndex; ++j)
result[lastIndex + j]->setOffset(lastOffset + (offset - lastOffset) * j / (i - lastIndex));
}
lastIndex = i;
lastOffset = offset;
}
}
}
return result;
}