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

Side by Side Diff: resources/test.lua

Issue 645283002: move test for lua into separate resource file (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | samplecode/SampleLua.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
2 local r = { left = 10, top = 10, right = 100, bottom = 80 }
3 local x = 0;
4
5 local paint = Sk.newPaint();
6 paint:setAntiAlias(true);
7
8 local image -- = Sk.loadImage('/skia/sailboat.jpg');
9 function setImageFilename(filename)
10 image = Sk.loadImage(filename)
11 end
12
13
14 local color = {a = 1, r = 1, g = 0, b = 0};
15
16 function rnd(range)
17 return math.random() * range;
18 end
19
20 rndX = function () return rnd(640) end
21 rndY = function () return rnd(480) end
22
23 function draw_rand_path(canvas);
24 if not path_paint then
25 path_paint = Sk.newPaint();
26 path_paint:setAntiAlias(true);
27 end
28 path_paint:setColor({a = 1, r = math.random(), g = math.random(), b = math.ra ndom() });
29
30 local path = Sk.newPath();
31 path:moveTo(rndX(), rndY());
32 for i = 0, 50 do
33 path:quadTo(rndX(), rndY(), rndX(), rndY());
34 end
35 canvas:drawPath(path, path_paint);
36
37 paint:setColor{a=1,r=0,g=0,b=1};
38 local align = { 'left', 'center', 'right' };
39 paint:setTextSize(30);
40 for k, v in next, align do
41 paint:setTextAlign(v);
42 canvas:drawText('Hamburgefons', 320, 200 + 30*k, paint);
43 end
44 end
45
46 function onStartup()
47 local paint = Sk.newPaint();
48 paint:setColor{a=1, r=1, g=0, b=0};
49 if false then
50 local doc = Sk.newDocumentPDF('/skia/trunk/test.pdf');
51 local canvas = doc:beginPage(72*8.5, 72*11);
52 canvas:drawText('Hello Lua', 300, 300, paint);
53 doc:close();
54 doc = nil;
55 end
56 end
57
58 function onDrawContent(canvas)
59 draw_rand_path(canvas);
60 color.g = x / 100;
61 paint:setColor(color)
62 canvas:translate(x, 0);
63 canvas:drawOval(r, paint)
64 x = x + 1;
65 local r2 = {}
66 r2.left = x;
67 r2.top = r.bottom + 50;
68 r2.right = r2.left + image:width() * 1;
69 r2.bottom = r2.top + image:height() * 1;
70 canvas:drawImageRect(image, nil, r2, 0.75);
71 if x > 200 then x = 0 end;
72 end
73
74 onStartup()
OLDNEW
« no previous file with comments | « no previous file | samplecode/SampleLua.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698