Slightly more sane examples of map usage.
authoronefang <onefang>
Mon, 7 Nov 2011 09:52:17 +0000 (09:52 +0000)
committeronefang <onefang@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 7 Nov 2011 09:52:17 +0000 (09:52 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@64862 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/examples/lua_script.edc

index eb4fdbe..1eb161f 100644 (file)
@@ -141,43 +141,69 @@ collections {
          print(D.text:text());
          D.text:show();
 
+         --// Fun with maps!
          D.map = edje.map(4);
+         --// These all do the same thing.
+         --// Note, lua likes to start at 1, C (and thus evas) at 0.  I choose to agree with C.
+         D.map:coord(0, 50, 50, 0);
+         D.map:coord(1, 100, 50, 0);
+         D.map:coord(2, 100, 100, 0);
+         D.map:coord(3, 50, 100, 0);
+         D.map:populate(50, 50, 50, 50, 0);
+         D.map:populate(D.rect2, 0);
+         D.map:populate(D.rect2);
 
-         D.map:coord(1, 100, 200, 300);
+         --// print the results
+         D.coord = D.map:coord(0);
+         print("lua::map coords for point 0 x=" .. D.coord.x .. " y=" .. D.coord.y .. " z=" .. D.coord.z);
          D.coord = D.map:coord(1);
+         print("lua::map coords for point 1 x=" .. D.coord.x .. " y=" .. D.coord.y .. " z=" .. D.coord.z);
+         D.coord = D.map:coord(2);
+         print("lua::map coords for point 2 x=" .. D.coord.x .. " y=" .. D.coord.y .. " z=" .. D.coord.z);
+         D.coord = D.map:coord(3);
+         print("lua::map coords for point 3 x=" .. D.coord.x .. " y=" .. D.coord.y .. " z=" .. D.coord.z);
 
-         D.map:populate(100, 200, 23, 45, 0);
-         D.map:populate(D.rect2);
-         D.map:populate(D.rect2, 0);
+         D.map:smooth(false);
+         D.map:alpha(true);
 
-         D.rect2:map(map);
-         D.rect2:map_enable(true);
-         if (D.rect2:map_enable()) then
-            print("lua::map enabled");
+         if (D.map:alpha()) then
+            print("lua::map is alpha");
          end
 
-         D.map:rotate(45.0, 10, 20);
-         D.map:zoom(10.0, 20.0, 100, 200);
-
-         D.map:rotate3d(90.0, 180.0, 45.0, 100, 200, 300);
-         D.map:perspective(100, 200, 300, 400);
+         if (D.map:smooth()) then
+            print("lua::map is smooooth");
+         end
 
-         D.map:color(1, r, g, b, a);  // set just one point to this colour.
-         D.map:color(r, g, b, a); // set all points to this colour.
+         if (D.map:clockwise()) then
+            print("lua::map is clockwise");
+         end
 
-         D.map:lighting(100, 200, 300, r, g, b, r, g, b);
+         D.map:color(255, 255, 255, 255); // set all points to this colour.
+         D.map:color(1, 255, 0, 255, 255);  // set just one point to this colour.
 
-         D.map:uv(1, 123.0, 456.0);
+         D.map:lighting(75, 75, 10, 255, 255, 255, 0, 255, 0);  // Ambient light and a 3D light source.
 
-         D.rect2:map_source(D.rect);
+         --// Toss it around.
+         D.map:rotate(45.0, 75, 75);
+         D.map:zoom(1.5, 1.5, 75, 75);
+         D.map:rotate3d(90.0, 180.0, 45.0, 75, 75, 0);
+         D.map:perspective(200, 200, 0, 20);
 
-         D.map:smooth();
-         D.map:alpha();
+         --// For image UV mapping.
+         D.map:uv(0, 0.0, 0.0);
+         D.map:uv(1, 50.0, 0.0);
+         D.map:uv(2, 50.0, 50.0);
+         D.map:uv(3, 0.0, 50.0);
 
-         if (D.map:clockwise()) then
-            print("lua::map is clockwise");
+         --// Actually apply the resulting transformations.
+         D.rect2:map(map);
+         D.rect2:map_enable(true);
+         if (D.rect2:map_enable()) then
+            print("lua::map enabled");
          end
 
+--//         D.rect2:map_source(D.rect);  --// Don't think this is actually implemented in evas.
+
 --//         D.map:dup();
 --//         D.map:size();  --// perhaps overide the # operator?  For now it's only gonna return 4 anyway.