show fat stroking on lines or curves

Change-Id: I31756e5f9fe0b2375f45a1263803196b6efd85d4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/299385
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2020-06-26 14:33:13 -04:00 committed by Skia Commit-Bot
parent 562c8dbd2c
commit 439fe6025b

View File

@ -301,7 +301,7 @@ DEF_SAMPLE( return new ArcToView; )
/////////////
class FatStroke : public Sample {
bool fClosed, fShowStroke, fShowHidden, fShowSkeleton;
bool fClosed, fShowStroke, fShowHidden, fShowSkeleton, fAsCurves = false;
int fJoinType, fCapType;
float fWidth = 30;
SkPaint fPtsPaint, fHiddenPaint, fSkeletonPaint, fStrokePaint;
@ -357,6 +357,7 @@ protected:
case '4': this->toggle3(fJoinType); return true;
case '5': this->toggle3(fCapType); return true;
case '6': this->toggle(fClosed); return true;
case 'c': this->toggle(fAsCurves); return true;
case '-': fWidth -= 5; return true;
case '=': fWidth += 5; return true;
default: break;
@ -366,8 +367,15 @@ protected:
void makePath(SkPath* path) {
path->moveTo(fPts[0]);
for (int i = 1; i < N; ++i) {
path->lineTo(fPts[i]);
if (fAsCurves) {
for (int i = 1; i < N-2; ++i) {
path->quadTo(fPts[i], (fPts[i+1] + fPts[i]) * 0.5f);
}
path->quadTo(fPts[N-2], fPts[N-1]);
} else {
for (int i = 1; i < N; ++i) {
path->lineTo(fPts[i]);
}
}
if (fClosed) {
path->close();