本文整理汇总了C++中SkPoint::scale方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPoint::scale方法的具体用法?C++ SkPoint::scale怎么用?C++ SkPoint::scale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPoint
的用法示例。
在下文中一共展示了SkPoint::scale方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: center_of_mass
static void center_of_mass(const SegmentArray& segments, SkPoint* c) {
SkScalar area = 0;
SkPoint center = {0, 0};
int count = segments.count();
SkPoint p0 = {0, 0};
if (count > 2) {
// We translate the polygon so that the first point is at the origin.
// This avoids some precision issues with small area polygons far away
// from the origin.
p0 = segments[0].endPt();
SkPoint pi;
SkPoint pj;
// the first and last iteration of the below loop would compute
// zeros since the starting / ending point is (0,0). So instead we start
// at i=1 and make the last iteration i=count-2.
pj = segments[1].endPt() - p0;
for (int i = 1; i < count - 1; ++i) {
pi = pj;
pj = segments[i + 1].endPt() - p0;
SkScalar t = SkPoint::CrossProduct(pi, pj);
area += t;
center.fX += (pi.fX + pj.fX) * t;
center.fY += (pi.fY + pj.fY) * t;
}
}
// If the poly has no area then we instead return the average of
// its points.
if (SkScalarNearlyZero(area)) {
SkPoint avg;
avg.set(0, 0);
for (int i = 0; i < count; ++i) {
const SkPoint& pt = segments[i].endPt();
avg.fX += pt.fX;
avg.fY += pt.fY;
}
SkScalar denom = SK_Scalar1 / count;
avg.scale(denom);
*c = avg;
} else {
area *= 3;
area = SkScalarInvert(area);
center.scale(area);
// undo the translate of p0 to the origin.
*c = center + p0;
}
SkASSERT(!SkScalarIsNaN(c->fX) && !SkScalarIsNaN(c->fY));
}
示例2: updateDom
void updateDom() {
const SkPoint corner = pos - SkPoint::Make(size.width() / 2, size.height() / 2);
update_pos(objectNode, corner);
// Simulate parallax shadow for a centered light source.
SkPoint shadowOffset = pos - SkPoint::Make(kBounds.centerX(), kBounds.centerY());
shadowOffset.scale(kShadowParallax);
const SkPoint shadowCorner = corner + shadowOffset;
update_pos(shadowNode, shadowCorner);
}
示例3: updateDom
void updateDom() {
const SkPoint corner = pos - SkPoint::Make(size.width() / 2, size.height() / 2);
objectNode->setX(SkSVGLength(corner.x()));
objectNode->setY(SkSVGLength(corner.y()));
// Simulate parallax shadow for a centered light source.
SkPoint shadowOffset = pos - SkPoint::Make(kBounds.centerX(), kBounds.centerY());
shadowOffset.scale(kShadowParallax);
const SkPoint shadowCorner = corner + shadowOffset;
shadowNode->setX(SkSVGLength(shadowCorner.x()));
shadowNode->setY(SkSVGLength(shadowCorner.y()));
}