aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode/SampleLua.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-22 20:53:42 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-22 20:53:42 +0000
commitfd3458750d92d9722e5760ddb99824e65455463c (patch)
treeef447aff5f80453bf473d7a2c7b67d833ac7090e /samplecode/SampleLua.cpp
parent3597b73bc6e3e169f1d360de80d77e6e0ab65e96 (diff)
use macro to encapsulate building get_mtname() specializations
BUG= Review URL: https://codereview.chromium.org/15773002 git-svn-id: http://skia.googlecode.com/svn/trunk@9248 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode/SampleLua.cpp')
-rw-r--r--samplecode/SampleLua.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/samplecode/SampleLua.cpp b/samplecode/SampleLua.cpp
index 263138bf6b..5b6be55ecc 100644
--- a/samplecode/SampleLua.cpp
+++ b/samplecode/SampleLua.cpp
@@ -19,6 +19,8 @@ extern "C" {
static const char gDrawName[] = "onDrawContent";
static const char gCode[] = ""
+ "require \"math\" "
+ ""
"local r = { left = 10, top = 10, right = 100, bottom = 80 } "
"local x = 0;"
""
@@ -27,7 +29,30 @@ static const char gCode[] = ""
""
"local color = {a = 1, r = 1, g = 0, b = 0};"
""
+ "function rnd(range) "
+ " return math.random() * range;"
+ "end "
+ ""
+ "rndX = function () return rnd(640) end "
+ "rndY = function () return rnd(480) end "
+ ""
+ "function draw_rand_path(canvas);"
+ " if not path_paint then "
+ " path_paint = Sk.newPaint();"
+ " path_paint:setAntiAlias(true);"
+ " end "
+ " path_paint:setColor({a = 1, r = math.random(), g = math.random(), b = math.random() });"
+ ""
+ " local path = Sk.newPath();"
+ " path:moveTo(rndX(), rndY());"
+ " for i = 0, 50 do "
+ " path:quadTo(rndX(), rndY(), rndX(), rndY());"
+ " end "
+ " canvas:drawPath(path, path_paint);"
+ "end "
+ ""
"function onDrawContent(canvas) "
+ " draw_rand_path(canvas);"
" color.g = x / 100;"
" paint:setColor(color) "
" canvas:translate(x, 0);"
@@ -60,10 +85,6 @@ protected:
}
SkUnichar uni;
if (SampleCode::CharQ(*evt, &uni)) {
- switch (uni) {
- default:
- break;
- }
}
return this->INHERITED::onQuery(evt);
}