本文整理汇总了C++中SkPoint::setLength方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPoint::setLength方法的具体用法?C++ SkPoint::setLength怎么用?C++ SkPoint::setLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPoint
的用法示例。
在下文中一共展示了SkPoint::setLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add_quad
static void add_quad(SkPoint pts[3], PLSVertices& vertices) {
SkPoint normal = SkPoint::Make(pts[0].fY - pts[2].fY,
pts[2].fX - pts[0].fX);
normal.setLength(kBloatSize);
SkScalar cross = (pts[1] - pts[0]).cross(pts[2] - pts[0]);
if (cross < 0) {
normal = -normal;
}
PLSVertex quad[kQuadNumVertices];
quad[0].fPos = pts[0] + normal;
quad[1].fPos = pts[0] - normal;
quad[2].fPos = pts[1] - normal;
quad[3].fPos = pts[2] - normal;
quad[4].fPos = pts[2] + normal;
for (int i = 0; i < kQuadNumVertices; i++) {
quad[i].fWinding = cross < 0 ? 1 : -1;
if (cross > 0.0) {
quad[i].fVert2 = pts[0];
quad[i].fVert3 = pts[2];
}
else {
quad[i].fVert2 = pts[2];
quad[i].fVert3 = pts[0];
}
}
GrPathUtils::QuadUVMatrix DevToUV(pts);
DevToUV.apply<kQuadNumVertices, sizeof(PLSVertex), sizeof(SkPoint)>(quad);
for (int i = 2; i < kQuadNumVertices; i++) {
vertices.push_back(quad[0]);
vertices.push_back(quad[i - 1]);
vertices.push_back(quad[i]);
}
}
示例2: outset
/* Used by bloat_tri; outsets a single point. */
static bool outset(SkPoint* p1, SkPoint line1, SkPoint line2) {
// rotate the two line vectors 90 degrees to form the normals, and compute
// the dot product of the normals
SkScalar dotProd = line1.fY * line2.fY + line1.fX * line2.fX;
SkScalar lengthSq = 1.0f / ((1.0f - dotProd) / 2.0f);
if (lengthSq > kBloatLimit) {
return false;
}
SkPoint bisector = line1 + line2;
bisector.setLength(SkScalarSqrt(lengthSq) * kBloatSize);
*p1 += bisector;
return true;
}