36 if (
nullptr == bottomData) {
42 leftShift %= topData.
size();
46 int shiftToEndCount = topData.
size() - leftShift;
47 plot->moveTo(
x, topData[leftShift]);
48 fill->
moveTo(
x, topData[leftShift]);
50 for (
int i = 1;
i < shiftToEndCount; ++
i) {
51 plot->lineTo(
x, topData[
i + leftShift]);
52 fill->
lineTo(
x, topData[
i + leftShift]);
56 for (
int i = 0;
i < leftShift; ++
i) {
57 plot->lineTo(
x, topData[
i]);
66 for (
int i = 0;
i < leftShift; ++
i) {
68 fill->
lineTo(
x, (*bottomData)[leftShift - 1 -
i]);
70 for (
int i = 0;
i < shiftToEndCount; ++
i) {
72 fill->
lineTo(
x, (*bottomData)[bottomData->
size() - 1 -
i]);
75 fill->
lineTo(
x - xDelta, yBase);
76 fill->
lineTo(xLeft, yBase);
83 inline static constexpr int kNumGraphs = 5;
84 inline static constexpr int kPixelsPerTick = 3;
85 inline static constexpr int kShiftPerFrame = 1;
94 bool sizeChanged =
false;
105 int dataPointCount =
std::max(fSize.fWidth / kPixelsPerTick + 1, 2);
107 for (
int i = 0;
i < kNumGraphs; ++
i) {
110 gen_data(
y, ySpread, dataPointCount, fData +
i);
114 canvas->
clear(0xFFE0F0E0);
119 for (
int i = 0;
i < kNumGraphs; ++
i) {
138 for (
int i = 0;
i < kNumGraphs; ++
i) {
155 prevData = fData +
i;
158 fShift += kShiftPerFrame;
static void gen_paths(const SkTDArray< SkScalar > &topData, const SkTDArray< SkScalar > *bottomData, SkScalar yBase, SkScalar xLeft, SkScalar xDelta, int leftShift, SkPathBuilder *plot, SkPathBuilder *fill)
static void gen_data(SkScalar yAvg, SkScalar ySpread, int count, SkTDArray< SkScalar > *dataPts)
static const SkColor gColors[]
void draw(SkCanvas *canvas) override
virtual SkISize getBaseLayerSize() const
void clear(SkColor color)
void drawPath(const SkPath &path, const SkPaint &paint)
void setStyle(Style style)
void setColor(SkColor color)
void setAntiAlias(bool aa)
void setStrokeCap(Cap cap)
@ kStroke_Style
set to stroke geometry
@ kFill_Style
set to fill geometry
void setStrokeJoin(Join join)
void setStrokeWidth(SkScalar width)
SkPathBuilder & lineTo(SkPoint pt)
void incReserve(int extraPtCount, int extraVerbCount)
SkPathBuilder & moveTo(SkPoint pt)
SkScalar nextRangeScalar(SkScalar min, SkScalar max)
static float max(float r, float g, float b)
static void plot(SkCanvas *canvas, const char *fn, float xMin, float xMax, float yMin, float yMax, const char *label=nullptr, bool requireES3=false)