本文整理汇总了C++中SkPath::cubicTo方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPath::cubicTo方法的具体用法?C++ SkPath::cubicTo怎么用?C++ SkPath::cubicTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPath
的用法示例。
在下文中一共展示了SkPath::cubicTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onDrawContent
void onDrawContent(SkCanvas* canvas) override {
test_huge_stroke(canvas); return;
canvas->translate(SkIntToScalar(10), SkIntToScalar(10));
SkPaint paint;
paint.setAntiAlias(true);
if (true) {
canvas->drawColor(SK_ColorBLACK);
paint.setTextSize(24);
paint.setColor(SK_ColorWHITE);
canvas->translate(10, 30);
static const SkBlurStyle gStyle[] = {
kNormal_SkBlurStyle,
kInner_SkBlurStyle,
kOuter_SkBlurStyle,
kSolid_SkBlurStyle,
};
for (int x = 0; x < 5; x++) {
SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4));
for (int y = 0; y < 10; y++) {
if (x) {
paint.setMaskFilter(SkBlurMaskFilter::Make(gStyle[x - 1], sigma));
}
canvas->drawString("Title Bar", x*SkIntToScalar(100), y*SkIntToScalar(30), paint);
sigma *= 0.75f;
}
}
return;
}
paint.setColor(SK_ColorBLUE);
#if 1
SkPath p;
float r = rand.nextUScalar1() + 0.5f;
SkScalar x = 0, y = 0;
p.moveTo(x, y);
#if 0
p.cubicTo(x-75*r, y+75*r, x-40*r, y+125*r, x, y+85*r);
p.cubicTo(x+40*r, y+125*r, x+75*r, y+75*r, x, y);
#else
p.cubicTo(x+75*r, y+75*r, x+40*r, y+125*r, x, y+85*r);
p.cubicTo(x-40*r, y+125*r, x-75*r, y+75*r, x, y);
#endif
p.close();
fPath = p;
fPath.offset(100, 0);
#endif
fPath.setFillType(SkPath::kWinding_FillType);
drawSet(canvas, &paint);
canvas->translate(0, fPath.getBounds().height() * 5 / 4);
fPath.setFillType(SkPath::kEvenOdd_FillType);
drawSet(canvas, &paint);
}
示例2: draw_path
static void draw_path(SkScalar size, SkCanvas* canvas, SkPaint paint) {
SkScalar c = 0.551915024494f * size;
SkPath path;
path.moveTo(0.0f, size);
path.cubicTo(c, size, size, c, size, 0.0f);
path.cubicTo(size, -c, c, -size, 0.0f, -size);
path.cubicTo(-c, -size, -size, -c, -size, 0.0f);
path.cubicTo(-size, c, -c, size, 0.0f, size);
canvas->drawPath(path, paint);
}
示例3: hiragino_maru_gothic_pro_dash
/* Generated on a Mac with:
* paint.setTypeface(SkTypeface::CreateByName("Hiragino Maru Gothic Pro"));
* const unsigned char hyphen[] = { 0xE3, 0x83, 0xBC };
* paint.getTextPath(hyphen, SK_ARRAY_COUNT(hyphen), 400, 80, &textPath);
*/
static SkPath hiragino_maru_gothic_pro_dash() {
SkPath path;
path.moveTo(488, 55.1f);
path.cubicTo(490.5f, 55.1f, 491.9f, 53.5f, 491.9f, 50.8f);
path.cubicTo(491.9f, 48.2f, 490.5f, 46.3f, 487.9f, 46.3f);
path.lineTo(412, 46.3f);
path.cubicTo(409.4f, 46.3f, 408, 48.2f, 408, 50.8f);
path.cubicTo(408, 53.5f, 409.4f, 55.1f, 411.9f, 55.1f);
path.lineTo(488, 55.1f);
path.close();
return path;
}
示例4: PathOpsSimplifyFailTest
static void PathOpsSimplifyFailTest(skiatest::Reporter* reporter) {
for (int index = 0; index < (int) (13 * nonFinitePtsCount * finitePtsCount); ++index) {
SkPath path;
int i = (int) (index % nonFinitePtsCount);
int f = (int) (index % finitePtsCount);
int g = (int) ((f + 1) % finitePtsCount);
switch (index % 13) {
case 0: path.lineTo(nonFinitePts[i]); break;
case 1: path.quadTo(nonFinitePts[i], nonFinitePts[i]); break;
case 2: path.quadTo(nonFinitePts[i], finitePts[f]); break;
case 3: path.quadTo(finitePts[f], nonFinitePts[i]); break;
case 4: path.cubicTo(nonFinitePts[i], finitePts[f], finitePts[f]); break;
case 5: path.cubicTo(finitePts[f], nonFinitePts[i], finitePts[f]); break;
case 6: path.cubicTo(finitePts[f], finitePts[f], nonFinitePts[i]); break;
case 7: path.cubicTo(nonFinitePts[i], nonFinitePts[i], finitePts[f]); break;
case 8: path.cubicTo(nonFinitePts[i], finitePts[f], nonFinitePts[i]); break;
case 9: path.cubicTo(finitePts[f], nonFinitePts[i], nonFinitePts[i]); break;
case 10: path.cubicTo(nonFinitePts[i], nonFinitePts[i], nonFinitePts[i]); break;
case 11: path.cubicTo(nonFinitePts[i], finitePts[f], finitePts[g]); break;
case 12: path.moveTo(nonFinitePts[i]); break;
}
SkPath result;
result.setFillType(SkPath::kWinding_FillType);
bool success = Simplify(path, &result);
REPORTER_ASSERT(reporter, !success);
REPORTER_ASSERT(reporter, result.isEmpty());
REPORTER_ASSERT(reporter, result.getFillType() == SkPath::kWinding_FillType);
reporter->bumpTestCount();
}
if (sizeof(reporter) == 4) {
return;
}
for (int index = 0; index < (int) (11 * finitePtsCount); ++index) {
SkPath path;
int f = (int) (index % finitePtsCount);
int g = (int) ((f + 1) % finitePtsCount);
switch (index % 11) {
case 0: path.lineTo(finitePts[f]); break;
case 1: path.quadTo(finitePts[f], finitePts[f]); break;
case 2: path.quadTo(finitePts[f], finitePts[g]); break;
case 3: path.quadTo(finitePts[g], finitePts[f]); break;
case 4: path.cubicTo(finitePts[f], finitePts[f], finitePts[f]); break;
case 5: path.cubicTo(finitePts[f], finitePts[f], finitePts[g]); break;
case 6: path.cubicTo(finitePts[f], finitePts[g], finitePts[f]); break;
case 7: path.cubicTo(finitePts[f], finitePts[g], finitePts[g]); break;
case 8: path.cubicTo(finitePts[g], finitePts[f], finitePts[f]); break;
case 9: path.cubicTo(finitePts[g], finitePts[f], finitePts[g]); break;
case 10: path.moveTo(finitePts[f]); break;
}
SkPath result;
result.setFillType(SkPath::kWinding_FillType);
bool success = Simplify(path, &result);
REPORTER_ASSERT(reporter, success);
REPORTER_ASSERT(reporter, result.getFillType() != SkPath::kWinding_FillType);
reporter->bumpTestCount();
}
}
示例5: make_path
static SkPath make_path() {
SkPath path;
int numOps = R(30);
for (int i = 0; i < numOps; ++i) {
switch (R(6)) {
case 0:
path.moveTo(make_scalar(), make_scalar());
break;
case 1:
path.lineTo(make_scalar(), make_scalar());
break;
case 2:
path.quadTo(make_scalar(), make_scalar(), make_scalar(), make_scalar());
break;
case 3:
path.conicTo(make_scalar(), make_scalar(), make_scalar(), make_scalar(), make_scalar());
break;
case 4:
path.cubicTo(make_scalar(), make_scalar(), make_scalar(),
make_scalar(), make_scalar(), make_scalar());
break;
case 5:
default:
path.arcTo(make_scalar(), make_scalar(), make_scalar(), make_scalar(), make_scalar());
break;
}
}
path.close();
return path;
}
示例6: AddMoveDegenCubicClose
static SkPoint AddMoveDegenCubicClose(SkPath& path, SkPoint& startPt) {
SkPoint moveToPt = startPt + SkPoint::Make(0, 10*SK_Scalar1);
path.moveTo(moveToPt);
path.cubicTo(moveToPt, moveToPt, moveToPt);
path.close();
return moveToPt;
}
示例7: onDrawContent
virtual void onDrawContent(SkCanvas* canvas) {
SkPaint paint;
paint.setAntiAlias(true);
paint.setColor(0xFF8888FF);
SkRect r = { 0, 0, SK_Scalar1, SK_Scalar1 };
canvas->concat(fMatrix);
canvas->drawRect(r, paint);
paint.setColor(SK_ColorBLACK);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(0);
paint.setStrokeCap(SkPaint::kRound_Cap);
SkPath path;
path.moveTo(fPts[0]);
path.cubicTo(fPts[1], fPts[2], fPts[3]);
canvas->drawPath(path, paint);
paint.setColor(SK_ColorRED);
paint.setStrokeWidth(0);
canvas->drawLine(0, 0, SK_Scalar1, SK_Scalar1, paint);
paint.setColor(SK_ColorBLUE);
paint.setStrokeWidth(SK_Scalar1 / 60);
for (int i = 0; i < 50; i++) {
SkScalar x = i * SK_Scalar1 / 49;
canvas->drawPoint(x, SkEvalCubicInterval(&fPts[1], x), paint);
}
paint.setStrokeWidth(SK_Scalar1 / 20);
paint.setColor(SK_ColorGREEN);
canvas->drawPoints(SkCanvas::kPoints_PointMode, 2, &fPts[1], paint);
}
示例8: AddCubic
static SkPoint AddCubic(SkPath& path, SkPoint& startPt) {
SkPoint t1Pt = startPt + SkPoint::Make(15*SK_Scalar1, 5*SK_Scalar1);
SkPoint t2Pt = startPt + SkPoint::Make(25*SK_Scalar1, 5*SK_Scalar1);
SkPoint endPt = startPt + SkPoint::Make(40*SK_Scalar1, 0);
path.cubicTo(t1Pt, t2Pt, endPt);
return endPt;
}
示例9: draw
void draw(SkCanvas* canvas) {
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
SkPath path;
path.moveTo(0, -10);
for (int i = 0; i < 128; i += 16) {
SkScalar c = i * 0.5f;
path.cubicTo( 10 + c, -10 - i, 10 + i, -10 - c, 10 + i, 0);
path.cubicTo( 14 + i, 14 + c, 14 + c, 14 + i, 0, 14 + i);
path.cubicTo(-18 - c, 18 + i, -18 - i, 18 + c, -18 - i, 0);
path.cubicTo(-22 - i, -22 - c, -22 - c, -22 - i, 0, -22 - i);
}
path.offset(128, 128);
canvas->drawPath(path, paint);
}
示例10: testCubics
static void testCubics() {
SkPath path;
path.moveTo(2,0);
path.cubicTo(2,3, 1,1, 0,0);
path.close();
test(path);
}
示例11: getSubsetPath
SkPath SubsetVerbs::getSubsetPath() const {
SkPath result;
result.setFillType(fPath.getFillType());
if (!fSelected.count()) {
return result;
}
SkPath::RawIter iter(fPath);
uint8_t verb;
SkPoint pts[4];
int verbIndex = 0;
bool addMoveTo = true;
bool addLineTo = false;
while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
bool enabled = SkPath::kLine_Verb <= verb && verb <= SkPath::kCubic_Verb
? fSelected[verbIndex++] : false;
if (enabled) {
if (addMoveTo) {
result.moveTo(pts[0]);
addMoveTo = false;
} else if (addLineTo) {
result.lineTo(pts[0]);
addLineTo = false;
}
}
switch (verb) {
case SkPath::kMove_Verb:
break;
case SkPath::kLine_Verb:
if (enabled) {
result.lineTo(pts[1]);
}
break;
case SkPath::kQuad_Verb:
if (enabled) {
result.quadTo(pts[1], pts[2]);
}
break;
case SkPath::kConic_Verb:
if (enabled) {
result.conicTo(pts[1], pts[2], iter.conicWeight());
}
break;
case SkPath::kCubic_Verb:
if (enabled) {
result.cubicTo(pts[1], pts[2], pts[3]);
}
break;
case SkPath::kClose_Verb:
result.close();
addMoveTo = true;
addLineTo = false;
continue;
default:
SkDEBUGFAIL("bad verb");
return result;
}
addLineTo = !enabled;
}
return result;
}
示例12: onDraw
void onDraw(SkCanvas* canvas) override {
SkPath path;
SkRandom rand;
int scale = 300;
for (int i = 0; i < 4; ++i) {
// get the random values deterministically
SkScalar randoms[12];
for (int index = 0; index < (int) SK_ARRAY_COUNT(randoms); ++index) {
randoms[index] = rand.nextUScalar1();
}
path.lineTo(randoms[0] * scale, randoms[1] * scale);
path.quadTo(randoms[2] * scale, randoms[3] * scale,
randoms[4] * scale, randoms[5] * scale);
path.cubicTo(randoms[6] * scale, randoms[7] * scale,
randoms[8] * scale, randoms[9] * scale,
randoms[10] * scale, randoms[11] * scale);
}
path.setFillType(SkPath::kEvenOdd_FillType);
path.offset(SkIntToScalar(20), SkIntToScalar(20));
test_hittest(canvas, path);
canvas->translate(SkIntToScalar(scale), 0);
path.setFillType(SkPath::kWinding_FillType);
test_hittest(canvas, path);
}
示例13: test_flattening
static void test_flattening(skiatest::Reporter* reporter) {
SkPath p;
static const SkPoint pts[] = {
{ 0, 0 },
{ SkIntToScalar(10), SkIntToScalar(10) },
{ SkIntToScalar(20), SkIntToScalar(10) }, { SkIntToScalar(20), 0 },
{ 0, 0 }, { 0, SkIntToScalar(10) }, { SkIntToScalar(1), SkIntToScalar(10) }
};
p.moveTo(pts[0]);
p.lineTo(pts[1]);
p.quadTo(pts[2], pts[3]);
p.cubicTo(pts[4], pts[5], pts[6]);
SkWriter32 writer(100);
p.flatten(writer);
size_t size = writer.size();
SkAutoMalloc storage(size);
writer.flatten(storage.get());
SkReader32 reader(storage.get(), size);
SkPath p1;
REPORTER_ASSERT(reporter, p1 != p);
p1.unflatten(reader);
REPORTER_ASSERT(reporter, p1 == p);
}
示例14: cubic_proc
static int cubic_proc(const FT_Vector* pt0, const FT_Vector* pt1,
const FT_Vector* pt2, void* ctx) {
SkPath* path = (SkPath*)ctx;
path->cubicTo(SkFDot6ToScalar(pt0->x), -SkFDot6ToScalar(pt0->y),
SkFDot6ToScalar(pt1->x), -SkFDot6ToScalar(pt1->y),
SkFDot6ToScalar(pt2->x), -SkFDot6ToScalar(pt2->y));
return 0;
}
示例15: onOnceBeforeDraw
void onOnceBeforeDraw() override {
{
SkPath* bigQuad = &fPaths.push_back();
bigQuad->moveTo(0, 0);
bigQuad->quadTo(kWidth/2, kHeight, kWidth, 0);
}
{
SkPath* degenBigQuad = &fPaths.push_back();
SkScalar yPos = kHeight / 2 + 10;
degenBigQuad->moveTo(0, yPos);
degenBigQuad->quadTo(0, yPos, kWidth, yPos);
}
{
SkPath* bigCubic = &fPaths.push_back();
bigCubic->moveTo(0, 0);
bigCubic->cubicTo(0, kHeight,
kWidth, kHeight,
kWidth, 0);
}
{
SkPath* degenBigCubic = &fPaths.push_back();
SkScalar yPos = kHeight / 2;
degenBigCubic->moveTo(0, yPos);
degenBigCubic->cubicTo(0, yPos,
0, yPos,
kWidth, yPos);
}
{
SkPath* bigConic = &fPaths.push_back();
bigConic->moveTo(0, 0);
bigConic->conicTo(kWidth/2, kHeight, kWidth, 0, .5);
}
{
SkPath* degenBigConic = &fPaths.push_back();
SkScalar yPos = kHeight / 2 - 10;
degenBigConic->moveTo(0, yPos);
degenBigConic->conicTo(0, yPos, kWidth, yPos, .5);
}
}