チェンジセット 2309

差分発生行の前後
無視リスト:
コミット日時:
2009/02/24 19:31:32 (3 年前)
コミッタ:
nutsu
ログメッセージ:

F5:SVGとか。途中だけどコミット

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • as3/Frocessing/changelog.txt

    r2219 r2309  
    11 
    22frocessing change log 
     3 
     42009-02-24      0.5.3   nutsu(face@nutsu.com) 
     5 
     6    * add     : add mouse events and properties. 
     7                add mouseClicked(),mouseMoved(),mousePressed(),mouseReleased() to F5MovieClip 
     8                                add pmouseX,pmouseY properties to F5MovieClip 
     9 
     10    * add     : add random seed API. 
     11                add class frocessing.math.MTRandom 
     12                                add API   frocessing.math.PerlinNoise#noiseSeed 
     13                                add API   frocessing.math.FMath#randomSeed 
     14                                add API   frocessing.display.F5MovieClip#noiseSeed,randomSeed 
     15 
     16    * add     : add string util methods. 
     17                                add API   frocessing.utils.FUtil#splitTokens 
     18                                add API   frocessing.utils.FUtil#trim 
     19 
     20    * add     : add round rect parameter. 
     21                to frocessing.core.F5Graphic#rect 
     22                to frocessing.core.F5MovieClip#rect 
     23 
     24    * add     : add shape and SVG API:(shape package is still in development) 
     25                update      frocessing.core.F5Graphic,F5Graphics2D,F5Graphics3D 
     26                add API     frocessing.display.F5MovieClip#shape 
     27                add package frocessing.shape.* 
     28                add class   frocessing.color.ColorKey 
     29 
    330 
    431 
    5322009-02-02      0.5.2   nutsu(face@nutsu.com) 
    633 
    7        * bug fix : [frocessing.core.GraphicsEx3D] 
    8                                fillColor is applied when not intended. 
     34    * bug fix : [frocessing.core.GraphicsEx3D] 
     35                fillColor is applied when not intended. 
    936 
    1037 
     
    12392009-02-02      0.5.1   nutsu(face@nutsu.com) 
    1340 
    14        * bug fix : [frocessing.color.ColorLeap] 
    15                                gradient() hsv mode dose not working properly. 
     41    * bug fix : [frocessing.color.ColorLeap] 
     42                gradient() hsv mode dose not working properly. 
    1643 
    17        * bug fix : [frocessing.core.F5Graphics] 
    18                                color() and __calColor() sometimes does not working properly when 32 bit color. 
     44    * bug fix : [frocessing.core.F5Graphics] 
     45                color() and __calColor() sometimes does not working properly when 32 bit color. 
    1946 
    2047 
     
    22492009-01-27      0.5.0   nutsu(face@nutsu.com) 
    2350 
    24        * Improved classes and structure. 
     51    * Improved classes and structure. 
    2552      pre version(0.3) is moved to branch. 
    2653 
  • as3/Frocessing/trunk/src/frocessing/bmp/FImageLoader.as

    r2180 r2309  
    3030        import flash.display.BitmapData; 
    3131        import flash.display.Loader; 
     32        import flash.net.URLRequest; 
    3233        import flash.events.Event; 
    33         import flash.geom.Point; 
    34         import flash.geom.Rectangle; 
    35         import flash.net.URLRequest; 
    3634         
    3735        /** 
    38         * ... 
     36        * Simple Image Loader 
     37        *  
    3938        * @author nutsu 
    4039        * @version 0.5 
     
    5352                        super( bitmapData ); 
    5453                        if ( _bitmapdata == null ) 
    55                                 _bitmapdata = new BitmapData( 4, 4, true, bgcolor );                            
     54                                _bitmapdata = new BitmapData( 4, 4, true, bgcolor ); 
    5655                          
    5756                        if ( loader != null ) 
     
    6160                         
    6261                        __complete = false; 
    63                         __loader.contentLoaderInfo.addEventListener( Event.COMPLETE, __onLoad ); 
     62                        __loader.contentLoaderInfo.addEventListener( Event.COMPLETE, __onLoad, false, int.MAX_VALUE ); 
    6463                        var request:URLRequest = new URLRequest(url); 
    6564                        __loader.load( request ); 
  • as3/Frocessing/trunk/src/frocessing/color/FColor.as

    r2180 r2309  
    334334                        { 
    335335                                _a = c2; 
    336                                 if ( c1 <= 0xff ) 
     336                                if ( uint(c1) <= 0xff ) 
    337337                                        gray( c1 ); 
    338338                                else 
     
    342342                        { 
    343343                                _a = 1.0; 
    344                                 if ( c1 <= 0xff ) 
     344                                if ( uint(c1) <= 0xff ) 
    345345                                        gray( c1 ); 
    346346                                else if ( c1 >>> 24 > 0 ) 
     
    541541                public static function GrayToValue( gray:uint, a:Number=0 ):uint 
    542542                { 
    543                         var g:uint = gray & 0xff
     543                        var g:uint = (gray>0xff) ? 255 : gray
    544544                        if ( a > 0 ) 
    545545                                return ( Math.round( a * 0xff ) & 0xff ) << 24 | g << 16 | g << 8 | g; 
  • as3/Frocessing/trunk/src/frocessing/core/F5Draw.as

    r2180 r2309  
    2727package frocessing.core  
    2828{ 
     29        import frocessing.f5internal; 
     30        use namespace f5internal; 
    2931         
    3032        /** 
     
    200202                public function drawCircle( x:Number, y:Number, radius:Number ):void 
    201203                { 
    202                         drawArc( x, y, radius, radius, 0.0, TWO_PI ); 
     204                        fg.f5internal::__ellipse( x, y, radius, radius ); 
    203205                } 
    204206                 
     
    214216                        width  *= 0.5; 
    215217                        height *= 0.5; 
    216                         drawArc( x+width, y+height, width, height, 0.0, TWO_PI ); 
     218                        fg.f5internal::__ellipse( x+width, y+height, width, height ); 
    217219                } 
    218220                 
     
    255257                                ry = ellipseHeight*0.5; 
    256258                         
    257                         fg.moveTo( x + rx, y ); 
    258                         fg.lineTo( x1 - rx, y );   fg.__arc( x1 - rx, y + ry, rx, ry, -HALF_PI, 0.0 ); 
    259                         fg.lineTo( x1, y1 - ry );  fg.__arc( x1 - rx, y1 - ry, rx, ry, 0.0, HALF_PI ); 
    260                         fg.lineTo( x + rx, y1 );   fg.__arc( x + rx, y1 - ry, rx, ry, HALF_PI, PI ); 
    261                         fg.lineTo( x, y + ry );    fg.__arc( x + rx, y + ry, rx, ry, -PI, -HALF_PI ); 
     259                        fg.f5internal::__roundrect( x, y, x1, y1, rx, ry ); 
    262260                } 
    263261                 
  • as3/Frocessing/trunk/src/frocessing/core/F5Graphics.as

    r2215 r2309  
    4242        import frocessing.text.PFontLoader; 
    4343        import frocessing.bmp.FImageLoader; 
     44        import frocessing.shape.FShapeSVGLoader; 
     45         
     46        import frocessing.f5internal; 
     47        use namespace f5internal; 
    4448         
    4549        /** 
     
    4751         *  
    4852         * @author nutsu 
    49          * @version 0.5 
     53         * @version 0.5.3 
    5054         */ 
    5155        public class F5Graphics  
     
    480484                        } 
    481485                } 
    482                  
    483486                 
    484487                /** 
     
    599602                 
    600603                /** 
     604                 * @private 
     605                 */ 
     606                f5internal function __ellipse( x:Number, y:Number, rx:Number, ry:Number ):void 
     607                { 
     608                        var _P:Number = 0.7071067811865476;    //Math.cos( Math.PI / 4 ) 
     609                        var _T:Number = 0.41421356237309503;   //Math.tan( Math.PI / 8 ) 
     610                        moveTo( x + rx, y ); 
     611                        curveTo( x + rx     , y + ry * _T, x + rx * _P, y + ry * _P ); 
     612                        curveTo( x + rx * _T, y + ry     , x          , y + ry ); 
     613                        curveTo( x - rx * _T, y + ry     , x - rx * _P, y + ry * _P ); 
     614                        curveTo( x - rx     , y + ry * _T, x - rx     , y ); 
     615                        curveTo( x - rx     , y - ry * _T, x - rx * _P, y - ry * _P ); 
     616                        curveTo( x - rx * _T, y - ry     , x          , y - ry ); 
     617                        curveTo( x + rx * _T, y - ry     , x + rx * _P, y - ry * _P ); 
     618                        curveTo( x + rx     , y - ry * _T, x + rx     , y ); 
     619                } 
     620                 
     621                /** 
     622                 * @private 
     623                 */ 
     624                f5internal function __roundrect( x0:Number, y0:Number, x1:Number, y1:Number, rx:Number, ry:Number ):void 
     625                { 
     626                        var _P:Number = 1 - 0.7071067811865476;    //Math.cos( Math.PI / 4 ) 
     627                        var _T:Number = 1 - 0.41421356237309503;   //Math.tan( Math.PI / 8 ) 
     628                         
     629                        moveTo( x0 + rx, y0 ); 
     630                        lineTo( x1 - rx, y0 );  curveTo( x1 - rx * _T, y0          , x1 - rx * _P, y0 + ry * _P ); 
     631                                                                        curveTo( x1          , y0 + ry * _T, x1          , y0 + ry ); 
     632                        lineTo( x1, y1 - ry );  curveTo( x1          , y1 - ry * _T, x1 - rx * _P, y1 - ry * _P ); 
     633                                                                        curveTo( x1 - rx * _T, y1          , x1 - rx     , y1 ); 
     634                        lineTo( x0 + rx, y1 );  curveTo( x0 + rx * _T, y1          , x0 + rx * _P, y1 - ry * _P ); 
     635                                                                        curveTo( x0          , y1 - ry * _T, x0          , y1 - ry ); 
     636                        lineTo( x0, y0 + ry );  curveTo( x0          , y0 + ry * _T, x0 + rx * _P, y0 + ry * _P ); 
     637                                                                        curveTo( x0 + rx * _T, y0          , x0 + rx     , y0 ); 
     638                         
     639                        /* 
     640                        moveTo( x0 + rx, y0 ); 
     641                        lineTo( x1 - rx, y0 );  __arc( x1 - rx, y0 + ry, rx, ry, -HALF_PI, 0.0 ); 
     642                        lineTo( x1, y1 - ry );  __arc( x1 - rx, y1 - ry, rx, ry, 0.0, HALF_PI ); 
     643                        lineTo( x0 + rx, y1 );  __arc( x0 + rx, y1 - ry, rx, ry, HALF_PI, PI ); 
     644                        lineTo( x0, y0 + ry );  __arc( x0 + rx, y0 + ry, rx, ry, -PI, -HALF_PI ); 
     645                        */ 
     646                } 
     647                 
     648                //------------------------------------------------------------------------------------------------------------------- 2D Primitives 
     649                 
     650                /** 
    601651                 * 点を描画します.点を描画する色は、線の色が適用されます. 
    602652                 */ 
     
    605655                        gc.point( x, y ); 
    606656                } 
    607                  
    608                 //------------------------------------------------------------------------------------------------------------------- 2D Primitives 
    609657                 
    610658                /** 
     
    671719                { 
    672720                        gc.applyFill(); 
    673                         __drawArc( x, y, radius, radius, 0, TWO_PI ); 
     721                        __ellipse( x, y, radius, radius ); 
    674722                        gc.endFill(); 
    675723                } 
     
    718766                        } 
    719767                        gc.applyFill(); 
    720                         __drawArc( x0, y0, w, h, 0, TWO_PI ); 
     768                        __ellipse( x0, y0, w, h ); 
    721769                        gc.endFill(); 
    722770                } 
     
    734782                 * <li>mode CORNERS : rect( left, top, right, bottom )</li> 
    735783                 * <li>mode RADIUS  : rect( center x, center y, radius x, radius y )</li> 
    736                  * <li>mode RADIUS  : rect( center x, center y, width, height )</li> 
     784                 * <li>mode CENTER  : rect( center x, center y, width, height )</li> 
    737785                 * </ul> 
    738786                 */ 
    739                 public function rect( x0:Number, y0:Number, x1:Number, y1:Number ):void 
    740                 { 
    741                         var rx:Number; 
    742                         var ry:Number; 
     787                public function rect( x0:Number, y0:Number, x1:Number, y1:Number, rx:Number=0, ry:Number=0 ):void 
     788                { 
     789                        var hw:Number; 
     790                        var hh:Number; 
    743791                        switch( _rect_mode ) 
    744792                        { 
    745793                                case CORNERS: 
     794                                        hw = (x1 - x0) * 0.5; 
     795                                        hh = (y1 - y0) * 0.5; 
    746796                                        break; 
    747797                                case CORNER: 
     
    750800                                        break; 
    751801                                case RADIUS: 
    752                                         rx = x1; 
    753                                         ry = y1; 
    754                                         x1 = x0 + rx
    755                                         y1 = y0 + ry
    756                                         x0 -= rx
    757                                         y0 -= ry
     802                                        hw = x1; 
     803                                        hh = y1; 
     804                                        x1 = x0 + hw
     805                                        y1 = y0 + hh
     806                                        x0 -= hw
     807                                        y0 -= hh
    758808                                        break; 
    759809                                case CENTER: 
    760                                         rx = x1*0.5; 
    761                                         ry = y1*0.5; 
    762                                         x1 = x0 + rx
    763                                         y1 = y0 + ry
    764                                         x0 -= rx
    765                                         y0 -= ry
     810                                        hw = x1*0.5; 
     811                                        hh = y1*0.5; 
     812                                        x1 = x0 + hw
     813                                        y1 = y0 + hh
     814                                        x0 -= hw
     815                                        y0 -= hh
    766816                                        break; 
    767817                        } 
    768                         quad( x0, y0, x1, y0, x1, y1, x0, y1 ); 
     818                         
     819                        gc.applyFill(); 
     820                        if ( rx <= 0 || ry <= 0 ) 
     821                        { 
     822                                moveTo( x0, y0 ); 
     823                                lineTo( x1, y0 ); 
     824                                lineTo( x1, y1 ); 
     825                                lineTo( x0, y1 ); 
     826                                closePath(); 
     827                        } 
     828                        else 
     829                        { 
     830                                if( rx>hw ) 
     831                                        rx = hw; 
     832                                 
     833                                if( ry>hh ) 
     834                                        ry = hh; 
     835                                 
     836                                __roundrect( x0, y0, x1, y1, rx, ry ); 
     837                        } 
     838                        gc.endFill(); 
    769839                } 
    770840                 
     
    12001270                 
    12011271                /** 
    1202                  * not implemetned 
    1203                  */ 
    1204                 public function shape( s:IFShape, x:Number, y:Number, w:Number = NaN, h:Number = NaN ):void 
    1205                 { 
    1206                         ; 
     1272                 *  
     1273                 * paratmeters(x,y,w,h) is applyed in F5Graphics2D or F5Graphics3D 
     1274                 */ 
     1275                public function shape( s:IFShape, x:Number=0, y:Number=0, w:Number = NaN, h:Number = NaN ):void 
     1276                { 
     1277                        //pushStyle(); 
     1278                        //rectMode( CORNER ); 
     1279                        //ellipseMode( CORNER ); 
     1280                        s.draw(this); 
     1281                        //pushStyle(); 
     1282                } 
     1283                 
     1284                /** 
     1285                 * SVG Shape を読み込みます. 
     1286                 *  
     1287                 * <listing> 
     1288                 * var f:FShapeSVGLoader = loadShape("sample.svg"); 
     1289                 *  
     1290                 * if( f.complete ) 
     1291                 *   shape( f ); 
     1292                 * </listing> 
     1293                 *  
     1294                 * @param       url 
     1295                 * @param       loader 
     1296                 */ 
     1297                public function loadShape( url:String, loader:URLLoader = null ):FShapeSVGLoader 
     1298                { 
     1299                        return new FShapeSVGLoader( url, loader ); 
    12071300                } 
    12081301                 
     
    12481341                public function image( img:BitmapData, x:Number, y:Number, w:Number = NaN, h:Number = NaN ):void 
    12491342                { 
    1250                         if ( isNaN(w) || isNaN(h) ) 
    1251                         { 
    1252                                 w = img.width; 
    1253                                 h = img.height; 
    1254                                 if( _image_mode==RADIUS || _image_mode==CENTER ) 
    1255                                 { 
    1256                                         x -= w * 0.5; 
    1257                                         y -= h * 0.5; 
    1258                                 } 
    1259                         } 
    1260                         else 
     1343                        if ( w>0 && h>0 ) 
    12611344                        { 
    12621345                                switch( _image_mode ) 
     
    12781361                                } 
    12791362                        } 
     1363                        else 
     1364                        { 
     1365                                w = img.width; 
     1366                                h = img.height; 
     1367                                if( _image_mode==RADIUS || _image_mode==CENTER ) 
     1368                                { 
     1369                                        x -= w * 0.5; 
     1370                                        y -= h * 0.5; 
     1371                                } 
     1372                        } 
    12801373                        _image( img, x, y, w, h ); 
    12811374                } 
     
    12841377                 * @private 
    12851378                 */ 
    1286                 internal function _image( img:BitmapData, x:Number, y:Number, w:Number, h:Number, z:Number=0 ):void 
     1379                f5internal function _image( img:BitmapData, x:Number, y:Number, w:Number, h:Number, z:Number=0 ):void 
    12871380                { 
    12881381                        if ( _tint_do ) 
     
    20012094                                } 
    20022095                        } 
     2096                } 
     2097                 
     2098                 
     2099                //------------------------------------------------------------------------------------------------------------------- 
     2100                // Transform 
     2101                //------------------------------------------------------------------------------------------------------------------- 
     2102                 
     2103                /** 
     2104                 * implements in F5Graphics2D,F5Graphics3D 
     2105                 * @private 
     2106                 */ 
     2107                public function pushMatrix():void 
     2108                { 
     2109                        ; 
     2110                } 
     2111                 
     2112                /** 
     2113                 * implements in F5Graphics2D,F5Graphics3D 
     2114                 * @private 
     2115                 */ 
     2116                public function popMatrix():void 
     2117                { 
     2118                        ; 
     2119                } 
     2120                 
     2121                /** 
     2122                 * implements in F5Graphics2D,F5Graphics3D 
     2123                 * @private 
     2124                 */ 
     2125                public function applyMatrix2D( mat:Matrix ):void 
     2126                { 
     2127                        ; 
    20032128                } 
    20042129                 
  • as3/Frocessing/trunk/src/frocessing/core/F5Graphics2D.as

    r2181 r2309  
    3636        import flash.geom.Matrix; 
    3737        import frocessing.geom.FMatrix2D; 
     38        import frocessing.shape.IFShape; 
     39         
     40        import frocessing.f5internal; 
     41        use namespace f5internal; 
    3842         
    3943        /** 
     
    4145        *  
    4246        * @author nutsu 
    43         * @version 0.5 
     47        * @version 0.5.3 
    4448        */ 
    4549        public class F5Graphics2D extends F5Graphics { 
     
    97101                 * 現在の 変換 Matrix を一時的に保持します. 
    98102                 */ 
    99                 public function pushMatrix():void 
     103                override public function pushMatrix():void 
    100104                { 
    101105                        __matrix_tmp.push( new MatrixParam( a, b, c, d, tx, ty ) ); 
     
    105109                 * 前回、pushMatrix() で保持した 変換 Matrix を復元します. 
    106110                 */ 
    107                 public function popMatrix():void 
     111                override public function popMatrix():void 
    108112                { 
    109113                        __applyMatrixParam( __matrix_tmp.pop() ); 
     
    188192                { 
    189193                        __matrix.prependMatrix( a_, b_, c_, d_, tx_, ty_ ); 
     194                        update_transform(); 
     195                } 
     196                 
     197                /** 
     198                 * FMatrix2Dの変換を適用します 
     199                 */ 
     200                override public function applyMatrix2D( mat:Matrix ):void 
     201                { 
     202                        __matrix.prepend( mat ); 
    190203                        update_transform(); 
    191204                } 
     
    377390                 
    378391                //------------------------------------------------------------------------------------------------------------------- 
     392                // Shape 
     393                //------------------------------------------------------------------------------------------------------------------- 
     394                 
     395                /** 
     396                 *  
     397                 */ 
     398                override public function shape( s:IFShape, x:Number=NaN, y:Number=NaN, w:Number = NaN, h:Number = NaN ):void 
     399                { 
     400                        //pushStyle(); 
     401                        //rectMode( CORNER ); 
     402                        //ellipseMode( CORNER ); 
     403                        if ( !isNaN(x * y) ) 
     404                        { 
     405                                pushMatrix(); 
     406                                if ( w>0 && h>0 ) 
     407                                { 
     408                                        if( _shape_mode==CENTER ) 
     409                                        { 
     410                                                x -= w * 0.5; 
     411                                                y -= h * 0.5; 
     412                                        } 
     413                                        else if ( _shape_mode == CORNERS ) 
     414                                        { 
     415                                                w -= x; 
     416                                                h -= y; 
     417                                        } 
     418                                        translate( x, y ); 
     419                                        scale( w / s.width, h / s.height ); 
     420                                } 
     421                                else if( _shape_mode==CENTER ) 
     422                                { 
     423                                        x -= s.width * 0.5; 
     424                                        y -= s.height * 0.5; 
     425                                        translate( x, y ); 
     426                                } 
     427                                else 
     428                                { 
     429                                        translate( x, y ); 
     430                                } 
     431                                translate( -s.left, -s.top ); 
     432                                s.draw(this); 
     433                                popMatrix(); 
     434                        } 
     435                        else 
     436                        { 
     437                                s.draw(this); 
     438                        } 
     439                        //popStyle(); 
     440                } 
     441                 
     442                //------------------------------------------------------------------------------------------------------------------- 
    379443                // IMAGE 
    380444                //------------------------------------------------------------------------------------------------------------------- 
     
    383447                 * @private 
    384448                 */ 
    385                 override internal function _image( img:BitmapData, x:Number, y:Number, w:Number, h:Number, z:Number=0 ):void 
     449                override f5internal function _image( img:BitmapData, x:Number, y:Number, w:Number, h:Number, z:Number=0 ):void 
    386450                { 
    387451                        if ( _tint_do ) 
     
    405469                                                                                   focalPointRatio:Number = 0.0 ):void 
    406470                { 
    407                         if ( matrix_ ) 
    408                         { 
    409                                 matrix_.concat( __matrix ); 
     471                        if ( transformFillMatrix ) 
     472                        { 
     473                                if ( matrix_!=null ) 
     474                                        gc.lineGradientStyle(type, colors, alphas, ratios, __matrix.preProduct(matrix_), spreadMethod, interpolationMethod, focalPointRatio); 
     475                                else 
     476                                        gc.lineGradientStyle(type, colors, alphas, ratios, __matrix, spreadMethod, interpolationMethod, focalPointRatio); 
     477                        } 
     478                        else 
     479                        { 
    410480                                gc.lineGradientStyle(type, colors, alphas, ratios, matrix_, spreadMethod, interpolationMethod, focalPointRatio); 
    411481                        } 
    412                         else 
    413                         { 
    414                                 gc.lineGradientStyle(type, colors, alphas, ratios, __matrix, spreadMethod, interpolationMethod, focalPointRatio); 
    415                         } 
    416                          
    417482                } 
    418483                 
     
    424489                        if ( transformFillMatrix ) 
    425490                        { 
    426                                 if ( matrix_
     491                                if ( matrix_!=null
    427492                                        gc.beginBitmapFill( bitmap, __matrix.preProduct( matrix_ ), repeat, smooth ); 
    428493                                else 
     
    443508                        if ( transformFillMatrix ) 
    444509                        { 
    445                                 if ( matrix_
     510                                if ( matrix_!=null
    446511                                        gc.beginGradientFill( type, color, alphas, ratios, __matrix.preProduct( matrix_ ), spreadMethod, interpolationMethod, focalPointRation ); 
    447512                                else 
  • as3/Frocessing/trunk/src/frocessing/core/F5Graphics3D.as

    r2216 r2309  
    4141        import frocessing.f3d.F3DCamera; 
    4242        import frocessing.f3d.F3DObject; 
     43        import frocessing.shape.IFShape; 
    4344         
    4445        import frocessing.f5internal; 
     
    4950        *  
    5051        * @author nutsu 
    51         * @version 0.5 
     52        * @version 0.5.3 
    5253        */ 
    5354        public class F5Graphics3D extends F5Graphics 
     
    154155                } 
    155156                 
     157                /** 
     158                 * @private 
     159                 */ 
    156160                override protected function __initGC(graphics:Graphics):void  
    157161                { 
     
    225229                 * 現在の 変換 Matrix を一時的に保持します. 
    226230                 */ 
    227                 public function pushMatrix():void 
     231                override public function pushMatrix():void 
    228232                { 
    229233                        __matrix_tmp.push( new MatrixParam3D(m11,m12,m13,m21,m22,m23,m31,m32,m33,tx,ty,tz) ); 
     
    233237                 * 前回、pushMatrix() で保持した 変換 Matrix を復元します. 
    234238                 */ 
    235                 public function popMatrix():void 
     239                override public function popMatrix():void 
    236240                { 
    237241                        __applyMatrixParam( __matrix_tmp.pop() ); 
     
    372376                { 
    373377                        __matrix.prependMatrix( m11_,m12_,m13_, m21_,m22_,m23_, m31_,m32_,m33_, m41_,m42_,m43_); 
     378                        update_transform(); 
     379                } 
     380                 
     381                /** 
     382                 * Matrixの変換を適用します 
     383                 */ 
     384                override public function applyMatrix2D( mat:Matrix ):void 
     385                { 
     386                        __matrix.prependMatrix( mat.a,mat.b,0, mat.c,mat.d,0, 0,0,1, mat.tx,mat.ty,0); 
    374387                        update_transform(); 
    375388                } 
     
    12521265                 
    12531266                //------------------------------------------------------------------------------------------------------------------- 
     1267                // Shape 
     1268                //------------------------------------------------------------------------------------------------------------------- 
     1269                 
     1270                /** 
     1271                 *  
     1272                 */ 
     1273                override public function shape(s:IFShape, x:Number=NaN, y:Number=NaN, w:Number = NaN, h:Number = NaN ):void 
     1274                { 
     1275                        //pushStyle(); 
     1276                        //rectMode( CORNER ); 
     1277                        //ellipseMode( CORNER ); 
     1278                        if ( !isNaN(x * y) ) 
     1279                        { 
     1280                                pushMatrix(); 
     1281                                if ( w>0 && h>0 ) 
     1282                                { 
     1283                                        if( _shape_mode==CENTER ) 
     1284                                        { 
     1285                                                x -= w * 0.5; 
     1286                                                y -= h * 0.5; 
     1287                                        } 
     1288                                        else if ( _shape_mode == CORNERS ) 
     1289                                        { 
     1290                                                w -= x; 
     1291                                                h -= y; 
     1292                                        } 
     1293                                        translate( x, y ); 
     1294                                        scale( w / s.width, h / s.height ); 
     1295                                } 
     1296                                else if( _shape_mode==CENTER ) 
     1297                                { 
     1298                                        x -= s.width * 0.5; 
     1299                                        y -= s.height * 0.5; 
     1300                                        translate( x, y ); 
     1301                                } 
     1302                                else 
     1303                                { 
     1304                                        translate( x, y ); 
     1305                                } 
     1306                                translate( -s.left, -s.top ); 
     1307                                s.draw(this); 
     1308                                popMatrix(); 
     1309                        } 
     1310                        else 
     1311                        { 
     1312                                s.draw(this); 
     1313                        } 
     1314                        //popStyle(); 
     1315                } 
     1316                 
     1317                //------------------------------------------------------------------------------------------------------------------- 
    12541318                // IMAGE 
    12551319                //------------------------------------------------------------------------------------------------------------------- 
     
    13401404                 * @private 
    13411405                 */ 
    1342                 override internal function _image(img:BitmapData, x1:Number, y1:Number, w:Number, h:Number, z:Number=0):void  
     1406                override f5internal function _image(img:BitmapData, x1:Number, y1:Number, w:Number, h:Number, z:Number=0):void  
    13431407                { 
    13441408                        if ( _tint_do ) 
     
    15191583                        { 
    15201584                                update_fill_matrix(); 
    1521                                 if ( matrix_
     1585                                if ( matrix_!=null
    15221586                                        fill_matrix.prepend( matrix_ ); 
    15231587                                gc3d.beginBitmapFill( bitmap_, fill_matrix, repeat_, smooth_ ); 
     
    15371601                        { 
    15381602                                update_fill_matrix(); 
    1539                                 if ( matrix_
     1603                                if ( matrix_!=null
    15401604                                        fill_matrix.prepend( matrix_ ); 
    15411605                                else 
     
    15631627                        { 
    15641628                                var znear:Number = _cameraObject.zNear; 
    1565                                 x0 *= znear / getZ( 0, 0, 0 ); 
    1566                                 y0 *= znear / getZ( 0, 0, 0 ); 
    1567                                 x1 *= znear / getZ( 1, 0, 0 ); 
    1568                                 y1 *= znear / getZ( 1, 0, 0 ); 
    1569                                 x2 *= znear / getZ( 0, 1, 0 ); 
    1570                                 y2 *= znear / getZ( 0, 1, 0 ); 
     1629                                var z0:Number = znear/getZ( 0, 0, 0 ); 
     1630                                var z1:Number = znear/getZ( 1, 0, 0 ); 
     1631                                var z2:Number = znear/getZ( 0, 1, 0 ); 
     1632                                x0 *= z0; 
     1633                                y0 *= z0; 
     1634                                x1 *= z1; 
     1635                                y1 *= z1; 
     1636                                x2 *= z2; 
     1637                                y2 *= z2; 
    15711638                        } 
    15721639                        fill_matrix.setMatrix( x1-x0, y1-y0, x2-x0, y2-y0, x0+half_width, y0+half_height ); 
  • as3/Frocessing/trunk/src/frocessing/core/F5Typographics.as

    r2180 r2309  
    3636        import frocessing.text.PFont; 
    3737        import frocessing.text.FFont; 
     38         
     39        import frocessing.f5internal; 
     40        use namespace f5internal; 
    3841         
    3942        /** 
     
    141144                        var h1:Number = high * _size; 
    142145                         
    143                         _fg._image( img, x1, y1, w1, h1, _z ); 
     146                        _fg.f5internal::_image( img, x1, y1, w1, h1, _z ); 
    144147                } 
    145148                 
  • as3/Frocessing/trunk/src/frocessing/core/GraphicsEx.as

    r2180 r2309  
    3232        import frocessing.bmp.FBitmapData; 
    3333        import frocessing.geom.FMatrix2D; 
     34        import frocessing.geom.FGradientMatrix; 
    3435         
    3536        /** 
     
    3738        *  
    3839        * @author nutsu 
    39         * @version 0.5 
     40        * @version 0.5.3 
    4041        */ 
    4142        public class GraphicsEx 
     
    156157                 * @private 
    157158                 */ 
    158                 internal var default_gradient_matrix:FMatrix2D
     159                internal var default_gradient_matrix:Matrix
    159160                 
    160161                /** 
     
    167168                        gc = graphics; 
    168169                        __matrix = new FMatrix2D(); 
    169                         default_gradient_matrix = new FMatrix2D(); 
    170                         default_gradient_matrix.createGradientBox( 200, 200, 0, -100, -100 ); 
     170                        default_gradient_matrix = FGradientMatrix.defaultGradient(); 
    171171                } 
    172172                 
     
    225225                        __x = anchorX; 
    226226                        __y = anchorY; 
     227                         
     228                        /* 
     229                        var k:Number = 1.0/bezierDetail; 
     230                        var t:Number = 0; 
     231                        var tp:Number; 
     232                        for ( var i:int = 1; i <= bezierDetail; i++ ) 
     233                        { 
     234                                t += k; 
     235                                tp = 1.0-t; 
     236                                gc.lineTo( __x*tp*tp + 2*controlX*t*tp + anchorX*t*t,  
     237                                                        __y*tp*tp + 2*controlY*t*tp + anchorY*t*t ); 
     238                        } 
     239                        __x = anchorX; 
     240                        __y = anchorY; 
     241                        */ 
    227242                } 
    228243                 
  • as3/Frocessing/trunk/src/frocessing/display/F5MovieClip.as

    r2180 r2309  
    3737        import flash.display.MovieClip; 
    3838        import flash.display.BitmapData; 
     39        import flash.events.MouseEvent; 
    3940        import flash.geom.Matrix; 
    4041        import flash.events.Event; 
     
    5455        import frocessing.utils.FUtil; 
    5556        import frocessing.bmp.FImageLoader; 
     57        import frocessing.shape.IFShape; 
     58        import frocessing.shape.FShapeSVGLoader; 
    5659         
    5760        /** 
    5861        * F5MovieClip 
    5962        * @author nutsu 
    60         * @version 0.5 
     63        * @version 0.5.3 
    6164        *  
    6265        * @see frocessing.core.F5Graphics 
     
    130133                private var __loop:Boolean; 
    131134                 
    132                 // setting functio 
     135                // setting function 
    133136                private var __draw:Function; 
    134137                private var __setup:Function; 
     138                private var __mouseClicked:Function; 
     139                private var __mouseMoved:Function; 
     140                private var __mousePressed:Function; 
     141                private var __mouseReleased:Function; 
     142                 
     143                //pre mouse 
     144                private var __pmouseX:Number; 
     145                private var __pmouseY:Number; 
    135146                 
    136147                // noise 
     
    144155                        super(); 
    145156                         
     157                        __pmouseX = __pmouseY = 0; 
     158                         
    146159                        //check setup() and draw() 
    147                         __setup = __getfunction("setup"); 
    148                         __draw  = __getfunction("draw"); 
    149                         __loop  = false; 
     160                        __setup         = __getfunction("setup"); 
     161                        __draw          = __getfunction("draw"); 
     162                        __loop          = false; 
     163                        __mouseClicked  = __getfunction("mouseClicked"); 
     164                        __mouseMoved    = __getfunction("mouseMoved"); 
     165                        __mousePressed  = __getfunction("mousePressed"); 
     166                        __mouseReleased = __getfunction("mouseReleased"); 
    150167                         
    151168                        //init perlin noise 
     
    226243                                __setup.apply(this,null); 
    227244                         
     245                        //TODO:非同期処理待ちするですか 
     246                         
     247                        //mouseEvent 
     248                        if ( stage != null ) 
     249                        { 
     250                                if ( __mouseClicked != null  ) stage.addEventListener( MouseEvent.CLICK, _mouseClicked ); 
     251                                if ( __mouseMoved != null    ) stage.addEventListener( MouseEvent.MOUSE_MOVE, _mouseMoved ); 
     252                                if ( __mousePressed != null  ) stage.addEventListener( MouseEvent.MOUSE_DOWN, _mousePressed ); 
     253                                if ( __mouseReleased != null ) stage.addEventListener( MouseEvent.MOUSE_UP, _mouseReleased ); 
     254                        } 
     255                         
    228256                        //draw 
    229257                        loop(); 
     
    240268                        __draw(); 
    241269                        __fg.endDraw(); 
     270                         
     271                        //exit_frame? 
     272                        __pmouseX = mouseX; 
     273                        __pmouseY = mouseY; 
    242274                } 
    243275                 
     
    258290                public function loop():void  
    259291                { 
    260                         if ( __loop == false
     292                        if ( __loop == false && __draw != null
    261293                        { 
    262                                 if ( __draw != null ) 
    263                                 { 
    264                                         addEventListener( Event.ENTER_FRAME, __on_enter_frame ); 
    265                                         __loop = true; 
    266                                 } 
     294                                addEventListener( Event.ENTER_FRAME, __on_enter_frame ); 
     295                                __loop = true; 
     296                                __pmouseX = mouseX; 
     297                                __pmouseY = mouseY; 
    267298                        } 
    268299                } 
     
    279310                        } 
    280311                } 
     312                 
     313                private function _mouseClicked( e:MouseEvent ):void{  __mouseClicked();  } 
     314                private function _mouseMoved( e:MouseEvent ):void{    __mouseMoved();    } 
     315                private function _mousePressed( e:MouseEvent ):void{  __mousePressed();  } 
     316                private function _mouseReleased( e:MouseEvent ):void{ __mouseReleased(); } 
     317                 
     318                public function get pmouseX():Number { return __pmouseX; } 
     319                public function get pmouseY():Number { return __pmouseY; } 
    281320                 
    282321                //------------------------------------------------------------------------------------------------------------------- 
     
    501540                        __fg.ellipse( x0, y0, x1, y1); 
    502541                } 
    503                 public function rect( x:Number, y:Number, x1:Number, y1:Number ):void{ 
    504                         __fg.rect( x, y, x1, y1 ); 
     542                public function rect( x:Number, y:Number, x1:Number, y1:Number, rx:Number=0, ry:Number=0 ):void{ 
     543                        __fg.rect( x, y, x1, y1, rx, ry ); 
    505544                } 
    506545                 
     
    598637                public function moveToLast():void { 
    599638                        __fg.moveToLast(); 
     639                } 
     640                 
     641                //------------------------------------------------------------------------------------------------------------------- 
     642                // Shape 
     643                //------------------------------------------------------------------------------------------------------------------- 
     644                 
     645                /** 
     646                 * paratmeters(x,y,w,h) is applyed in F5MovieClip2D or F5MovieClip3D 
     647                 */ 
     648                public function shape( s:IFShape, x:Number=NaN, y:Number=NaN, w:Number = NaN, h:Number = NaN ):void { 
     649                        __fg.shape( s, x, y, w, h ); 
     650                } 
     651                 
     652                public function loadShape( url:String, loader:URLLoader = null ):FShapeSVGLoader{ 
     653                        return __fg.loadShape( url, loader ); 
    600654                } 
    601655                 
     
    770824                /** 
    771825                 * @see frocessing.math.FMath 
     826                 * @see frocessing.math.MTRandom 
    772827                 */ 
    773828                public function random( high:Number, low:Number = 0 ):Number{ 
     
    776831                 
    777832                /** 
    778                  *  
     833                 * @see frocessing.math.FMath 
     834                 * @see frocessing.math.MTRandom 
     835                 */ 
     836                public function randomSeed( seed:uint ):void{ 
     837                        FMath.randomSeed( seed ); 
     838                } 
     839                 
     840                /** 
     841                 * note that fallout value greater than 0.5 might result in greater than 1.0 values returned by noise(). 
    779842                 * @param       lod 
    780843                 * @param       falloff 
    781844                 * @see         frocessing.math.PerlinNoise 
    782845                 */ 
    783                 public function noiseDetail( lod:int, falloff:Number = 0):void{ 
     846                public function noiseDetail( lod:uint, falloff:Number = 0):void{ 
    784847                        __perlin_noise.noiseDetail( lod, falloff ); 
    785848                } 
     
    791854                public function noise( x:Number, y:Number = 0.0, z:Number = 0.0 ):Number{ 
    792855                        return __perlin_noise.noise( x, y, z ); 
     856                } 
     857                 
     858                /** 
     859                 *  
     860                 * @see frocessing.math.PerlinNoise 
     861                 */ 
     862                public function noiseSeed( seed:uint ):void{ 
     863                        __perlin_noise.noiseSeed( seed ); 
    793864                } 
    794865                 
  • as3/Frocessing/trunk/src/frocessing/display/F5MovieClip2DBmp.as

    r2180 r2309  
    4040        * ... 
    4141        * @author nutsu 
    42         * @version 0.5 
     42        * @version 0.5.3 
    4343        *  
    4444        * @see frocessing.core.F5BitmapData2D 
     
    100100                } 
    101101                 
     102                public function get bmpfg():F5BitmapData2D 
     103                { 
     104                        return F5BitmapData2D(fg); 
     105                } 
    102106        } 
    103107         
  • as3/Frocessing/trunk/src/frocessing/display/F5MovieClip3DBmp.as

    r2180 r2309  
    4040        * ... 
    4141        * @author nutsu 
    42         * @version 0.5 
     42        * @version 0.5.3 
    4343        *  
    4444        * @see frocessing.core.F5BitmapData3D 
     
    9999                        return F5BitmapData3D(fg).bitmapData; 
    100100                } 
     101                 
     102                public function get bmpfg():F5BitmapData3D 
     103                { 
     104                        return F5BitmapData3D(fg); 
     105                } 
    101106        } 
    102107         
  • as3/Frocessing/trunk/src/frocessing/geom/FMatrix2D.as

    r2180 r2309  
    3434        *  
    3535        * @author nutsu 
    36         * @version 0.5 
     36        * @version 0.5.3 
    3737        */ 
    3838        public class FMatrix2D extends Matrix{ 
     
    8383                 
    8484                /** 
    85                  *  
    86                  * @param       mtx 
     85                 * prepend matrix. 
     86                 * @param       mtx            matrix 
    8787                 */ 
    8888                public function prepend( mtx:Matrix ):void 
     
    100100                 
    101101                /** 
    102                  * 現在の行列の前に、指定の行列を concat します
    103                  * @param       t11     
    104                  * @param       t12     
    105                  * @param       t21     
    106                  * @param       t22     
    107                  * @param       t31     tx 
    108                  * @param       t32     ty 
     102                 * prepend matrix
     103                 * @param       t11            
     104                 * @param       t12            
     105                 * @param       t21            
     106                 * @param       t22            
     107                 * @param       t31            tx 
     108                 * @param       t32            ty 
    109109                 */ 
    110110                public function prependMatrix( t11:Number, t12:Number, 
     
    124124                 
    125125                /** 
    126                  *  
    127                  * @param       scaleX 
    128                  * @param       scaleY 
     126                 * prepend scale matrix. 
     127                 * @param       sx     scaleX 
     128                 * @param       sy     scaleY 
    129129                 */ 
    130130                public function prependScale( sx:Number, sy:Number ):void 
     
    138138                 
    139139                /** 
    140                  *  
    141                  * @param       x 
    142                  * @param       y 
     140                 * prepend translate matrix. 
     141                 * @param       x      translate x 
     142                 * @param       y      translate y 
    143143                 */ 
    144144                public function prependTranslation( x:Number, y:Number ):void 
     
    150150                 
    151151                /** 
    152                  *  
    153                  * @param       angle 
     152                 * prepend rotate matrix. 
     153                 * @param       angle  rotate radian 
    154154                 */ 
    155155                public function prependRotation( angle:Number ):void 
     
    169169                 
    170170                /** 
    171                  *  
    172                  * @param       mtx 
     171                 * append matrix. 
     172                 * @param       mtx            matrix 
    173173                 */ 
    174174                override public function concat( mtx:Matrix ):void 
     
    186186                 
    187187                /** 
    188                  * 現在の行列に、指定の行列値を concat します
    189                  * @param       t11     
    190                  * @param       t12     
    191                  * @param       t21     
    192                  * @param       t22     
    193                  * @param       t31     tx 
    194                  * @param       t32     ty 
     188                 * append matrix
     189                 * @param       t11            
     190                 * @param       t12            
     191                 * @param       t21            
     192                 * @param       t22            
     193                 * @param       t31            tx 
     194                 * @param       t32            ty 
    195195                 */ 
    196196                public function appendMatrix( t11:Number, t12:Number, 
     
    210210                 
    211211                /** 
    212                  * append scale 
    213                  * @param       scaleX 
    214                  * @param       scaleY 
     212                 * append scale        matrix. 
     213                 * @param       sx     scaleX 
     214                 * @param       sy     scaleY 
    215215                 */ 
    216216                override public function scale( sx:Number, sy:Number ):void 
     
    226226                 
    227227                /** 
    228                  * append translation 
    229                  * @param       x 
    230                  * @param       y 
     228                 * append translate matrix. 
     229                 * @param       x      translate x 
     230                 * @param       y      translate y 
    231231                 */ 
    232232                override public function translate( x:Number, y:Number ):void 
     
    238238                 
    239239                /** 
    240                  * append rotation 
    241                  * @param       angle 
     240                 * append rotate matrix. 
     241                 * @param       angle  rotate radian 
    242242                 */ 
    243243                override public function rotate( angle:Number ):void 
     
    391391                 
    392392                /** 
    393                 * Scale変換行列 
    394                 * @param        scaleX 
    395                 * @param        scaleY 
    396                 * @return        
     393                * create scale matrix. 
     394                * @param        sx      scaleX 
     395                * @param        sy      scaleY 
    397396                */ 
    398397                public static function scaleMatrix( sx:Number = 1.0, sy:Number = 1.0 ):FMatrix2D 
     
    402401                 
    403402                /** 
    404                 * 移動変換行列 
    405                 * @param        translateX 
    406                 * @param        translateY 
    407                 * @return 
     403                * create translate matrix. 
     404                * @param        tx      translate x 
     405                * @param        ty      translate y 
    408406                */ 
    409407                public static function translateMatrix( tx:Number, ty:Number ):FMatrix2D 
     
    413411                 
    414412                /** 
    415                 * 回転行列 
    416                 * @param        radian 
    417                 * @return       FMatrix2D 
     413                * create rotate matrix. 
     414                * @param        a       rotate radian 
    418415                */ 
    419416                public static function rotateMatrix( a:Number ):FMatrix2D 
     
    427424                 
    428425                /** 
    429                 * toString 
    430                 * @return       String 
     426                *  
    431427                */ 
    432428                override public function toString():String 
  • as3/Frocessing/trunk/src/frocessing/math/FMath.as

    r2180 r2309  
    5050                public static var NE:Number = 1e-6; 
    5151                 
     52                private static var __random:MTRandom; 
     53                 
    5254                //--------------------------------------------------------------------------------------------------- Calculation 
    5355                 
     
    307309                public static function random( high:Number, low:Number=0 ):Number 
    308310                { 
    309                         return low + (high - low) * Math.random(); 
     311                        if ( __random == null ) 
     312                                __random = new MTRandom(); 
     313                        return low + (high - low) * __random.random(); 
     314                } 
     315                 
     316                /** 
     317                 * set random seed 
     318                 * @param       seed 
     319                 */ 
     320                public static function randomSeed( seed:uint ):void 
     321                { 
     322                        if ( __random == null ) 
     323                                __random = new MTRandom(); 
     324                        __random.randomSeed( seed ); 
    310325                } 
    311326                 
  • as3/Frocessing/trunk/src/frocessing/math/PerlinNoise.as

    r2180 r2309  
    3535        *  
    3636        * @author nutsu 
    37         * @version 0.1 
     37        * @version 0.5.3 
    3838        */ 
    3939        public class PerlinNoise  
     
    4848                private var perlin_amp_falloff:Number = 0.5; // 50% reduction/octave 
    4949                 
    50                 private var perlin:Array;       //Number[] 
     50                private var __perlin:Array;     //Number[] 
     51                private var __random:MTRandom; 
     52                 
     53                //private static var __cosTabel:Array; 
     54                //private static var __perlin_TWOPI:int = 360 * 2; 
     55                //private static var __perlin_PI:int = 360; 
    5156                 
    5257                /** 
     
    5560                public function PerlinNoise()  
    5661                { 
    57                         random_init(); 
    58                 } 
    59                  
    60                 private function random_init():void 
    61                 { 
    62                         /* 
    63                         if (perlinRandom == null) { 
    64                                 perlinRandom = new Random(); 
    65                         } 
    66                         */ 
    67                          
    68                         perlin = new Array(PERLIN_SIZE + 1); 
    69                         for ( var i:int=0; i < PERLIN_SIZE + 1; i++) 
    70                         { 
    71                                 //perlin[i] = perlinRandom.nextFloat(); //(float)Math.random(); 
    72                                 perlin[i] = Math.random(); 
    73                         } 
     62                        ; 
    7463                } 
    7564                 
     
    7968                public function noise( x:Number, y:Number=0.0, z:Number=0.0 ):Number 
    8069                { 
     70                        if ( __perlin == null ) 
     71                        { 
     72                                if ( __random == null ) 
     73                                        __random = new MTRandom(); 
     74                                 
     75                                __perlin = new Array(PERLIN_SIZE + 1); 
     76                                for ( var p:int = 0; p < PERLIN_SIZE + 1; p++) 
     77                                { 
     78                                        __perlin[p] = __random.random(); 
     79                                }        
     80                                /* 
     81                                if ( __cosTabel == null ) 
     82                                { 
     83                                        __cosTabel = []; 
     84                                        var d2r:Number = 0.5 * Math.PI / 180; 
     85                                        for ( var j:int = 0; j < __perlin_TWOPI; j++ ) 
     86                                                __cosTabel[j] = Math.cos( j * d2r ); 
     87                                } 
     88                                */ 
     89                        } 
     90                         
    8191                        if (x < 0) x = -x; 
    8292                        if (y < 0) y = -y; 
     
    99109                        var n3:Number; 
    100110                         
    101                         for ( var i:int=0; i < perlin_octaves; i++)  
     111                        for ( var i:int=0; i < perlin_octaves; i++ )  
    102112                        { 
    103                                 var of:int = xi+(yi<<PERLIN_YWRAPB)+(zi<<PERLIN_ZWRAPB); 
     113                                var of:int = xi + (yi << PERLIN_YWRAPB) + (zi << PERLIN_ZWRAPB); 
    104114                                 
    105                                 rxf = 0.5 * (1.0 - Math.cos( xf * Math.PI )); 
    106                                 ryf = 0.5 * (1.0 - Math.cos( yf * Math.PI )); 
     115                                rxf = 0.5 * (1.0 - Math.cos( xf * Math.PI )); //0.5*(1.0 - __cosTabel[int(xf*__perlin_PI%__perlin_TWOPI)]); 
     116                                ryf = 0.5 * (1.0 - Math.cos( yf * Math.PI )); //0.5*(1.0 - __cosTabel[int(yf*__perlin_PI%__perlin_TWOPI)]); 
    107117                                 
    108                                 n1  = perlin[of&PERLIN_SIZE]; 
    109                                 n1 += rxf*(perlin[(of+1)&PERLIN_SIZE]-n1); 
    110                                 n2  = perlin[(of+PERLIN_YWRAP)&PERLIN_SIZE]; 
    111                                 n2 += rxf*(perlin[(of+PERLIN_YWRAP+1)&PERLIN_SIZE]-n2); 
    112                                 n1 += ryf*(n2-n1); 
     118                                n1  = __perlin[int(of & PERLIN_SIZE)]; 
     119                                n1 += rxf * ( __perlin[int((of + 1) & PERLIN_SIZE)] - n1 ); 
     120                                n2  = __perlin[int((of + PERLIN_YWRAP) & PERLIN_SIZE)]; 
     121                                n2 += rxf * ( __perlin[int((of + PERLIN_YWRAP + 1) & PERLIN_SIZE)] - n2); 
     122                                n1 += ryf * ( n2 - n1 ); 
    113123                                 
    114124                                of += PERLIN_ZWRAP; 
    115                                 n2  = perlin[of&PERLIN_SIZE]; 
    116                                 n2 += rxf*(perlin[(of+1)&PERLIN_SIZE]-n2); 
    117                                 n3  = perlin[(of+PERLIN_YWRAP)&PERLIN_SIZE]; 
    118                                 n3 += rxf*(perlin[(of+PERLIN_YWRAP+1)&PERLIN_SIZE]-n3); 
    119                                 n2 += ryf*(n3-n2); 
     125                                n2  = __perlin[int(of & PERLIN_SIZE)]; 
     126                                n2 += rxf * (__perlin[int((of + 1) & PERLIN_SIZE)] - n2); 
     127                                n3  = __perlin[int((of + PERLIN_YWRAP) & PERLIN_SIZE)]; 
     128                                n3 += rxf * (__perlin[int((of + PERLIN_YWRAP + 1) & PERLIN_SIZE)] - n3); 
     129                                n2 += ryf * (n3 - n2); 
    120130                                 
    121                                 n1 += 0.5 * (1.0 - Math.cos( zf * Math.PI ))*(n2-n1); 
     131                                n1 += 0.5 * (1.0 - Math.cos( zf * Math.PI ))*(n2-n1); //0.5*(1.0 - __cosTabel[int(zf*__perlin_PI%__perlin_TWOPI)])*(n2-n1); 
    122132                                 
    123133                                r += n1*ampl; 
     
    135145                 
    136146                /** 
    137                  *  
     147                 * set random seed. 
     148                 * @param       what 
     149                 */ 
     150                public function noiseSeed( what:int ):void 
     151                { 
     152                        if (__random == null) 
     153                                __random = new MTRandom(); 
     154                        __random.randomSeed( what ); 
     155                        __perlin = null; 
     156                } 
     157   
     158                /** 
     159                 * note that fallout value greater than 0.5 might result in greater than 1.0 values returned by noise(). 
    138160                 * @param       lod 
    139161                 * @param       falloff 
    140162                 */ 
    141                 public function noiseDetail( lod:int, falloff:Number=0):void 
     163                public function noiseDetail( lod:uint, falloff:Number=0):void 
    142164                { 
    143                         if (lod>0) perlin_octaves=lod; 
    144                         if (falloff>0) perlin_amp_falloff = falloff; 
     165                        if (lod > 0)  
     166                                perlin_octaves = lod; 
     167                                 
     168                        if (falloff > 0 && falloff < 1 ) 
     169                                perlin_amp_falloff = falloff; 
    145170                } 
    146                  
    147                 /* 
    148                 public noiseSeed( what:int ):void 
    149                 { 
    150                         if (perlinRandom == null) perlinRandom = new Random(); 
    151                         perlinRandom.setSeed(what); 
    152                         // force table reset after changing the random number seed [0122] 
    153                         random_init(); 
    154                 } 
    155                 */ 
    156171        } 
    157172         
  • as3/Frocessing/trunk/src/frocessing/shape/FShape.as

    r2180 r2309  
    2727package frocessing.shape  
    2828{ 
     29        import flash.display.Graphics; 
     30        import frocessing.core.F5Graphics; 
    2931         
    3032        /** 
    31         * not implemented 
     33        * Path Shape 
    3234        *  
    3335        * @author nutsu 
     36        * @version 0.5.3 
    3437        */ 
    35         public class FShape implements IFShape 
     38        public class FShape extends FShapeObject implements IFShape 
    3639        { 
    37                  
    38                 public function FShape()  
    39                 { 
    40                          
    41                 } 
     40                // path command -------------------------------- 
     41                /** 
     42                 * @private 
     43                 */ 
     44                protected static const MOVE_TO    :int = 1; 
     45                /** 
     46                 * @private 
     47                 */ 
     48                protected static const LINE_TO    :int = 2; 
     49                /** 
     50                 * @private 
     51                 */ 
     52                protected static const CURVE_TO   :int = 3; 
     53                /** 
     54                 * @private 
     55                 */ 
     56                protected static const BEZIER_TO  :int = 10; 
     57                /** 
     58                 * @private 
     59                 */ 
     60                protected static const CLOSE_PATH :int = 100; 
     61                 
     62                // path values --------------------------------- 
     63                /** 
     64                 * @private 
     65                 */ 
     66                protected var _commands:Array; 
     67                /** 
     68                 * @private 
     69                 */ 
     70                protected var _vertices:Array; 
     71                 
     72                 
     73                /** 
     74                 *  
     75                 */ 
     76                public function FShape( commands:Array=null, vertices:Array=null, parent_group:FShapeContainer=null )  
     77                { 
     78                        super( parent_group ); 
     79                         
     80                        //path 
     81                        _commands = ( commands != null ) ? commands : []; 
     82                        _vertices = ( vertices != null ) ? vertices : []; 
     83                         
     84                        //_geom_changed = true; 
     85                } 
     86                 
     87                /** 
     88                 *  
     89                 */ 
     90                public function get commands():Array { return _commands; } 
     91                 
     92                /** 
     93                 *  
     94                 */ 
     95                public function get vertices():Array { return _vertices; } 
     96                 
     97                //------------------------------------------------------------------------------------------------------------------- 
     98                // implements draw method 
     99                //------------------------------------------------------------------------------------------------------------------- 
     100                 
     101                /** 
     102                 * implements f5graphics draw code. 
     103                 * @private 
     104                 */ 
     105                override protected function _draw_to_f5( fg:F5Graphics ):void 
     106                { 
     107                        var len:int = _commands.length; 
     108                        if ( len == 0 ) 
     109                                return; 
     110                         
     111                        var xi:int   = 0; 
     112                        var yi:int   = 1; 
     113                        var cxi:int; 
     114                        var cyi:int; 
     115                         
     116                        //path 
     117                        for ( var i:int = 0; i < len ; i++ ) 
     118                        { 
     119                                var cmd:int = _commands[i]; 
     120                                if ( cmd == LINE_TO ) 
     121                                { 
     122                                        fg.lineTo( _vertices[xi], _vertices[yi] ); 
     123                                        xi += 2; 
     124                                        yi += 2; 
     125                                } 
     126                                else if ( cmd == CURVE_TO ) 
     127                                { 
     128                                        cxi = xi + 2; 
     129                                        cyi = yi + 2; 
     130                                        fg.curveTo( _vertices[xi], _vertices[yi], _vertices[cxi], _vertices[cyi] ); 
     131                                        xi += 4; 
     132                                        yi += 4; 
     133                                } 
     134                                else if ( cmd == MOVE_TO ) 
     135                                { 
     136                                        fg.moveTo( _vertices[xi], _vertices[yi] ); 
     137                                        xi += 2; 
     138                                        yi += 2; 
     139                                } 
     140                                else if ( cmd == CLOSE_PATH ) 
     141                                { 
     142                                        fg.closePath(); 
     143                                } 
     144                                else if ( cmd == BEZIER_TO ) 
     145                                { 
     146                                        fg.bezierTo( _vertices[xi], _vertices[yi], _vertices[int(xi + 2)], _vertices[int(yi + 2)], _vertices[int(xi + 4)], _vertices[int(yi + 4)] ); 
     147                                        xi += 6; 
     148                                        yi += 6; 
     149                                } 
     150                        } 
     151                } 
     152                 
     153                /** 
     154                 * implements graphics draw code. 
     155                 * @private 
     156                 */ 
     157                override protected function _draw_to_graphics( gc:Graphics ):void 
     158                { 
     159                        var len:int = _commands.length; 
     160                        if ( len == 0 ) 
     161                                return; 
     162                                 
     163                        var sx:Number = 0; 
     164                        var sy:Number = 0; 
     165                        var xi:int   = 0; 
     166                        var yi:int   = 1; 
     167                        var cxi:int; 
     168                        var cyi:int; 
     169                        for ( var i:int = 0; i < len ; i++ ) 
     170                        { 
     171                                var cmd:int = _commands[i]; 
     172                                if ( cmd == LINE_TO ) 
     173                                { 
     174                                        gc.lineTo( _vertices[xi], _vertices[yi] ); 
     175                                        xi += 2; 
     176                                        yi += 2; 
     177                                } 
     178                                else if ( cmd == CURVE_TO ) 
     179                                { 
     180                                        cxi = xi + 2; 
     181                                        cyi = yi + 2; 
     182                                        gc.curveTo( _vertices[xi], _vertices[yi], _vertices[cxi], _vertices[cyi] ); 
     183                                        xi += 4; 
     184                                        yi += 4; 
     185                                } 
     186                                else if ( cmd == MOVE_TO ) 
     187                                { 
     188                                        sx = _vertices[xi]; 
     189                                        sy = _vertices[yi]; 
     190                                        gc.moveTo( sx, sy ); 
     191                                        xi += 2; 
     192                                        yi += 2; 
     193                                } 
     194                                else if ( cmd == CLOSE_PATH ) 
     195                                { 
     196                                        gc.lineTo( sx, sy ); 
     197                                } 
     198                                else if ( cmd == BEZIER_TO ) 
     199                                { 
     200                                        var bx:Number = _vertices[int(xi + 4)]; 
     201                                        var by:Number = _vertices[int(yi + 4)]; 
     202                                        _draw_bezier( gc, sx, sy, _vertices[xi], _vertices[yi], _vertices[int(xi + 2)], _vertices[int(yi + 2)], bx, by ); 
     203                                        sx = bx; 
     204                                        sy = by; 
     205                                        xi += 6; 
     206                                        yi += 6; 
     207                                } 
     208                        } 
     209                } 
     210                 
     211                public var bezierDetail:uint = 20; 
     212                 
     213                private function _draw_bezier( gc:Graphics, x0:Number, y0:Number, cx0:Number, cy0:Number, cx1:Number, cy1:Number, x:Number, y:Number ):void 
     214                { 
     215                        var k:Number = 1.0/bezierDetail; 
     216                        var t:Number = 0; 
     217                        var tp:Number; 
     218                        for ( var i:int = 1; i <= bezierDetail; i++ ) 
     219                        { 
     220                                t += k; 
     221                                tp = 1.0-t; 
     222                                gc.lineTo( x0*tp*tp*tp + 3*cx0*t*tp*tp + 3*cx1*t*t*tp + x*t*t*t,  
     223                                                   y0*tp*tp*tp + 3*cy0*t*tp*tp + 3*cy1*t*t*tp + y*t*t*t ); 
     224                        } 
     225                } 
     226                 
     227                //------------------------------------------------------------------------------------------------------------------- 
     228                // path commands 
     229                //------------------------------------------------------------------------------------------------------------------- 
     230                 
     231                /** 
     232                 *  
     233                 */ 
     234                public function moveTo( x:Number, y:Number ):void 
     235                { 
     236                        _commands.push( MOVE_TO ); 
     237                        _vertices.push( x, y ); 
     238                } 
     239                 
     240                /** 
     241                 *  
     242                 */ 
     243                public function lineTo( x:Number, y:Number ):void 
     244                { 
     245                        _commands.push( LINE_TO ); 
     246                        _vertices.push( x, y ); 
     247                        _geom_changed = true; 
     248                } 
     249                 
     250                /** 
     251                 *  
     252                 */ 
     253                public function curveTo( cx:Number, cy:Number, x:Number, y:Number ):void 
     254                { 
     255                        _commands.push( CURVE_TO ); 
     256                        _vertices.push( cx, cy, x, y ); 
     257                        _geom_changed = true; 
     258                } 
     259                 
     260                /** 
     261                 *  
     262                 */ 
     263                public function bezierTo( cx0:Number, cy0:Number, cx1:Number, cy1:Number, x:Number, y:Number ):void 
     264                { 
     265                        _commands.push( BEZIER_TO ); 
     266                        _vertices.push( cx0, cy0, cx1, cy1, x, y ); 
     267                        _geom_changed = true; 
     268                } 
     269                 
     270                /** 
     271                 *  
     272                 */ 
     273                public function closePath():void 
     274                { 
     275                        _commands.push( CLOSE_PATH ); 
     276                } 
     277                 
    42278                 
    43279        } 
  • as3/Frocessing/trunk/src/frocessing/shape/IFShape.as

    r2180 r2309  
    2727package frocessing.shape  
    2828{ 
     29        import flash.display.Sprite; 
     30        import frocessing.core.F5Graphics; 
    2931         
    3032        /** 
    31         * not implemented 
     33        * Shape Object Interface 
    3234        *  
    3335        * @author nutsu 
     36        * @version 0.5.3 
    3437        */ 
    3538        public interface IFShape  
    3639        { 
    37                  
    38                  
     40                function draw( fg:F5Graphics ):void; 
     41                function toSprite():Sprite; 
     42                function get name():String; 
     43                function get left():Number; 
     44                function get top():Number; 
     45                function get width():Number; 
     46                function get height():Number; 
    3947        } 
    4048         
  • as3/Frocessing/trunk/src/frocessing/text/PFontLoader.as

    r2180 r2309  
    4646                private var __loader:URLLoader; 
    4747                private var __complete:Boolean; 
     48                 
    4849                /** 
    49                  *  
     50                 * Simple Font Loader  
    5051                 */ 
    5152                public function PFontLoader( url:String, loader:URLLoader = null ) 
     
    6162                        } 
    6263                        __loader.dataFormat = URLLoaderDataFormat.BINARY; 
    63                         __loader.addEventListener( Event.COMPLETE, __onLoad ); 
     64                        __loader.addEventListener( Event.COMPLETE, __onLoad, false, int.MAX_VALUE ); 
    6465                         
    6566                        __complete = false; 
  • as3/Frocessing/trunk/src/frocessing/utils/FUtil.as

    r2180 r2309  
    4444                //--------------------------------------------------------------------------------------------------- 
    4545                 
     46                /** 
     47                 *  
     48                 * @return String[] 
     49                 */ 
     50                public static function splitTokens( str:String, tokens:String=" "):Array 
     51                { 
     52                        var pattern:RegExp = new RegExp( "[" + tokens + "]+" ); 
     53                        return trim(str).split(pattern); 
     54                } 
     55                 
     56                public static function trim( str:String ):String 
     57                { 
     58                        return str.replace(/^ +/, "").replace(/ +$/, ""); 
     59                } 
    4660                 
    4761                //--------------------------------------------------------------------------------------------------- FORMAT