{"id":341,"date":"2009-07-10T05:00:50","date_gmt":"2009-07-10T12:00:50","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=1734"},"modified":"2009-07-10T05:00:50","modified_gmt":"2009-07-10T12:00:50","slug":"wireframe-plane-2d","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=341","title":{"rendered":"Wireframe Plane 2D"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nvar plane:Shape = Shape(addChild(new Shape()));\r\nplane.x = plane.y = 50;\r\n\r\nvar verts:Vector.&lt;Number&gt; = new Vector.&lt;Number&gt;();\r\nvar indices:Vector.&lt;int&gt; = new Vector.&lt;int&gt;();\r\nvar rows:int = 20;\r\nvar size:Number = rows + 1;\r\nvar vertNum:Number = size * size;\r\nvar polySize:Number = 20;\r\nvar vIndex:int = 0;\r\nfor (var i:Number = 0; i&lt;vertNum; i++){\r\n\tverts&#x5B;vIndex++] = i % size * polySize;\r\n\tverts&#x5B;vIndex++] = int(i \/ size) * polySize;\r\n\tif (i % size != rows){\r\n\t\t  indices.push(i, i+1, i+size, i+size, i+size+1, i+1);\r\n\t}\r\n}\r\n\r\n\/\/ render and show that the verts can be changed around\r\naddEventListener(Event.ENTER_FRAME, onLoop);\r\nfunction onLoop(evt:Event):void {\r\n\t\/\/ shake the verts\r\n\tfor (var i:int = 0; i&lt;verts.length; i++){\r\n\t\tverts&#x5B;i] += Math.random() - 0.5;\r\n\t}\r\n\twith(plane.graphics){\r\n\t\tclear();\r\n\t\tlineStyle(0,0);\r\n\t\tdrawTriangles(verts, indices);\r\n\t}\r\n}\r\n<\/pre>\n<p>This snippet shows a simple way to draw a 2D wireframe plane using drawTriangles(). To demonstrate the flexibility of the plane&#8230; the vertices are randomly shaken on enterframe.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>var plane:Shape = Shape(addChild(new Shape())); plane.x = plane.y = 50; var verts:Vector.&lt;Number&gt; = new Vector.&lt;Number&gt;(); var indices:Vector.&lt;int&gt; = new Vector.&lt;int&gt;(); var rows:int = 20; var size:Number = rows + 1; var vertNum:Number = size * size; var polySize:Number = 20; var vIndex:int = 0; for (var i:Number = 0; i&lt;vertNum; i++){ verts&#x5B;vIndex++] = i % [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33,79],"tags":[3,14,4],"class_list":["post-341","post","type-post","status-publish","format-standard","hentry","category-graphics","category-vector","tag-actionscript","tag-as3","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/341","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=341"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/341\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=341"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}