Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Shape's drawTriangle question..

Explorer ,
Jun 10, 2013 Jun 10, 2013

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:

affine_problem.JPG

What is wrong in my code?




TOPICS
ActionScript
265
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation