本文整理汇总了C++中SkPath::lineTo方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPath::lineTo方法的具体用法?C++ SkPath::lineTo怎么用?C++ SkPath::lineTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPath
的用法示例。
在下文中一共展示了SkPath::lineTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dash
// http://crbug.com/165432
// Limit extreme dash path effects to avoid exhausting the system memory.
static void test_crbug_165432(skiatest::Reporter* reporter) {
SkPath path;
path.moveTo(0, 0);
path.lineTo(10000000, 0);
SkScalar intervals[] = { 0.5f, 0.5f };
SkDashPathEffect dash(intervals, 2, 0);
SkPaint paint;
paint.setStyle(SkPaint::kStroke_Style);
paint.setPathEffect(&dash);
SkPath filteredPath;
SkStrokeRec rec(paint);
REPORTER_ASSERT(reporter, !dash.filterPath(&filteredPath, path, &rec, NULL));
REPORTER_ASSERT(reporter, filteredPath.isEmpty());
}
示例2: create_concave_path
SkPath create_concave_path(const SkPoint& offset) {
SkPath concavePath;
concavePath.moveTo(kMin, kMin);
concavePath.lineTo(kMid, 105.0f);
concavePath.lineTo(kMax, kMin);
concavePath.lineTo(295.0f, kMid);
concavePath.lineTo(kMax, kMax);
concavePath.lineTo(kMid, 295.0f);
concavePath.lineTo(kMin, kMax);
concavePath.lineTo(105.0f, kMid);
concavePath.close();
concavePath.offset(offset.fX, offset.fY);
return concavePath;
}
示例3: switch
static void test4(SkCanvas* canvas) {
SkPaint paint;
paint.setAntiAlias(true);
SkPoint pts[] = {
{10, 160}, {610, 160},
{610, 160}, {10, 160},
{610, 160}, {610, 160},
{610, 199}, {610, 199},
{10, 198}, {610, 198},
{610, 199}, {10, 199},
{10, 160}, {10, 160},
{10, 199}, {10, 199}
};
char verbs[] = {
0, 1, 1, 1, 4,
0, 1, 1, 1, 4,
0, 1, 1, 1, 4,
0, 1, 1, 1, 4
};
SkPath path;
SkPoint* ptPtr = pts;
for (size_t i = 0; i < sizeof(verbs); ++i) {
switch ((SkPath::Verb) verbs[i]) {
case SkPath::kMove_Verb:
path.moveTo(ptPtr->fX, ptPtr->fY);
++ptPtr;
break;
case SkPath::kLine_Verb:
path.lineTo(ptPtr->fX, ptPtr->fY);
++ptPtr;
break;
case SkPath::kClose_Verb:
path.close();
break;
default:
SkASSERT(false);
break;
}
}
SkRect clip = {0, 130, 772, 531};
canvas->clipRect(clip);
canvas->drawPath(path, paint);
}
示例4: test_infinite_dash
// Extremely large path_length/dash_length ratios may cause infinite looping
// in SkDashPathEffect::filterPath() due to single precision rounding.
// The test is quite expensive, but it should get much faster after the fix
// for http://crbug.com/165432 goes in.
static void test_infinite_dash(skiatest::Reporter* reporter) {
SkPath path;
path.moveTo(0, 0);
path.lineTo(5000000, 0);
SkScalar intervals[] = { 0.2f, 0.2f };
SkDashPathEffect dash(intervals, 2, 0);
SkPath filteredPath;
SkPaint paint;
paint.setStyle(SkPaint::kStroke_Style);
paint.setPathEffect(&dash);
paint.getFillPath(path, &filteredPath);
// If we reach this, we passed.
REPORTER_ASSERT(reporter, true);
}
示例5: onDraw
void onDraw(SkCanvas* canvas) override {
SkPaint p;
p.setColor(SK_ColorRED);
p.setAntiAlias(true);
canvas->clear(0xFFFFFFFF);
canvas->save();
canvas->rotate(1);
const SkScalar R = 115.2f, C = 128.0f;
SkPath path;
path.moveTo(C + R, C);
for (int i = 1; i < 8; ++i) {
SkScalar a = 2.6927937f * i;
SkScalar cosine;
SkScalar sine = SkScalarSinCos(a, &cosine);
path.lineTo(C + R * cosine, C + R * sine);
}
canvas->drawPath(path, p);
canvas->restore();
canvas->save();
canvas->translate(200, 0);
canvas->rotate(1);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(5);
canvas->drawPath(path, p);
canvas->restore();
// The following two paths test if we correctly cumulates the alpha on the middle pixel
// column where the left rect and the right rect abut.
p.setStyle(SkPaint::kFill_Style);
canvas->translate(0, 300);
path.reset();
path.addRect({20, 20, 100.4999f, 100});
path.addRect({100.5001f, 20, 200, 100});
canvas->drawPath(path, p);
canvas->translate(300, 0);
path.reset();
path.addRect({20, 20, 100.1f, 100});
path.addRect({100.9f, 20, 200, 100});
canvas->drawPath(path, p);
}
示例6: triangle
void WebTestThemeControlWin::triangle(int x0, int y0, int x1, int y1, int x2, int y2, SkColor color)
{
SkPath path;
SkPaint paint;
paint.setColor(color);
paint.setStyle(SkPaint::kFill_Style);
path.incReserve(4);
path.moveTo(SkIntToScalar(x0), SkIntToScalar(y0));
path.lineTo(SkIntToScalar(x1), SkIntToScalar(y1));
path.lineTo(SkIntToScalar(x2), SkIntToScalar(y2));
path.close();
m_canvas->drawPath(path, paint);
paint.setColor(m_edgeColor);
paint.setStyle(SkPaint::kStroke_Style);
m_canvas->drawPath(path, paint);
}
示例7: create_star
// Creates a star type shape using a SkPath
static SkPath create_star() {
static const int kNumPoints = 5;
SkPath concavePath;
SkPoint points[kNumPoints] = {{0, SkIntToScalar(-50)} };
SkMatrix rot;
rot.setRotate(SkIntToScalar(360) / kNumPoints);
for (int i = 1; i < kNumPoints; ++i) {
rot.mapPoints(points + i, points + i - 1, 1);
}
concavePath.moveTo(points[0]);
for (int i = 0; i < kNumPoints; ++i) {
concavePath.lineTo(points[(2 * i) % kNumPoints]);
}
concavePath.setFillType(SkPath::kEvenOdd_FillType);
SkASSERT(!concavePath.isConvex());
concavePath.close();
return concavePath;
}
示例8: createStar
static void createStar(SkPath& path, SkScalar innerRadius, SkScalar outerRadius,
SkScalar startAngle, int points, SkPoint center) {
SkScalar angle = startAngle;
for (int index = 0; index < points * 2; ++index) {
SkScalar radius = index & 1 ? outerRadius : innerRadius;
SkScalar x = radius * cos(angle);
SkScalar y = radius * sin(angle);
x += center.fX;
y += center.fY;
if (index == 0) {
path.moveTo(x, y);
} else {
path.lineTo(x, y);
}
angle += 3.1415f / points;
}
path.close();
}
示例9:
// An edge collapse event causes an edge to become collinear, requiring
// its event to be removed.
static SkPath create_path_26() {
SkPath path;
path.moveTo( 43.44110107421875, 148.15106201171875);
path.lineTo( 44.64471435546875, 148.16748046875);
path.lineTo( 46.35009765625, 147.403076171875);
path.lineTo( 46.45404052734375, 148.34906005859375);
path.lineTo( 45.0400390625, 148.54205322265625);
path.lineTo( 44.624053955078125, 148.9810791015625);
path.lineTo( 44.59405517578125, 149.16107177734375);
path.lineTo( 44.877044677734375, 149.62005615234375);
path.lineTo(144.373016357421875, 68.8070068359375);
return path;
}
示例10: testTightBoundsLines
static void testTightBoundsLines(PathOpsThreadState* data) {
SkRandom ran;
for (int index = 0; index < 1000; ++index) {
SkPath path;
int contourCount = ran.nextRangeU(1, 10);
for (int cIndex = 0; cIndex < contourCount; ++cIndex) {
int lineCount = ran.nextRangeU(1, 10);
path.moveTo(ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000));
for (int lIndex = 0; lIndex < lineCount; ++lIndex) {
path.lineTo(ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000));
}
if (ran.nextBool()) {
path.close();
}
}
SkRect classicBounds = path.getBounds();
SkRect tightBounds;
REPORTER_ASSERT(data->fReporter, TightBounds(path, &tightBounds));
REPORTER_ASSERT(data->fReporter, classicBounds == tightBounds);
}
}
示例11: Make
static sk_sp<SkPathEffect> make_pe(int flags, SkScalar phase) {
if (flags == 1) {
return SkCornerPathEffect::Make(SkIntToScalar(CORNER_RADIUS));
}
SkPath path;
path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1]));
for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2)
path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1]));
path.close();
path.offset(SkIntToScalar(-6), 0);
auto outer = SkPath1DPathEffect::Make(path, 12, phase, SkPath1DPathEffect::kRotate_Style);
if (flags == 2)
return outer;
auto inner = SkCornerPathEffect::Make(SkIntToScalar(CORNER_RADIUS));
return SkComposePathEffect::Make(outer, inner);
}
示例12: addCubic
SkPath ValueTraits<ShapeValue>::As<SkPath>(const ShapeValue& shape) {
SkPath path;
if (!shape.fVertices.empty()) {
// conservatively assume all cubics
path.incReserve(1 + SkToU32(shape.fVertices.size() * 3));
path.moveTo(shape.fVertices.front().fVertex);
}
const auto& addCubic = [&](size_t from, size_t to) {
const auto c0 = shape.fVertices[from].fVertex + shape.fVertices[from].fOutPoint,
c1 = shape.fVertices[to].fVertex + shape.fVertices[to].fInPoint;
if (c0 == shape.fVertices[from].fVertex &&
c1 == shape.fVertices[to].fVertex) {
// If the control points are coincident, we can power-reduce to a straight line.
// TODO: we could also do that when the controls are on the same line as the
// vertices, but it's unclear how common that case is.
path.lineTo(shape.fVertices[to].fVertex);
} else {
path.cubicTo(c0, c1, shape.fVertices[to].fVertex);
}
};
for (size_t i = 1; i < shape.fVertices.size(); ++i) {
addCubic(i - 1, i);
}
if (!shape.fVertices.empty() && shape.fClosed) {
addCubic(shape.fVertices.size() - 1, 0);
path.close();
}
path.setIsVolatile(shape.fVolatile);
path.shrinkToFit();
return path;
}
示例13: emit_clip
// TODO: expand the testing to include the different ops & AA types!
static void emit_clip(SkCanvas* canvas, ClipType clip) {
switch (clip) {
case kNone_ClipType:
break;
case kRect_ClipType: {
SkRect r = SkRect::MakeLTRB(10, 10, 90, 90);
canvas->clipRect(r, SkRegion::kIntersect_Op, true);
break;
}
case kRRect_ClipType: {
SkRect r = SkRect::MakeLTRB(10, 10, 90, 90);
SkRRect rr;
rr.setRectXY(r, 10, 10);
canvas->clipRRect(rr, SkRegion::kIntersect_Op, true);
break;
}
case kPath_ClipType: {
SkPath p;
p.moveTo(5.0f, 5.0f);
p.lineTo(50.0f, 50.0f);
p.lineTo(100.0f, 5.0f);
p.close();
canvas->clipPath(p, SkRegion::kIntersect_Op, true);
break;
}
case kRegion_ClipType: {
SkIRect rects[2] = {
{ 1, 1, 55, 55 },
{ 45, 45, 99, 99 },
};
SkRegion r;
r.setRects(rects, 2);
canvas->clipRegion(r, SkRegion::kIntersect_Op);
break;
}
default:
SkASSERT(0);
}
}
示例14: skiaRandomizePaintColor
int
sk_test_multi_line(caskbench_context_t *ctx)
{
int w = ctx->canvas_width;
int h = ctx->canvas_height;
double x = (double)rnd()/RAND_MAX * w;
double y = (double)rnd()/RAND_MAX * h;
SkPath path;
path.moveTo(x, y);
for (int i=0; i<ctx->size; i++) {
x = (double)rnd()/RAND_MAX * w;
y = (double)rnd()/RAND_MAX * h;
path.lineTo(x, y);
}
skiaRandomizePaintColor(ctx);
ctx->skia_canvas->drawPath(path, *(ctx->skia_paint));
return 1;
}
示例15: make_path
static SkPath make_path() {
SkPath path;
uint8_t numOps;
fuzz->nextRange(&numOps, 0, 30);
for (uint8_t i = 0; i < numOps; ++i) {
uint8_t op;
fuzz->nextRange(&op, 0, 5);
SkScalar a, b, c, d, e, f;
switch (op) {
case 0:
fuzz->next(&a, &b);
path.moveTo(a, b);
break;
case 1:
fuzz->next(&a, &b);
path.lineTo(a, b);
break;
case 2:
fuzz->next(&a, &b, &c, &d);
path.quadTo(a, b, c, d);
break;
case 3:
fuzz->next(&a, &b, &c, &d, &e);
path.conicTo(a, b, c, d, e);
break;
case 4:
fuzz->next(&a, &b, &c, &d, &e, &f);
path.cubicTo(a, b, c, d, e, f);
break;
case 5:
default:
fuzz->next(&a, &b, &c, &d, &e);
path.arcTo(a, b, c, d, e);
break;
}
}
path.close();
return path;
}