1 Reply Latest reply on Nov 22, 2010 3:58 AM by Redade

    Drawing Lines after Rotation !



      i am trying to draw lines after rotate the image, my image is child of a canvas object and i m rotating the image. i ö adding the line on canvas object and it is not rotating. but when i want to draw lines after rotating the image (canvas is still same - no rotation) my line points are coming from different points. i think i need to transfrom my points from one coordinate system to an other coordinate system but i dont know how to do that in flex.

      Anybody can help ?



        • 1. Re: Drawing Lines after Rotation !
          Redade Level 1

          I added the picture of my problem and the code part. I hope somebody can help...


                      graphics.lineStyle(1, textFormat.color as uint,1);
                      var tpoint:Point;
                      var rpoint:Point;


                      var tpointNew:Point;
                      var rpointNew:Point;
                      var startXNew:Number = startX;
                      var startYNew:Number = startY;
                      var endXNew:Number = endX;
                      var endYNew:Number = endY;


                      var startX2:Number = startX;
                      var startY2:Number = startY;
                      var endX2:Number = endX;
                      var endY2:Number = endY;


                      var xComP1:Point = new Point(startX,startY);
                      var xComP2:Point = new Point(endX,startY);
                      var yComP1:Point = new Point(endX,startY);
                      var yComP2:Point = new Point(endX,endY);
                      var measureXComp:Number = Point.distance(xComP1,xComP2) * horpixelSpacing/zoomFactor;
                      var measureYComp:Number = Point.distance(yComP1,yComP2) * verpixelSpacing/zoomFactor;
                      var measure:Number = Math.sqrt(Math.pow(measureXComp,2)+Math.pow(measureYComp,2));


                      tpoint = new Point(startX,startY);
                      rpoint = new Point(endX,endY);           
                      tpointNew = new Point(startXNew,startYNew);
                      rpointNew = new Point(endXNew,endYNew);
                      uit.autoSize =  TextFieldAutoSize.LEFT;
                      uit.defaultTextFormat = textFormat;
                      uit.text = measure.toFixed(3).toString();
                      var textBitmapData:BitmapData =    ImageSnapshot.captureBitmapData(uit);
                      var sizeMatrix:Matrix = new Matrix();
                      var coef:Number = Math.min(uit.measuredWidth/textBitmapData.width,uit.measuredHeight/textBitmapData.height) ;
                      sizeMatrix.a = coef;
                      sizeMatrix.d = coef;
                      textBitmapData = ImageSnapshot.captureBitmapData(uit,sizeMatrix);
                      var sm:Matrix = new Matrix();
                      sm.tx = (tpointNew.x+rpointNew.x)/2;
                      sm.ty = (tpointNew.y+rpointNew.y)/2;
                      graphics.drawRect((tpointNew.x+rpointNew.x)/2,(tpointNew.y+rpointNew.y)/2,uit.measuredWid th,uit.measuredHeight);


          Thats all...