チェンジセット 2309
- コミット日時:
- 2009/02/24 19:31:32 (3 年前)
- ファイル:
-
- as3/Frocessing/changelog.txt (更新) (3 diffs)
- as3/Frocessing/trunk/src/frocessing/bmp/FImageLoader.as (更新) (3 diffs)
- as3/Frocessing/trunk/src/frocessing/color/ColorKey.as (追加)
- as3/Frocessing/trunk/src/frocessing/color/FColor.as (更新) (3 diffs)
- as3/Frocessing/trunk/src/frocessing/core/F5Draw.as (更新) (4 diffs)
- as3/Frocessing/trunk/src/frocessing/core/F5Graphics.as (更新) (14 diffs)
- as3/Frocessing/trunk/src/frocessing/core/F5Graphics2D.as (更新) (10 diffs)
- as3/Frocessing/trunk/src/frocessing/core/F5Graphics3D.as (更新) (11 diffs)
- as3/Frocessing/trunk/src/frocessing/core/F5Typographics.as (更新) (2 diffs)
- as3/Frocessing/trunk/src/frocessing/core/GraphicsEx.as (更新) (5 diffs)
- as3/Frocessing/trunk/src/frocessing/display/F5MovieClip.as (更新) (13 diffs)
- as3/Frocessing/trunk/src/frocessing/display/F5MovieClip2DBmp.as (更新) (2 diffs)
- as3/Frocessing/trunk/src/frocessing/display/F5MovieClip3DBmp.as (更新) (2 diffs)
- as3/Frocessing/trunk/src/frocessing/geom/FGradientMatrix.as (追加)
- as3/Frocessing/trunk/src/frocessing/geom/FMatrix2D.as (更新) (15 diffs)
- as3/Frocessing/trunk/src/frocessing/geom/FViewBox.as (追加)
- as3/Frocessing/trunk/src/frocessing/graphics (追加)
- as3/Frocessing/trunk/src/frocessing/graphics/FGradientFill.as (追加)
- as3/Frocessing/trunk/src/frocessing/graphics/IFGraphicsFill.as (追加)
- as3/Frocessing/trunk/src/frocessing/math/FMath.as (更新) (2 diffs)
- as3/Frocessing/trunk/src/frocessing/math/MTRandom.as (追加)
- as3/Frocessing/trunk/src/frocessing/math/PerlinNoise.as (更新) (6 diffs)
- as3/Frocessing/trunk/src/frocessing/shape/FShape.as (更新) (1 diff)
- as3/Frocessing/trunk/src/frocessing/shape/FShapeCircle.as (追加)
- as3/Frocessing/trunk/src/frocessing/shape/FShapeContainer.as (追加)
- as3/Frocessing/trunk/src/frocessing/shape/FShapeEllipse.as (追加)
- as3/Frocessing/trunk/src/frocessing/shape/FShapeGradient.as (追加)
- as3/Frocessing/trunk/src/frocessing/shape/FShapeImage.as (追加)
- as3/Frocessing/trunk/src/frocessing/shape/FShapeImageLoader.as (追加)
- as3/Frocessing/trunk/src/frocessing/shape/FShapeLine.as (追加)
- as3/Frocessing/trunk/src/frocessing/shape/FShapeObject.as (追加)
- as3/Frocessing/trunk/src/frocessing/shape/FShapeRect.as (追加)
- as3/Frocessing/trunk/src/frocessing/shape/FShapeSVG.as (追加)
- as3/Frocessing/trunk/src/frocessing/shape/FShapeSVGLoader.as (追加)
- as3/Frocessing/trunk/src/frocessing/shape/IFShape.as (更新) (1 diff)
- as3/Frocessing/trunk/src/frocessing/text/PFontLoader.as (更新) (2 diffs)
- as3/Frocessing/trunk/src/frocessing/utils/FUtil.as (更新) (1 diff)
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/Frocessing/changelog.txt
r2219 r2309 1 1 2 2 frocessing change log 3 4 2009-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 3 30 4 31 5 32 2009-02-02 0.5.2 nutsu(face@nutsu.com) 6 33 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. 9 36 10 37 … … 12 39 2009-02-02 0.5.1 nutsu(face@nutsu.com) 13 40 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. 16 43 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. 19 46 20 47 … … 22 49 2009-01-27 0.5.0 nutsu(face@nutsu.com) 23 50 24 * Improved classes and structure.51 * Improved classes and structure. 25 52 pre version(0.3) is moved to branch. 26 53 as3/Frocessing/trunk/src/frocessing/bmp/FImageLoader.as
r2180 r2309 30 30 import flash.display.BitmapData; 31 31 import flash.display.Loader; 32 import flash.net.URLRequest; 32 33 import flash.events.Event; 33 import flash.geom.Point;34 import flash.geom.Rectangle;35 import flash.net.URLRequest;36 34 37 35 /** 38 * ... 36 * Simple Image Loader 37 * 39 38 * @author nutsu 40 39 * @version 0.5 … … 53 52 super( bitmapData ); 54 53 if ( _bitmapdata == null ) 55 _bitmapdata = new BitmapData( 4, 4, true, bgcolor ); 54 _bitmapdata = new BitmapData( 4, 4, true, bgcolor ); 56 55 57 56 if ( loader != null ) … … 61 60 62 61 __complete = false; 63 __loader.contentLoaderInfo.addEventListener( Event.COMPLETE, __onLoad );62 __loader.contentLoaderInfo.addEventListener( Event.COMPLETE, __onLoad, false, int.MAX_VALUE ); 64 63 var request:URLRequest = new URLRequest(url); 65 64 __loader.load( request ); as3/Frocessing/trunk/src/frocessing/color/FColor.as
r2180 r2309 334 334 { 335 335 _a = c2; 336 if ( c1<= 0xff )336 if ( uint(c1) <= 0xff ) 337 337 gray( c1 ); 338 338 else … … 342 342 { 343 343 _a = 1.0; 344 if ( c1<= 0xff )344 if ( uint(c1) <= 0xff ) 345 345 gray( c1 ); 346 346 else if ( c1 >>> 24 > 0 ) … … 541 541 public static function GrayToValue( gray:uint, a:Number=0 ):uint 542 542 { 543 var g:uint = gray & 0xff;543 var g:uint = (gray>0xff) ? 255 : gray; 544 544 if ( a > 0 ) 545 545 return ( Math.round( a * 0xff ) & 0xff ) << 24 | g << 16 | g << 8 | g; as3/Frocessing/trunk/src/frocessing/core/F5Draw.as
r2180 r2309 27 27 package frocessing.core 28 28 { 29 import frocessing.f5internal; 30 use namespace f5internal; 29 31 30 32 /** … … 200 202 public function drawCircle( x:Number, y:Number, radius:Number ):void 201 203 { 202 drawArc( x, y, radius, radius, 0.0, TWO_PI);204 fg.f5internal::__ellipse( x, y, radius, radius ); 203 205 } 204 206 … … 214 216 width *= 0.5; 215 217 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 ); 217 219 } 218 220 … … 255 257 ry = ellipseHeight*0.5; 256 258 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 ); 262 260 } 263 261 as3/Frocessing/trunk/src/frocessing/core/F5Graphics.as
r2215 r2309 42 42 import frocessing.text.PFontLoader; 43 43 import frocessing.bmp.FImageLoader; 44 import frocessing.shape.FShapeSVGLoader; 45 46 import frocessing.f5internal; 47 use namespace f5internal; 44 48 45 49 /** … … 47 51 * 48 52 * @author nutsu 49 * @version 0.5 53 * @version 0.5.3 50 54 */ 51 55 public class F5Graphics … … 480 484 } 481 485 } 482 483 486 484 487 /** … … 599 602 600 603 /** 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 /** 601 651 * 点を描画します.点を描画する色は、線の色が適用されます. 602 652 */ … … 605 655 gc.point( x, y ); 606 656 } 607 608 //------------------------------------------------------------------------------------------------------------------- 2D Primitives609 657 610 658 /** … … 671 719 { 672 720 gc.applyFill(); 673 __ drawArc( x, y, radius, radius, 0, TWO_PI);721 __ellipse( x, y, radius, radius ); 674 722 gc.endFill(); 675 723 } … … 718 766 } 719 767 gc.applyFill(); 720 __ drawArc( x0, y0, w, h, 0, TWO_PI);768 __ellipse( x0, y0, w, h ); 721 769 gc.endFill(); 722 770 } … … 734 782 * <li>mode CORNERS : rect( left, top, right, bottom )</li> 735 783 * <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> 737 785 * </ul> 738 786 */ 739 public function rect( x0:Number, y0:Number, x1:Number, y1:Number ):void740 { 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; 743 791 switch( _rect_mode ) 744 792 { 745 793 case CORNERS: 794 hw = (x1 - x0) * 0.5; 795 hh = (y1 - y0) * 0.5; 746 796 break; 747 797 case CORNER: … … 750 800 break; 751 801 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; 758 808 break; 759 809 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; 766 816 break; 767 817 } 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(); 769 839 } 770 840 … … 1200 1270 1201 1271 /** 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 ); 1207 1300 } 1208 1301 … … 1248 1341 public function image( img:BitmapData, x:Number, y:Number, w:Number = NaN, h:Number = NaN ):void 1249 1342 { 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 ) 1261 1344 { 1262 1345 switch( _image_mode ) … … 1278 1361 } 1279 1362 } 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 } 1280 1373 _image( img, x, y, w, h ); 1281 1374 } … … 1284 1377 * @private 1285 1378 */ 1286 internal function _image( img:BitmapData, x:Number, y:Number, w:Number, h:Number, z:Number=0 ):void1379 f5internal function _image( img:BitmapData, x:Number, y:Number, w:Number, h:Number, z:Number=0 ):void 1287 1380 { 1288 1381 if ( _tint_do ) … … 2001 2094 } 2002 2095 } 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 ; 2003 2128 } 2004 2129 as3/Frocessing/trunk/src/frocessing/core/F5Graphics2D.as
r2181 r2309 36 36 import flash.geom.Matrix; 37 37 import frocessing.geom.FMatrix2D; 38 import frocessing.shape.IFShape; 39 40 import frocessing.f5internal; 41 use namespace f5internal; 38 42 39 43 /** … … 41 45 * 42 46 * @author nutsu 43 * @version 0.5 47 * @version 0.5.3 44 48 */ 45 49 public class F5Graphics2D extends F5Graphics { … … 97 101 * 現在の 変換 Matrix を一時的に保持します. 98 102 */ 99 public function pushMatrix():void103 override public function pushMatrix():void 100 104 { 101 105 __matrix_tmp.push( new MatrixParam( a, b, c, d, tx, ty ) ); … … 105 109 * 前回、pushMatrix() で保持した 変換 Matrix を復元します. 106 110 */ 107 public function popMatrix():void111 override public function popMatrix():void 108 112 { 109 113 __applyMatrixParam( __matrix_tmp.pop() ); … … 188 192 { 189 193 __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 ); 190 203 update_transform(); 191 204 } … … 377 390 378 391 //------------------------------------------------------------------------------------------------------------------- 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 //------------------------------------------------------------------------------------------------------------------- 379 443 // IMAGE 380 444 //------------------------------------------------------------------------------------------------------------------- … … 383 447 * @private 384 448 */ 385 override internal function _image( img:BitmapData, x:Number, y:Number, w:Number, h:Number, z:Number=0 ):void449 override f5internal function _image( img:BitmapData, x:Number, y:Number, w:Number, h:Number, z:Number=0 ):void 386 450 { 387 451 if ( _tint_do ) … … 405 469 focalPointRatio:Number = 0.0 ):void 406 470 { 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 { 410 480 gc.lineGradientStyle(type, colors, alphas, ratios, matrix_, spreadMethod, interpolationMethod, focalPointRatio); 411 481 } 412 else413 {414 gc.lineGradientStyle(type, colors, alphas, ratios, __matrix, spreadMethod, interpolationMethod, focalPointRatio);415 }416 417 482 } 418 483 … … 424 489 if ( transformFillMatrix ) 425 490 { 426 if ( matrix_ )491 if ( matrix_!=null ) 427 492 gc.beginBitmapFill( bitmap, __matrix.preProduct( matrix_ ), repeat, smooth ); 428 493 else … … 443 508 if ( transformFillMatrix ) 444 509 { 445 if ( matrix_ )510 if ( matrix_!=null ) 446 511 gc.beginGradientFill( type, color, alphas, ratios, __matrix.preProduct( matrix_ ), spreadMethod, interpolationMethod, focalPointRation ); 447 512 else as3/Frocessing/trunk/src/frocessing/core/F5Graphics3D.as
r2216 r2309 41 41 import frocessing.f3d.F3DCamera; 42 42 import frocessing.f3d.F3DObject; 43 import frocessing.shape.IFShape; 43 44 44 45 import frocessing.f5internal; … … 49 50 * 50 51 * @author nutsu 51 * @version 0.5 52 * @version 0.5.3 52 53 */ 53 54 public class F5Graphics3D extends F5Graphics … … 154 155 } 155 156 157 /** 158 * @private 159 */ 156 160 override protected function __initGC(graphics:Graphics):void 157 161 { … … 225 229 * 現在の 変換 Matrix を一時的に保持します. 226 230 */ 227 public function pushMatrix():void231 override public function pushMatrix():void 228 232 { 229 233 __matrix_tmp.push( new MatrixParam3D(m11,m12,m13,m21,m22,m23,m31,m32,m33,tx,ty,tz) ); … … 233 237 * 前回、pushMatrix() で保持した 変換 Matrix を復元します. 234 238 */ 235 public function popMatrix():void239 override public function popMatrix():void 236 240 { 237 241 __applyMatrixParam( __matrix_tmp.pop() ); … … 372 376 { 373 377 __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); 374 387 update_transform(); 375 388 } … … 1252 1265 1253 1266 //------------------------------------------------------------------------------------------------------------------- 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 //------------------------------------------------------------------------------------------------------------------- 1254 1318 // IMAGE 1255 1319 //------------------------------------------------------------------------------------------------------------------- … … 1340 1404 * @private 1341 1405 */ 1342 override internal function _image(img:BitmapData, x1:Number, y1:Number, w:Number, h:Number, z:Number=0):void1406 override f5internal function _image(img:BitmapData, x1:Number, y1:Number, w:Number, h:Number, z:Number=0):void 1343 1407 { 1344 1408 if ( _tint_do ) … … 1519 1583 { 1520 1584 update_fill_matrix(); 1521 if ( matrix_ )1585 if ( matrix_!=null ) 1522 1586 fill_matrix.prepend( matrix_ ); 1523 1587 gc3d.beginBitmapFill( bitmap_, fill_matrix, repeat_, smooth_ ); … … 1537 1601 { 1538 1602 update_fill_matrix(); 1539 if ( matrix_ )1603 if ( matrix_!=null ) 1540 1604 fill_matrix.prepend( matrix_ ); 1541 1605 else … … 1563 1627 { 1564 1628 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; 1571 1638 } 1572 1639 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 36 36 import frocessing.text.PFont; 37 37 import frocessing.text.FFont; 38 39 import frocessing.f5internal; 40 use namespace f5internal; 38 41 39 42 /** … … 141 144 var h1:Number = high * _size; 142 145 143 _fg. _image( img, x1, y1, w1, h1, _z );146 _fg.f5internal::_image( img, x1, y1, w1, h1, _z ); 144 147 } 145 148 as3/Frocessing/trunk/src/frocessing/core/GraphicsEx.as
r2180 r2309 32 32 import frocessing.bmp.FBitmapData; 33 33 import frocessing.geom.FMatrix2D; 34 import frocessing.geom.FGradientMatrix; 34 35 35 36 /** … … 37 38 * 38 39 * @author nutsu 39 * @version 0.5 40 * @version 0.5.3 40 41 */ 41 42 public class GraphicsEx … … 156 157 * @private 157 158 */ 158 internal var default_gradient_matrix: FMatrix2D;159 internal var default_gradient_matrix:Matrix; 159 160 160 161 /** … … 167 168 gc = graphics; 168 169 __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(); 171 171 } 172 172 … … 225 225 __x = anchorX; 226 226 __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 */ 227 242 } 228 243 as3/Frocessing/trunk/src/frocessing/display/F5MovieClip.as
r2180 r2309 37 37 import flash.display.MovieClip; 38 38 import flash.display.BitmapData; 39 import flash.events.MouseEvent; 39 40 import flash.geom.Matrix; 40 41 import flash.events.Event; … … 54 55 import frocessing.utils.FUtil; 55 56 import frocessing.bmp.FImageLoader; 57 import frocessing.shape.IFShape; 58 import frocessing.shape.FShapeSVGLoader; 56 59 57 60 /** 58 61 * F5MovieClip 59 62 * @author nutsu 60 * @version 0.5 63 * @version 0.5.3 61 64 * 62 65 * @see frocessing.core.F5Graphics … … 130 133 private var __loop:Boolean; 131 134 132 // setting functio 135 // setting function 133 136 private var __draw:Function; 134 137 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; 135 146 136 147 // noise … … 144 155 super(); 145 156 157 __pmouseX = __pmouseY = 0; 158 146 159 //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"); 150 167 151 168 //init perlin noise … … 226 243 __setup.apply(this,null); 227 244 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 228 256 //draw 229 257 loop(); … … 240 268 __draw(); 241 269 __fg.endDraw(); 270 271 //exit_frame? 272 __pmouseX = mouseX; 273 __pmouseY = mouseY; 242 274 } 243 275 … … 258 290 public function loop():void 259 291 { 260 if ( __loop == false )292 if ( __loop == false && __draw != null ) 261 293 { 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; 267 298 } 268 299 } … … 279 310 } 280 311 } 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; } 281 320 282 321 //------------------------------------------------------------------------------------------------------------------- … … 501 540 __fg.ellipse( x0, y0, x1, y1); 502 541 } 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 ); 505 544 } 506 545 … … 598 637 public function moveToLast():void { 599 638 __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 ); 600 654 } 601 655 … … 770 824 /** 771 825 * @see frocessing.math.FMath 826 * @see frocessing.math.MTRandom 772 827 */ 773 828 public function random( high:Number, low:Number = 0 ):Number{ … … 776 831 777 832 /** 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(). 779 842 * @param lod 780 843 * @param falloff 781 844 * @see frocessing.math.PerlinNoise 782 845 */ 783 public function noiseDetail( lod: int, falloff:Number = 0):void{846 public function noiseDetail( lod:uint, falloff:Number = 0):void{ 784 847 __perlin_noise.noiseDetail( lod, falloff ); 785 848 } … … 791 854 public function noise( x:Number, y:Number = 0.0, z:Number = 0.0 ):Number{ 792 855 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 ); 793 864 } 794 865 as3/Frocessing/trunk/src/frocessing/display/F5MovieClip2DBmp.as
r2180 r2309 40 40 * ... 41 41 * @author nutsu 42 * @version 0.5 42 * @version 0.5.3 43 43 * 44 44 * @see frocessing.core.F5BitmapData2D … … 100 100 } 101 101 102 public function get bmpfg():F5BitmapData2D 103 { 104 return F5BitmapData2D(fg); 105 } 102 106 } 103 107 as3/Frocessing/trunk/src/frocessing/display/F5MovieClip3DBmp.as
r2180 r2309 40 40 * ... 41 41 * @author nutsu 42 * @version 0.5 42 * @version 0.5.3 43 43 * 44 44 * @see frocessing.core.F5BitmapData3D … … 99 99 return F5BitmapData3D(fg).bitmapData; 100 100 } 101 102 public function get bmpfg():F5BitmapData3D 103 { 104 return F5BitmapData3D(fg); 105 } 101 106 } 102 107 as3/Frocessing/trunk/src/frocessing/geom/FMatrix2D.as
r2180 r2309 34 34 * 35 35 * @author nutsu 36 * @version 0.5 36 * @version 0.5.3 37 37 */ 38 38 public class FMatrix2D extends Matrix{ … … 83 83 84 84 /** 85 * 86 * @param mtx 85 * prepend matrix. 86 * @param mtx matrix 87 87 */ 88 88 public function prepend( mtx:Matrix ):void … … 100 100 101 101 /** 102 * 現在の行列の前に、指定の行列を concat します.103 * @param t11 a104 * @param t12 b105 * @param t21 c106 * @param t22 d107 * @param t31 tx108 * @param t32 ty102 * prepend matrix. 103 * @param t11 a 104 * @param t12 b 105 * @param t21 c 106 * @param t22 d 107 * @param t31 tx 108 * @param t32 ty 109 109 */ 110 110 public function prependMatrix( t11:Number, t12:Number, … … 124 124 125 125 /** 126 * 127 * @param s caleX128 * @param s caleY126 * prepend scale matrix. 127 * @param sx scaleX 128 * @param sy scaleY 129 129 */ 130 130 public function prependScale( sx:Number, sy:Number ):void … … 138 138 139 139 /** 140 * 141 * @param x 142 * @param y 140 * prepend translate matrix. 141 * @param x translate x 142 * @param y translate y 143 143 */ 144 144 public function prependTranslation( x:Number, y:Number ):void … … 150 150 151 151 /** 152 * 153 * @param angle 152 * prepend rotate matrix. 153 * @param angle rotate radian 154 154 */ 155 155 public function prependRotation( angle:Number ):void … … 169 169 170 170 /** 171 * 172 * @param mtx 171 * append matrix. 172 * @param mtx matrix 173 173 */ 174 174 override public function concat( mtx:Matrix ):void … … 186 186 187 187 /** 188 * 現在の行列に、指定の行列値を concat します.189 * @param t11 a190 * @param t12 b191 * @param t21 c192 * @param t22 d193 * @param t31 tx194 * @param t32 ty188 * append matrix. 189 * @param t11 a 190 * @param t12 b 191 * @param t21 c 192 * @param t22 d 193 * @param t31 tx 194 * @param t32 ty 195 195 */ 196 196 public function appendMatrix( t11:Number, t12:Number, … … 210 210 211 211 /** 212 * append scale 213 * @param s caleX214 * @param s caleY212 * append scale matrix. 213 * @param sx scaleX 214 * @param sy scaleY 215 215 */ 216 216 override public function scale( sx:Number, sy:Number ):void … … 226 226 227 227 /** 228 * append translat ion229 * @param x 230 * @param y 228 * append translate matrix. 229 * @param x translate x 230 * @param y translate y 231 231 */ 232 232 override public function translate( x:Number, y:Number ):void … … 238 238 239 239 /** 240 * append rotat ion241 * @param angle 240 * append rotate matrix. 241 * @param angle rotate radian 242 242 */ 243 243 override public function rotate( angle:Number ):void … … 391 391 392 392 /** 393 * Scale変換行列 394 * @param scaleX 395 * @param scaleY 396 * @return 393 * create scale matrix. 394 * @param sx scaleX 395 * @param sy scaleY 397 396 */ 398 397 public static function scaleMatrix( sx:Number = 1.0, sy:Number = 1.0 ):FMatrix2D … … 402 401 403 402 /** 404 * 移動変換行列 405 * @param translateX 406 * @param translateY 407 * @return 403 * create translate matrix. 404 * @param tx translate x 405 * @param ty translate y 408 406 */ 409 407 public static function translateMatrix( tx:Number, ty:Number ):FMatrix2D … … 413 411 414 412 /** 415 * 回転行列 416 * @param radian 417 * @return FMatrix2D 413 * create rotate matrix. 414 * @param a rotate radian 418 415 */ 419 416 public static function rotateMatrix( a:Number ):FMatrix2D … … 427 424 428 425 /** 429 * toString 430 * @return String 426 * 431 427 */ 432 428 override public function toString():String as3/Frocessing/trunk/src/frocessing/math/FMath.as
r2180 r2309 50 50 public static var NE:Number = 1e-6; 51 51 52 private static var __random:MTRandom; 53 52 54 //--------------------------------------------------------------------------------------------------- Calculation 53 55 … … 307 309 public static function random( high:Number, low:Number=0 ):Number 308 310 { 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 ); 310 325 } 311 326 as3/Frocessing/trunk/src/frocessing/math/PerlinNoise.as
r2180 r2309 35 35 * 36 36 * @author nutsu 37 * @version 0. 137 * @version 0.5.3 38 38 */ 39 39 public class PerlinNoise … … 48 48 private var perlin_amp_falloff:Number = 0.5; // 50% reduction/octave 49 49 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; 51 56 52 57 /** … … 55 60 public function PerlinNoise() 56 61 { 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 ; 74 63 } 75 64 … … 79 68 public function noise( x:Number, y:Number=0.0, z:Number=0.0 ):Number 80 69 { 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 81 91 if (x < 0) x = -x; 82 92 if (y < 0) y = -y; … … 99 109 var n3:Number; 100 110 101 for ( var i:int=0; i < perlin_octaves; i++ )111 for ( var i:int=0; i < perlin_octaves; i++ ) 102 112 { 103 var of:int = xi +(yi<<PERLIN_YWRAPB)+(zi<<PERLIN_ZWRAPB);113 var of:int = xi + (yi << PERLIN_YWRAPB) + (zi << PERLIN_ZWRAPB); 104 114 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)]); 107 117 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 ); 113 123 114 124 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); 120 130 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); 122 132 123 133 r += n1*ampl; … … 135 145 136 146 /** 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(). 138 160 * @param lod 139 161 * @param falloff 140 162 */ 141 public function noiseDetail( lod: int, falloff:Number=0):void163 public function noiseDetail( lod:uint, falloff:Number=0):void 142 164 { 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; 145 170 } 146 147 /*148 public noiseSeed( what:int ):void149 {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 */156 171 } 157 172 as3/Frocessing/trunk/src/frocessing/shape/FShape.as
r2180 r2309 27 27 package frocessing.shape 28 28 { 29 import flash.display.Graphics; 30 import frocessing.core.F5Graphics; 29 31 30 32 /** 31 * not implemented33 * Path Shape 32 34 * 33 35 * @author nutsu 36 * @version 0.5.3 34 37 */ 35 public class FShape implements IFShape38 public class FShape extends FShapeObject implements IFShape 36 39 { 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 42 278 43 279 } as3/Frocessing/trunk/src/frocessing/shape/IFShape.as
r2180 r2309 27 27 package frocessing.shape 28 28 { 29 import flash.display.Sprite; 30 import frocessing.core.F5Graphics; 29 31 30 32 /** 31 * not implemented33 * Shape Object Interface 32 34 * 33 35 * @author nutsu 36 * @version 0.5.3 34 37 */ 35 38 public interface IFShape 36 39 { 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; 39 47 } 40 48 as3/Frocessing/trunk/src/frocessing/text/PFontLoader.as
r2180 r2309 46 46 private var __loader:URLLoader; 47 47 private var __complete:Boolean; 48 48 49 /** 49 * 50 * Simple Font Loader 50 51 */ 51 52 public function PFontLoader( url:String, loader:URLLoader = null ) … … 61 62 } 62 63 __loader.dataFormat = URLLoaderDataFormat.BINARY; 63 __loader.addEventListener( Event.COMPLETE, __onLoad );64 __loader.addEventListener( Event.COMPLETE, __onLoad, false, int.MAX_VALUE ); 64 65 65 66 __complete = false; as3/Frocessing/trunk/src/frocessing/utils/FUtil.as
r2180 r2309 44 44 //--------------------------------------------------------------------------------------------------- 45 45 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 } 46 60 47 61 //--------------------------------------------------------------------------------------------------- FORMAT

