本文整理汇总了C++中SkPath::addCircle方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPath::addCircle方法的具体用法?C++ SkPath::addCircle怎么用?C++ SkPath::addCircle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPath
的用法示例。
在下文中一共展示了SkPath::addCircle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_fill
void draw_fill(SkCanvas* canvas, const SkRect& rect, SkScalar width) {
if (rect.isEmpty()) {
return;
}
SkPaint paint;
paint.setColor(0x1f1f0f0f);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(width);
SkPath path;
SkScalar maxSide = SkTMax(rect.width(), rect.height()) / 2;
SkPoint center = { rect.fLeft + maxSide, rect.fTop + maxSide };
path.addCircle(center.fX, center.fY, maxSide);
canvas->drawPath(path, paint);
paint.setStyle(SkPaint::kFill_Style);
path.reset();
path.addCircle(center.fX, center.fY, maxSide - width / 2);
paint.setColor(0x3f0f1f3f);
canvas->drawPath(path, paint);
path.reset();
path.setFillType(SkPath::kEvenOdd_FillType);
path.addCircle(center.fX, center.fY, maxSide + width / 2);
SkRect outside = SkRect::MakeXYWH(center.fX - maxSide - width, center.fY - maxSide - width,
(maxSide + width) * 2, (maxSide + width) * 2);
path.addRect(outside);
canvas->drawPath(path, paint);
}
示例2: makePath
void makePath() {
if (fPath.isEmpty()) {
const SkScalar radius = SkIntToScalar(45);
fPath.addCircle(SkIntToScalar(50), SkIntToScalar(50), radius);
fPath.addCircle(SkIntToScalar(100), SkIntToScalar(100), radius);
}
}
示例3: FillTypeView
FillTypeView() {
const SkScalar radius = SkIntToScalar(45);
fPath.addCircle(SkIntToScalar(50), SkIntToScalar(50), radius);
fPath.addCircle(SkIntToScalar(100), SkIntToScalar(100), radius);
this->setBGColor(0xFFDDDDDD);
}
示例4: onOnceBeforeDraw
void onOnceBeforeDraw() override {
fX1 = 80;
fX2 = 120;
fY = 50;
fR = 40;
fCircle1.addCircle(fX1, fY, fR, SkPath::kCW_Direction);
fCircle2.addCircle(fX2, fY, fR, SkPath::kCW_Direction);
}
示例5: onDraw
virtual void onDraw(SkCanvas* canvas) {
SkPath path;
path.addCircle(SkIntToScalar(50), SkIntToScalar(50), SkIntToScalar(40));
path.toggleInverseFillType();
SkRect clipR = { 0, 0, SkIntToScalar(100), SkIntToScalar(200) };
canvas->translate(SkIntToScalar(10), SkIntToScalar(10));
for (int doclip = 0; doclip <= 1; ++doclip) {
for (int aa = 0; aa <= 1; ++aa) {
SkPaint paint;
paint.setAntiAlias(SkToBool(aa));
canvas->save();
canvas->clipRect(clipR);
const SkRect* clipPtr = doclip ? &clipR : NULL;
show(canvas, path, paint, clipPtr, clipR.fTop, clipR.centerY());
show(canvas, path, paint, clipPtr, clipR.centerY(), clipR.fBottom);
canvas->restore();
canvas->translate(SkIntToScalar(110), 0);
}
}
}
示例6: TestOverflowHitTest
static void TestOverflowHitTest() {
SkPath path;
#ifdef SK_SCALAR_IS_FLOATx
path.addCircle(0, 0, 70000, SkPath::kCCW_Direction);
SkASSERT(HitTestPath(path, 40000, 40000));
#endif
}
示例7: draw
SkRect draw(SkCanvas* canvas, const SkPaint& paint) override {
SkPath path;
path.addCircle(15, 15, 10);
path.addOval(SkRect::MakeXYWH(2, 2, 22, 37));
path.setFillType(SkPath::kEvenOdd_FillType);
canvas->drawPath(path, paint);
return path.getBounds();
}
示例8: TestOverflowHitTest
static void TestOverflowHitTest() {
SkPath path;
#ifdef SK_SCALAR_IS_FLOATx // FIXME: unclear when if ever this can be enabled
path.addCircle(0, 0, 70000, SkPath::kCCW_Direction);
SkASSERT(HitTestPath(path, 40000, 40000));
#endif
}
示例9: onDraw
virtual void onDraw(SkCanvas* canvas) {
SkMatrix m;
m.reset();
m.setRotate(33 * SK_Scalar1);
m.postScale(3000 * SK_Scalar1, 3000 * SK_Scalar1);
m.postTranslate(6000 * SK_Scalar1, -5000 * SK_Scalar1);
canvas->concat(m);
SkPaint paint;
paint.setColor(SK_ColorRED);
paint.setAntiAlias(true);
bool success = m.invert(&m);
SkASSERT(success);
(void) success; // silence compiler :(
SkPath path;
SkPoint pt = {10 * SK_Scalar1, 10 * SK_Scalar1};
SkScalar small = 1 / (500 * SK_Scalar1);
m.mapPoints(&pt, 1);
path.addCircle(pt.fX, pt.fY, small);
canvas->drawPath(path, paint);
pt.set(30 * SK_Scalar1, 10 * SK_Scalar1);
m.mapPoints(&pt, 1);
SkRect rect = {pt.fX - small, pt.fY - small,
pt.fX + small, pt.fY + small};
canvas->drawRect(rect, paint);
SkBitmap bmp;
bmp.setConfig(SkBitmap::kARGB_8888_Config, 2, 2);
bmp.allocPixels();
bmp.lockPixels();
uint32_t* pixels = reinterpret_cast<uint32_t*>(bmp.getPixels());
pixels[0] = SkPackARGB32(0xFF, 0xFF, 0x00, 0x00);
pixels[1] = SkPackARGB32(0xFF, 0x00, 0xFF, 0x00);
pixels[2] = SkPackARGB32(0x80, 0x00, 0x00, 0x00);
pixels[3] = SkPackARGB32(0xFF, 0x00, 0x00, 0xFF);
bmp.unlockPixels();
pt.set(30 * SK_Scalar1, 30 * SK_Scalar1);
m.mapPoints(&pt, 1);
SkShader* shader = SkShader::CreateBitmapShader(
bmp,
SkShader::kRepeat_TileMode,
SkShader::kRepeat_TileMode);
SkMatrix s;
s.reset();
s.setScale(SK_Scalar1 / 1000, SK_Scalar1 / 1000);
shader->setLocalMatrix(s);
paint.setShader(shader)->unref();
paint.setAntiAlias(false);
paint.setFilterLevel(SkPaint::kLow_FilterLevel);
rect.setLTRB(pt.fX - small, pt.fY - small,
pt.fX + small, pt.fY + small);
canvas->drawRect(rect, paint);
}
示例10: MakeTileEffect
static SkPathEffect* MakeTileEffect() {
SkMatrix m;
m.setScale(SkIntToScalar(12), SkIntToScalar(12));
SkPath path;
path.addCircle(0, 0, SkIntToScalar(5));
return SkPath2DPathEffect::Create(m, path);
}
示例11: SkIntToScalar
static sk_sp<SkPathEffect> make_tile_effect() {
SkMatrix m;
m.setScale(1.f, 1.f);
SkPath path;
path.addCircle(0, 0, SkIntToScalar(5));
return SkPath2DPathEffect::Make(m, path);
}
示例12: onDraw
virtual void onDraw(SkCanvas* canvas) {
SkScalar x = SkIntToScalar(100);
SkScalar y = SkIntToScalar(88);
SkPaint paint;
paint.setAntiAlias(true);
paint.setTextSize(SkIntToScalar(100));
paint.setStrokeWidth(SkIntToScalar(5));
SkTypeface* face = SkTypeface::CreateFromName("Papyrus", SkTypeface::kNormal);
SkSafeUnref(paint.setTypeface(face));
show_bold(canvas, "Hello", 5, x, y, paint);
face = SkTypeface::CreateFromName("Hiragino Maru Gothic Pro", SkTypeface::kNormal);
SkSafeUnref(paint.setTypeface(face));
const unsigned char hyphen[] = { 0xE3, 0x83, 0xBC };
show_bold(canvas, hyphen, SK_ARRAY_COUNT(hyphen), x + SkIntToScalar(300), y, paint);
paint.setStyle(SkPaint::kStrokeAndFill_Style);
SkPath path;
path.setFillType(SkPath::kWinding_FillType);
path.addCircle(x, y + SkIntToScalar(200), SkIntToScalar(50), SkPath::kCW_Direction);
path.addCircle(x, y + SkIntToScalar(200), SkIntToScalar(40), SkPath::kCCW_Direction);
canvas->drawPath(path, paint);
SkPath path2;
path2.setFillType(SkPath::kWinding_FillType);
path2.addCircle(x + SkIntToScalar(120), y + SkIntToScalar(200), SkIntToScalar(50), SkPath::kCCW_Direction);
path2.addCircle(x + SkIntToScalar(120), y + SkIntToScalar(200), SkIntToScalar(40), SkPath::kCW_Direction);
canvas->drawPath(path2, paint);
path2.reset();
path2.addCircle(x + SkIntToScalar(240), y + SkIntToScalar(200), SkIntToScalar(50), SkPath::kCCW_Direction);
canvas->drawPath(path2, paint);
SkASSERT(path2.cheapIsDirection(SkPath::kCCW_Direction));
path2.reset();
SkASSERT(!path2.cheapComputeDirection(NULL));
path2.addCircle(x + SkIntToScalar(360), y + SkIntToScalar(200), SkIntToScalar(50), SkPath::kCW_Direction);
SkASSERT(path2.cheapIsDirection(SkPath::kCW_Direction));
canvas->drawPath(path2, paint);
}
示例13: SkIntToScalar
StrokePathView() {
// test_blur();
fWidth = SkIntToScalar(120);
#if 0
const char str[] =
"M 0, 3"
"C 10, -10, 30, -10, 0, 28"
"C -30, -10, -10, -10, 0, 3"
"Z";
SkParsePath::FromSVGString(str, &fPath);
#else
fPath.addCircle(0, 0, SkIntToScalar(50), SkPath::kCW_Direction);
fPath.addCircle(0, SkIntToScalar(-50), SkIntToScalar(30), SkPath::kCW_Direction);
#endif
scale_to_width(&fPath, fWidth);
const SkRect& bounds = fPath.getBounds();
fPath.offset(-bounds.fLeft, -bounds.fTop);
}
示例14: quadTo
void SkPathStroker::quadTo(const SkPoint& pt1, const SkPoint& pt2) {
bool degenerateAB = SkPath::IsLineDegenerate(fPrevPt, pt1);
bool degenerateBC = SkPath::IsLineDegenerate(pt1, pt2);
if (degenerateAB | degenerateBC) {
if (degenerateAB ^ degenerateBC) {
this->lineTo(pt2);
}
return;
}
SkVector normalAB, unitAB, normalBC, unitBC;
this->preJoinTo(pt1, &normalAB, &unitAB, false);
{
SkPoint pts[3], tmp[5];
pts[0] = fPrevPt;
pts[1] = pt1;
pts[2] = pt2;
if (SkChopQuadAtMaxCurvature(pts, tmp) == 2) {
unitBC.setNormalize(pts[2].fX - pts[1].fX, pts[2].fY - pts[1].fY);
unitBC.rotateCCW();
if (normals_too_pinchy(unitAB, unitBC)) {
normalBC = unitBC;
normalBC.scale(fRadius);
fOuter.lineTo(tmp[2].fX + normalAB.fX, tmp[2].fY + normalAB.fY);
fOuter.lineTo(tmp[2].fX + normalBC.fX, tmp[2].fY + normalBC.fY);
fOuter.lineTo(tmp[4].fX + normalBC.fX, tmp[4].fY + normalBC.fY);
fInner.lineTo(tmp[2].fX - normalAB.fX, tmp[2].fY - normalAB.fY);
fInner.lineTo(tmp[2].fX - normalBC.fX, tmp[2].fY - normalBC.fY);
fInner.lineTo(tmp[4].fX - normalBC.fX, tmp[4].fY - normalBC.fY);
fExtra.addCircle(tmp[2].fX, tmp[2].fY, fRadius,
SkPath::kCW_Direction);
} else {
this->quad_to(&tmp[0], normalAB, unitAB, &normalBC, &unitBC,
kMaxQuadSubdivide);
SkVector n = normalBC;
SkVector u = unitBC;
this->quad_to(&tmp[2], n, u, &normalBC, &unitBC,
kMaxQuadSubdivide);
}
} else {
this->quad_to(pts, normalAB, unitAB, &normalBC, &unitBC,
kMaxQuadSubdivide);
}
}
this->postJoinTo(pt2, normalBC, unitBC);
}
示例15: AAClipRegionBench
AAClipRegionBench(void* param) : INHERITED(param) {
SkPath path;
// test conversion of a complex clip to a aaclip
path.addCircle(0, 0, SkIntToScalar(200));
path.addCircle(0, 0, SkIntToScalar(180));
// evenodd means we've constructed basically a stroked circle
path.setFillType(SkPath::kEvenOdd_FillType);
SkIRect bounds;
path.getBounds().roundOut(&bounds);
fRegion.setPath(path, SkRegion(bounds));
}