Go to the source code of this file.
|
static void | gen_data (SkScalar yAvg, SkScalar ySpread, int count, SkRandom *random, SkTDArray< SkScalar > *dataPts) |
|
static void | gen_paths (const SkTDArray< SkScalar > &topData, const SkTDArray< SkScalar > *bottomData, SkScalar yBase, SkScalar xLeft, SkScalar xDelta, int leftShift, SkPath *plot, SkPath *fill) |
|
◆ gen_data()
This is a conversion of samplecode/SampleChart.cpp into a bench. It sure would be nice to be able to write one subclass that can be a GM, bench, and/or Sample.
Definition at line 21 of file ChartBench.cpp.
22 {
27 }
28}
SkScalar nextRangeScalar(SkScalar min, SkScalar max)
◆ gen_paths()
Definition at line 34 of file ChartBench.cpp.
39 {
43 if (nullptr == bottomData) {
45 } else {
47 }
48
49 leftShift %= topData.
size();
51
52
53 int shiftToEndCount = topData.
size() - leftShift;
54 plot->moveTo(
x, topData[leftShift]);
55 fill->
moveTo(
x, topData[leftShift]);
56
57 for (
int i = 1;
i < shiftToEndCount; ++
i) {
58 plot->lineTo(
x, topData[
i + leftShift]);
59 fill->
lineTo(
x, topData[
i + leftShift]);
61 }
62
63 for (
int i = 0;
i < leftShift; ++
i) {
64 plot->lineTo(
x, topData[
i]);
67 }
68
69 if (bottomData) {
71
72
73 for (
int i = 0;
i < leftShift; ++
i) {
75 fill->
lineTo(
x, (*bottomData)[leftShift - 1 -
i]);
76 }
77 for (
int i = 0;
i < shiftToEndCount; ++
i) {
79 fill->
lineTo(
x, (*bottomData)[bottomData->
size() - 1 -
i]);
80 }
81 } else {
82 fill->
lineTo(
x - xDelta, yBase);
83 fill->
lineTo(xLeft, yBase);
84 }
85}
SkPath & moveTo(SkScalar x, SkScalar y)
SkPath & lineTo(SkScalar x, SkScalar y)
void incReserve(int extraPtCount, int extraVerbCount=0, int extraConicCount=0)
static void plot(SkCanvas *canvas, const char *fn, float xMin, float xMax, float yMin, float yMax, const char *label=nullptr, bool requireES3=false)