ea60b951d7
Change-Id: Ieac05047826b1fb80950d65573d38494a1a5c5e7 Reviewed-on: https://skia-review.googlesource.com/148383 Commit-Queue: Hal Canary <halcanary@google.com> Commit-Queue: Ben Wagner <bungeman@google.com> Auto-Submit: Hal Canary <halcanary@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
76 lines
1.9 KiB
C++
76 lines
1.9 KiB
C++
/*
|
|
* Copyright 2011 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "Sample.h"
|
|
#include "SkCanvas.h"
|
|
#include "SkGradientShader.h"
|
|
#include "SkGraphics.h"
|
|
#include "SkPath.h"
|
|
#include "SkRandom.h"
|
|
#include "SkRegion.h"
|
|
#include "SkShader.h"
|
|
#include "SkUTF.h"
|
|
#include "SkColorPriv.h"
|
|
#include "SkColorFilter.h"
|
|
#include "SkTime.h"
|
|
#include "SkTypeface.h"
|
|
#include "SkStream.h"
|
|
|
|
class PointsView : public Sample {
|
|
public:
|
|
PointsView() {}
|
|
|
|
protected:
|
|
virtual bool onQuery(Sample::Event* evt) {
|
|
if (Sample::TitleQ(*evt)) {
|
|
Sample::TitleR(evt, "Points");
|
|
return true;
|
|
}
|
|
return this->INHERITED::onQuery(evt);
|
|
}
|
|
|
|
static void fill_pts(SkPoint pts[], size_t n, SkRandom* rand) {
|
|
for (size_t i = 0; i < n; i++)
|
|
pts[i].set(rand->nextUScalar1() * 640, rand->nextUScalar1() * 480);
|
|
}
|
|
|
|
virtual void onDrawContent(SkCanvas* canvas) {
|
|
canvas->translate(SK_Scalar1, SK_Scalar1);
|
|
|
|
SkRandom rand;
|
|
SkPaint p0, p1, p2, p3;
|
|
const size_t n = 99;
|
|
|
|
p0.setColor(SK_ColorRED);
|
|
p1.setColor(SK_ColorGREEN);
|
|
p2.setColor(SK_ColorBLUE);
|
|
p3.setColor(SK_ColorWHITE);
|
|
|
|
p0.setStrokeWidth(SkIntToScalar(4));
|
|
p2.setStrokeCap(SkPaint::kRound_Cap);
|
|
p2.setStrokeWidth(SkIntToScalar(6));
|
|
|
|
SkPoint* pts = new SkPoint[n];
|
|
fill_pts(pts, n, &rand);
|
|
|
|
canvas->drawPoints(SkCanvas::kPolygon_PointMode, n, pts, p0);
|
|
canvas->drawPoints(SkCanvas::kLines_PointMode, n, pts, p1);
|
|
canvas->drawPoints(SkCanvas::kPoints_PointMode, n, pts, p2);
|
|
canvas->drawPoints(SkCanvas::kPoints_PointMode, n, pts, p3);
|
|
|
|
delete[] pts;
|
|
}
|
|
|
|
private:
|
|
|
|
typedef Sample INHERITED;
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
DEF_SAMPLE( return new PointsView(); )
|