本文整理汇总了C++中SkPath::setConvexity方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPath::setConvexity方法的具体用法?C++ SkPath::setConvexity怎么用?C++ SkPath::setConvexity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPath
的用法示例。
在下文中一共展示了SkPath::setConvexity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawAtlas
void SkBaseDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkRSXform xform[],
const SkRect tex[], const SkColor colors[], int count,
SkXfermode::Mode mode, const SkPaint& paint) {
SkPath path;
path.setIsVolatile(true);
for (int i = 0; i < count; ++i) {
SkPoint quad[4];
xform[i].toQuad(tex[i].width(), tex[i].height(), quad);
SkMatrix localM;
localM.setRSXform(xform[i]);
localM.preTranslate(-tex[i].left(), -tex[i].top());
SkPaint pnt(paint);
sk_sp<SkShader> shader = atlas->makeShader(SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode,
&localM);
if (!shader) {
break;
}
pnt.setShader(std::move(shader));
if (colors) {
pnt.setColorFilter(SkColorFilter::MakeModeFilter(colors[i], mode));
}
path.rewind();
path.addPoly(quad, 4, true);
path.setConvexity(SkPath::kConvex_Convexity);
this->drawPath(draw, path, pnt, nullptr, true);
}
}
示例2: drawAtlas
void SkBaseDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkRSXform xform[],
const SkRect tex[], const SkColor colors[], int count,
SkXfermode::Mode mode, const SkPaint& paint) {
SkPath path;
path.setIsVolatile(true);
for (int i = 0; i < count; ++i) {
SkPoint quad[4];
xform[i].toQuad(tex[i].width(), tex[i].height(), quad);
SkMatrix localM;
localM.setRSXform(xform[i]);
localM.preTranslate(-tex[i].left(), -tex[i].top());
SkPaint pnt(paint);
pnt.setShader(atlas->newShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode,
&localM))->unref();
if (colors && colors[i] != SK_ColorWHITE) {
SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(colors[i], mode));
pnt.setColorFilter(cf);
}
path.rewind();
path.addPoly(quad, 4, true);
path.setConvexity(SkPath::kConvex_Convexity);
this->drawPath(draw, path, pnt, NULL, true);
}
}
示例3: onDraw
void onDraw(SkCanvas* canvas) override {
SkPaint p;
p.setColor(SK_ColorRED);
p.setAntiAlias(true);
canvas->clear(0xFFFFFFFF);
canvas->save();
SkScalar y = 0;
canvas->translate(0, y);
canvas->rotate(1);
canvas->drawRect({ 20, 20, 200, 200 }, p);
canvas->restore();
y += 200;
canvas->translate(0, y);
canvas->rotate(1);
canvas->drawRect({ 20, 20, 20.2f, 200 }, p);
canvas->drawRect({ 20, 200, 200, 200.1f }, p);
canvas->drawCircle(100, 100, 30, p);
canvas->restore();
// The following path is empty but it'll reveal bug chrome:662914
SkPath path;
path.moveTo(SkBits2Float(0x429b9d5c), SkBits2Float(0x4367a041)); // 77.8073f, 231.626f
// 77.8075f, 231.626f, 77.8074f, 231.625f, 77.8073f, 231.625f
path.cubicTo(SkBits2Float(0x429b9d71), SkBits2Float(0x4367a022),
SkBits2Float(0x429b9d64), SkBits2Float(0x4367a009),
SkBits2Float(0x429b9d50), SkBits2Float(0x43679ff2));
path.lineTo(SkBits2Float(0x429b9d5c), SkBits2Float(0x4367a041)); // 77.8073f, 231.626f
path.close();
canvas->drawPath(path, p);
// The following path reveals a subtle SkAnalyticQuadraticEdge::updateQuadratic bug:
// we should not use any snapped y for the intermediate values whose error may accumulate;
// snapping should only be allowed once before updateLine.
path.reset();
path.moveTo(SkBits2Float(0x434ba71e), SkBits2Float(0x438a06d0)); // 203.653f, 276.053f
path.lineTo(SkBits2Float(0x43492a74), SkBits2Float(0x4396d70d)); // 201.166f, 301.68f
// 200.921f, 304.207f, 196.939f, 303.82f, 0.707107f
path.conicTo(SkBits2Float(0x4348ebaf), SkBits2Float(0x43981a75),
SkBits2Float(0x4344f079), SkBits2Float(0x4397e900), SkBits2Float(0x3f3504f3));
path.close();
// Manually setting convexity is required. Otherwise, this path will be considered concave.
path.setConvexity(SkPath::kConvex_Convexity);
canvas->drawPath(path, p);
// skbug.com/7573
y += 200;
canvas->translate(0, y);
p.setAntiAlias(true);
path.reset();
path.moveTo(1.98009784f, 9.0162744f);
path.lineTo(47.843992f, 10.1922744f);
path.lineTo(47.804008f, 11.7597256f);
path.lineTo(1.93990216f, 10.5837256f);
canvas->drawPath(path, p);
canvas->restore();
}