0 Replies Latest reply on Mar 19, 2012 5:50 AM by asharazeem

    Resizing the Path Data

    asharazeem Level 1

      Hi,

       

      I have a situation where in I want to scale a graphics based on path ,which can have data inputs to draw anything using the available values like lines and curves.

       

      I could scale the data uniformaly in x and y directions by scaling the numbers inside the the data

       

      eg:

      The value for data string in path can be like this:

       

      M162 18 162 94.5M53.999 94.5 53.999 18M134.999 103.5 134.999 90M80.999 90 80.999 103.5M0 108 26.999 63 0 18 53.999 18 53.999 4.50049C53.999 2.01416 57.0225 0 60.75 0L155.25 0C158.977 0 162 2.01416 162 4.50049L162 18 216 18 188.999 63 216 108 141.75

      108C138.022 108 134.999 105.986 134.999 103.5 134.999 101.014 138.022 99 141.75 99L155.25 99C158.977 99 162 96.9844 162 94.5 162 92.0137 158.977 90 155.25 90L60.75 90C57.0225 90 53.999 92.0137 53.999 94.5 53.999 96.9844 57.0225 99 60.75 99L74.249

      99C77.9775 99 80.999 101.014 80.999 103.5 80.999 105.986 77.9775 108 74.249 108L0 108Z

       

      Following is the code I used to resize the data uniformly

       

      private function scalePathData(pathData:String):String

                          {

                                    var pattern:RegExp = /([0-9\.]+)/g;

                                    var scaledPathData:String = pathData.replace(pattern, scalePathDataNumber);

                                    return scaledPathData;

                          }

       

                          private function scalePathDataNumber():String

                          {

                                    var scaleFactor:Number =_sizeIncreaseRatio ;

                                    var str:String = arguments[1];

                                    var number:Number = Number(str);

                                    number *= scaleFactor;

                                    return number.toString();

                          }

       

      Now I have to resize it independently in x and y directions.

      Any suggestions?