本文整理汇总了C++中SkTDArray::top方法的典型用法代码示例。如果您正苦于以下问题:C++ SkTDArray::top方法的具体用法?C++ SkTDArray::top怎么用?C++ SkTDArray::top使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkTDArray
的用法示例。
在下文中一共展示了SkTDArray::top方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onDraw
void onDraw(SkCanvas* canvas) override {
static const char kText[] = "SKIA";
static const int kTextLen = SK_ARRAY_COUNT(kText) - 1;
static const int kPointSize = 55;
SkTDArray<LabeledMatrix> matrices;
matrices.append()->fMatrix.reset();
matrices.top().fLabel = "Identity";
matrices.append()->fMatrix.setScale(1.2f, 0.8f);
matrices.top().fLabel = "Scale";
matrices.append()->fMatrix.setRotate(10.f);
matrices.top().fLabel = "Rotate";
matrices.append()->fMatrix.reset();
matrices.top().fMatrix.setPerspX(-0.0015f);
matrices.top().fMatrix.setPerspY(+0.0015f);
matrices.top().fLabel = "Persp";
SkTDArray<LabeledMatrix> localMatrices;
localMatrices.append()->fMatrix.reset();
localMatrices.top().fLabel = "Identity";
localMatrices.append()->fMatrix.setScale(2.5f, 0.2f);
localMatrices.top().fLabel = "Scale";
localMatrices.append()->fMatrix.setRotate(45.f);
localMatrices.top().fLabel = "Rotate";
localMatrices.append()->fMatrix.reset();
localMatrices.top().fMatrix.setPerspX(-0.007f);
localMatrices.top().fMatrix.setPerspY(+0.008f);
localMatrices.top().fLabel = "Persp";
static SkBitmap bmp;
if (bmp.isNull()) {
makebm(&bmp, kPointSize / 2, kPointSize / 2);
}
SkPaint fillPaint;
fillPaint.setAntiAlias(true);
sk_tool_utils::set_portable_typeface_always(&fillPaint);
fillPaint.setTextSize(SkIntToScalar(kPointSize));
fillPaint.setFilterQuality(kLow_SkFilterQuality);
SkPaint outlinePaint;
outlinePaint.setAntiAlias(true);
sk_tool_utils::set_portable_typeface_always(&outlinePaint);
outlinePaint.setTextSize(SkIntToScalar(kPointSize));
outlinePaint.setStyle(SkPaint::kStroke_Style);
outlinePaint.setStrokeWidth(0.f);
SkScalar w = fillPaint.measureText(kText, kTextLen);
static SkScalar kPadY = 0.5f * kPointSize;
static SkScalar kPadX = 1.5f * kPointSize;
SkPaint strokePaint(fillPaint);
strokePaint.setStyle(SkPaint::kStroke_Style);
strokePaint.setStrokeWidth(kPointSize * 0.1f);
SkPaint labelPaint;
labelPaint.setColor(0xff000000);
labelPaint.setAntiAlias(true);
sk_tool_utils::set_portable_typeface_always(&labelPaint);
labelPaint.setTextSize(12.f);
canvas->translate(15.f, 15.f);
canvas->drawBitmap(bmp, 0, 0);
canvas->translate(0, bmp.height() + labelPaint.getTextSize() + 15.f);
static const char kLabelLabel[] = "localM / canvasM";
canvas->drawText(kLabelLabel, strlen(kLabelLabel), 0, 0, labelPaint);
canvas->translate(0, 15.f);
canvas->save();
SkScalar maxLabelW = 0;
canvas->translate(0, kPadY / 2 + kPointSize);
for (int lm = 0; lm < localMatrices.count(); ++lm) {
canvas->drawText(matrices[lm].fLabel, strlen(matrices[lm].fLabel),
0, labelPaint.getTextSize() - 1, labelPaint);
SkScalar labelW = labelPaint.measureText(matrices[lm].fLabel,
strlen(matrices[lm].fLabel));
maxLabelW = SkMaxScalar(maxLabelW, labelW);
canvas->translate(0.f, 2 * kPointSize + 2.5f * kPadY);
}
canvas->restore();
canvas->translate(maxLabelW + kPadX / 2.f, 0.f);
for (int s = 0; s < 2; ++s) {
SkPaint& paint = s ? strokePaint : fillPaint;
SkScalar columnH = 0;
for (int m = 0; m < matrices.count(); ++m) {
columnH = 0;
canvas->save();
canvas->drawText(matrices[m].fLabel, strlen(matrices[m].fLabel),
0, labelPaint.getTextSize() - 1, labelPaint);
canvas->translate(0, kPadY / 2 + kPointSize);
columnH += kPadY / 2 + kPointSize;
for (int lm = 0; lm < localMatrices.count(); ++lm) {
paint.setShader(
SkShader::CreateBitmapShader(bmp,
SkShader::kMirror_TileMode,
SkShader::kRepeat_TileMode,
//.........这里部分代码省略.........