当前位置: 首页>>代码示例>>C++>>正文


C++ SkPath::close方法代码示例

本文整理汇总了C++中SkPath::close方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPath::close方法的具体用法?C++ SkPath::close怎么用?C++ SkPath::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SkPath的用法示例。


在下文中一共展示了SkPath::close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onDraw

    void onDraw(SkCanvas* canvas) override {
        SkScalar angle = kAngle*SK_ScalarPI + SkScalarHalf(SK_ScalarPI);
        SkScalar size = SkIntToScalar(SkMin32(kWidth, kHeight));
        SkPoint center = SkPoint::Make(SkScalarHalf(kWidth), SkScalarHalf(kHeight));
        SkScalar length = 5;
        SkScalar step = angle;

        SkPath path;
        path.moveTo(center);

        while (length < (SkScalarHalf(size) - 10.f))
        {
            SkPoint rp = SkPoint::Make(length*SkScalarCos(step) + center.fX,
                                       length*SkScalarSin(step) + center.fY);
            path.lineTo(rp);
            length += angle / SkScalarHalf(SK_ScalarPI);
            step += angle;
        }
        path.close();

        SkPaint paint;
        paint.setAntiAlias(true);
        paint.setStyle(SkPaint::kStroke_Style);
        paint.setColor(sk_tool_utils::color_to_565(0xFF007700));

        canvas->drawPath(path, paint);
    }
开发者ID:AHPlankton,项目名称:skia,代码行数:27,代码来源:stringart.cpp

示例2: getArc

PathTexture* PathCache::getArc(float width, float height,
        float startAngle, float sweepAngle, bool useCenter, const SkPaint* paint) {
    PathDescription entry(kShapeArc, paint);
    entry.shape.arc.mWidth = width;
    entry.shape.arc.mHeight = height;
    entry.shape.arc.mStartAngle = startAngle;
    entry.shape.arc.mSweepAngle = sweepAngle;
    entry.shape.arc.mUseCenter = useCenter;

    PathTexture* texture = get(entry);

    if (!texture) {
        SkPath path;
        SkRect r;
        r.set(0.0f, 0.0f, width, height);
        if (useCenter) {
            path.moveTo(r.centerX(), r.centerY());
        }
        path.arcTo(r, startAngle, sweepAngle, !useCenter);
        if (useCenter) {
            path.close();
        }

        texture = addTexture(entry, &path, paint);
    }

    return texture;
}
开发者ID:AdrianoMartins,项目名称:platform_frameworks_base,代码行数:28,代码来源:PathCache.cpp

示例3: onDrawContent

    void onDrawContent(SkCanvas* canvas) override {
        SkScalar angle = fAngle*SK_ScalarPI + SkScalarHalf(SK_ScalarPI);

        SkPoint center = SkPoint::Make(SkScalarHalf(this->width()), SkScalarHalf(this->height()));
        SkScalar length = 5;
        SkScalar step = angle;

        SkPath path;
        path.moveTo(center);

        while (length < (SkScalarHalf(SkMinScalar(this->width(), this->height())) - 10.f))
        {
            SkPoint rp = SkPoint::Make(length*SkScalarCos(step) + center.fX,
                                       length*SkScalarSin(step) + center.fY);
            path.lineTo(rp);
            length += SkScalarDiv(angle, SkScalarHalf(SK_ScalarPI));
            step += angle;
        }
        path.close();

        SkPaint paint;
        paint.setAntiAlias(true);
        paint.setStyle(SkPaint::kStroke_Style);
        paint.setColor(0xFF007700);

        canvas->drawPath(path, paint);
    }
开发者ID:Ashu17,项目名称:blackberry,代码行数:27,代码来源:SampleStringArt.cpp

示例4: drawTriangle

void FatBits::drawTriangle(SkCanvas* canvas, SkPoint pts[3]) {
    SkPaint paint;

    fInverse.mapPoints(pts, 3);

    if (fGrid) {
        apply_grid(pts, 3);
    }

    SkPath path;
    path.moveTo(pts[0]);
    path.lineTo(pts[1]);
    path.lineTo(pts[2]);
    path.close();

    erase(fMinSurface.get());
    this->setupPaint(&paint);
    paint.setColor(FAT_PIXEL_COLOR);
    fMinSurface->getCanvas()->drawPath(path, paint);
    this->copyMinToMax();

    SkCanvas* max = fMaxSurface->getCanvas();

    fMatrix.mapPoints(pts, 3);
    this->drawTriangleSkeleton(max, pts);

    fMaxSurface->draw(canvas, 0, 0, nullptr);
}
开发者ID:google,项目名称:skia,代码行数:28,代码来源:SampleFatBits.cpp

示例5: FillPolygon

void ACanvasSkia::FillPolygon(APoint* pts,int count)
{
	if( count == 1 )
	{
		_clip();
		_SetPaint_Fill();
		m_pCanvas->drawPoint(SkIntToScalar(pts[0].x),SkIntToScalar(pts[0].y),m_Paint);
		Reset();
	}
	else if( count < 1 )
	{
		//do nothing
	}
	else
	{
		_SetPaint_Fill();
		SkPath path;
		path.moveTo(SkIntToScalar(pts[0].x),SkIntToScalar(pts[0].y));
		for(int i=1;i<count;i++)
		{
			//path.moveTo(SkIntToScalar(pts[i].x),SkIntToScalar(pts[i].y));
			path.lineTo(SkIntToScalar(pts[i].x),SkIntToScalar(pts[i].y));
		}
		path.close();
		m_pCanvas->drawPath(path,m_Paint);
	}
}
开发者ID:emuikernel,项目名称:BaijieCppUILib,代码行数:27,代码来源:ACanvasSkia.cpp

示例6: 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;
}
开发者ID:android,项目名称:platform_external_skia,代码行数:31,代码来源:SampleFilterFuzz.cpp

示例7: test_emptydrawing

/*  Two invariants are tested: How does an empty/degenerate path draw?
 *  - if the path is drawn inverse, it should draw everywhere
 *  - if the path is drawn non-inverse, it should draw nowhere
 *
 *  Things to iterate on:
 *  - path (empty, degenerate line/quad/cubic w/ and w/o close
 *  - paint style
 *  - path filltype
 *  - path stroke variants (e.g. caps, joins, width)
 */
static void test_emptydrawing(skiatest::Reporter* reporter) {
    static void (*gMakeProc[])(SkPath*) = {
        make_empty, make_M, make_MM, make_MZM, make_L, make_Q, make_C
    };
    static SkPath::FillType gFills[] = {
        SkPath::kWinding_FillType,
        SkPath::kEvenOdd_FillType,
        SkPath::kInverseWinding_FillType,
        SkPath::kInverseEvenOdd_FillType
    };
    for (int doClose = 0; doClose < 2; ++doClose) {
        for  (size_t i = 0; i < SK_ARRAY_COUNT(gMakeProc); ++i) {
            SkPath path;
            gMakeProc[i](&path);
            if (doClose) {
                path.close();
            }
            for (size_t fill = 0; fill < SK_ARRAY_COUNT(gFills); ++fill) {
                path.setFillType(gFills[fill]);
                bool shouldDraw = path.isInverseFillType();
                iter_paint(reporter, path, shouldDraw);
            }
        }
    }
}
开发者ID:Adenilson,项目名称:skia,代码行数:35,代码来源:EmptyPathTest.cpp

示例8: AddMoveLineClose

 static SkPoint AddMoveLineClose(SkPath& path, SkPoint& startPt) {
     SkPoint moveToPt = startPt + SkPoint::Make(0, 10*SK_Scalar1);
     SkPoint endPt = moveToPt + SkPoint::Make(40*SK_Scalar1, 0);
     path.moveTo(moveToPt);
     path.lineTo(endPt);
     path.close();
     return endPt;
 }
开发者ID:jetlive,项目名称:skiaming,代码行数:8,代码来源:degeneratesegments.cpp

示例9: make_convex_path

static SkPath make_convex_path() {
    SkPath path;
    path.lineTo(100, 0);
    path.lineTo(50, 100);
    path.close();

    return path;
}
开发者ID:03050903,项目名称:skia,代码行数:8,代码来源:PictureTest.cpp

示例10: test

static void testLine1() {
    SkPath path;
    path.moveTo(2,0);
    path.lineTo(1,1);
    path.lineTo(0,0);
    path.close();
    test(path);
}
开发者ID:Adenilson,项目名称:skia,代码行数:8,代码来源:SimplifyFindTop_Test.cpp

示例11: make_tri_path

// Make an equilateral triangle path with its top corner at (originX, originY)
static SkPath make_tri_path(SkScalar originX, SkScalar originY) {
    SkPath tri;
    tri.moveTo(originX, originY);
    tri.rLineTo(SkScalarHalf(kTriSide), 1.5f * kTriSide / kRoot3);
    tri.rLineTo(-kTriSide, 0);
    tri.close();
    return tri;
}
开发者ID:aseprite,项目名称:skia,代码行数:9,代码来源:multipicturedraw.cpp

示例12: getSubsetPath

SkPath SubsetContours::getSubsetPath() const {
    SkPath result;
    result.setFillType(fPath.getFillType());
    if (!fSelected.count()) {
        return result;
    }
    SkPath::RawIter iter(fPath);
    uint8_t verb;
    SkPoint pts[4];
    int contourCount = 0;
    bool enabled = fSelected[0];
    bool addMoveTo = true;
    while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
        if (enabled && addMoveTo) {
            result.moveTo(pts[0]);
            addMoveTo = 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:
                if (enabled) {
                    result.close();
                }
                if (++contourCount >= fSelected.count()) {
                    break;
                }
                enabled = fSelected[contourCount];
                addMoveTo = true;
                continue;
            default:
                SkDEBUGFAIL("bad verb");
                return result;
        }
    }
    return result;
}
开发者ID:03050903,项目名称:skia,代码行数:57,代码来源:SubsetPath.cpp

示例13: AddMoveQuadClose

 static SkPoint AddMoveQuadClose(SkPath& path, SkPoint& startPt) {
     SkPoint moveToPt = startPt + SkPoint::Make(0, 10*SK_Scalar1);
     SkPoint midPt = moveToPt + SkPoint::Make(20*SK_Scalar1, 5*SK_Scalar1);
     SkPoint endPt = moveToPt + SkPoint::Make(40*SK_Scalar1, 0);
     path.moveTo(moveToPt);
     path.quadTo(midPt, endPt);
     path.close();
     return endPt;
 }
开发者ID:jetlive,项目名称:skiaming,代码行数:9,代码来源:degeneratesegments.cpp

示例14: create_convex_path

SkPath create_convex_path(const SkPoint& offset) {
    SkPath convexPath;
    convexPath.moveTo(kMin, kMin);
    convexPath.lineTo(kMax, kMax);
    convexPath.lineTo(kMin, kMax);
    convexPath.close();
    convexPath.offset(offset.fX, offset.fY);
    return convexPath;
}
开发者ID:Crawping,项目名称:chromium_extract,代码行数:9,代码来源:SampleClipDrawMatch.cpp

示例15: AddMoveCubicClose

 static SkPoint AddMoveCubicClose(SkPath& path, SkPoint& startPt) {
     SkPoint moveToPt = startPt + SkPoint::Make(0, 10*SK_Scalar1);
     SkPoint t1Pt = moveToPt + SkPoint::Make(15*SK_Scalar1, 5*SK_Scalar1);
     SkPoint t2Pt = moveToPt + SkPoint::Make(25*SK_Scalar1, 5*SK_Scalar1);
     SkPoint endPt = moveToPt + SkPoint::Make(40*SK_Scalar1, 0);
     path.moveTo(moveToPt);
     path.cubicTo(t1Pt, t2Pt, endPt);
     path.close();
     return endPt;
 }
开发者ID:jetlive,项目名称:skiaming,代码行数:10,代码来源:degeneratesegments.cpp


注:本文中的SkPath::close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。