Skip to main content
Inspiring
June 10, 2013
Question

Shape's drawTriangle question..

  • June 10, 2013
  • 0 replies
  • 287 views

I have 200x200 image. Now I want to apply Affine Transformation on it like:

var src:Array = new Array();

var dst:Array = new Array();

src.push(new Point(0,0));

src.push(new Point(200,0));

src.push(new Point(200,200));

src.push(new Point(0,200));

dst.push(new Point(0,0));

dst.push(new Point(200,100));

dst.push(new Point(200,200));

dst.push(new Point(0,200));

Every vertices stays same except upper right one moving down by 100.


And I wrote transformation code like:

vertices = new Vector.<Number>();

indices = new Vector.<int>();

uvtData = new Vector.<Number>();

vertices.push(dst[0].x, dst[0].y,dst[1].x, dst[1].y,dst[2].x, dst[2].y,dst[3].x, dst[3].y );

indices.push(0,1,3, 1,2,3); uvtData.push(0,0, 1,0, 1,1, 0,1)

var shape:Shape = new Shape();

shape.graphics.beginBitmapFill(bitmap.bitmapData);

shape.graphics.drawTriangles(vertices, indices, uvtData);

shape.graphics.endFill();

bitmap.bitmapData.draw(shape);

(I have referred to flashandmath.com/advanced/p10triangles/method.html)

But the result I got looks like:

What is wrong in my code?




This topic has been closed for replies.