aboutsummaryrefslogtreecommitdiff
path: root/samplecode/SampleBox.cpp
diff options
context:
space:
mode:
authoryangsu@google.com <yangsu@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-06-01 16:11:58 +0000
committeryangsu@google.com <yangsu@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-06-01 16:11:58 +0000
commit4c295a3d9285247a50fffbc3d2a3317c45249c5b (patch)
treecca12d5c8e76b30384c131c84298f176f48d1f5a /samplecode/SampleBox.cpp
parent416d30370941cc03423ae014061a640fae9ac212 (diff)
Added 3 new sample tests. http://codereview.appspot.com/4527092/
git-svn-id: http://skia.googlecode.com/svn/trunk@1464 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode/SampleBox.cpp')
-rw-r--r--samplecode/SampleBox.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/samplecode/SampleBox.cpp b/samplecode/SampleBox.cpp
new file mode 100644
index 0000000000..d445df7596
--- /dev/null
+++ b/samplecode/SampleBox.cpp
@@ -0,0 +1,48 @@
+#include "SampleCode.h"
+#include "SkView.h"
+#include "SkCanvas.h"
+
+class SimpleView : public SampleView {
+public:
+ SimpleView() {
+ this->setBGColor(0xFFDDDDDD);
+ }
+
+protected:
+ // overrides from SkEventSink
+ virtual bool onQuery(SkEvent* evt) {
+ if (SampleCode::TitleQ(*evt)) {
+ SampleCode::TitleR(evt, "Box Gradient");
+ return true;
+ }
+ return this->INHERITED::onQuery(evt);
+ }
+
+ virtual void onDrawContent(SkCanvas* canvas) {
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setStyle(SkPaint::kStroke_Style);
+ paint.setStrokeWidth(SkScalarHalf(SkIntToScalar(3)));
+ paint.setStyle(SkPaint::kFill_Style);
+
+ SkRect r;
+ SkScalar x,y;
+ x = 10;
+ y = 10;
+
+ r.set(x, y, x + SkIntToScalar(100), y + SkIntToScalar(100));
+ for (int i = 0; i < 256; ++i) {
+ canvas->translate(1, 1);
+ paint.setColor(0xFF000000 + i * 0x00010000);
+ canvas->drawRect(r, paint);
+ }
+ }
+
+private:
+ typedef SampleView INHERITED;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+static SkView* MyFactory() { return new SimpleView; }
+static SkViewRegister reg(MyFactory); \ No newline at end of file