Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(968)

Unified Diff: samplecode/SampleLua.cpp

Issue 15773002: use macro to encapsulate building get_mtname() specializations (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/utils/SkLua.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleLua.cpp
diff --git a/samplecode/SampleLua.cpp b/samplecode/SampleLua.cpp
index 263138bf6be8c5939e979f0b37bf4000aa248571..cfafd9da70aaa5f160b1c2504d9d02ac4edbe5d2 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);"
« no previous file with comments | « no previous file | src/utils/SkLua.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698