チェンジセット 3488

差分発生行の前後
無視リスト:
コミット日時:
2010/03/06 18:12:43 (3 年前)
コミッタ:
hkrn
ログメッセージ:

added 3 methods and use LayerBitmap#applyMatrix? instead of setting transform property

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/LayerBitmap.as

    r3438 r3488  
    55    import flash.display.IBitmapDrawable; 
    66    import flash.geom.ColorTransform; 
     7    import flash.geom.Matrix; 
    78 
    89    public final class LayerBitmap extends Bitmap 
     
    6667        } 
    6768         
     69        public function applyMatrix(matrix:Matrix):void 
     70        { 
     71            var transformed:BitmapData = new BitmapData(width, height, true, 0x0); 
     72            transformed.draw(bitmapData, matrix); 
     73            bitmapData.dispose(); 
     74            bitmapData = transformed; 
     75        } 
     76         
    6877        /** 
    6978         * 指定された位置にバケツツールを適用する 
  • as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/LayerBitmapCollection.as

    r3438 r3488  
    55     
    66    import org.libspark.gunyarapaint.framework.errors.MergeLayersError; 
    7  
     7    import org.libspark.gunyarapaint.framework.errors.RemoveLayerError; 
     8     
    89    public class LayerBitmapCollection 
    910    { 
     
    117118        public function mergeAt(index:int):void 
    118119        { 
    119             var current:LayerBitmap = layers[index]; 
    120             var prev:LayerBitmap = layers[index - 1]; 
    121120            // 両方可視である必要がある 
    122             if (current.visible && prev.visible) { 
    123                 current.compositeTo(prev.bitmapData); 
    124                 // 合成後の LayerBitmap は完全に不透明にしておく 
    125                 prev.alpha = 1.0; 
    126                 layers.splice(index, 1); 
    127                 spriteToView.removeChildAt(index); 
    128                 if (index >= currentIndex) 
    129                     currentIndex -= 1; 
    130                 compositeAll(); 
    131                 resetLayersIndex(); 
    132             } 
    133             else { 
    134                 throw new MergeLayersError(); 
    135             } 
     121            if (currentIndex > 0) { 
     122                var current:LayerBitmap = layers[index]; 
     123                var prev:LayerBitmap = layers[index - 1]; 
     124                if (current.visible && prev.visible) { 
     125                    current.compositeTo(prev.bitmapData); 
     126                    // 合成後の LayerBitmap は完全に不透明にしておく 
     127                    prev.alpha = 1.0; 
     128                    layers.splice(index, 1); 
     129                    spriteToView.removeChildAt(index); 
     130                    if (index >= currentIndex) 
     131                        currentIndex -= 1; 
     132                    compositeAll(); 
     133                    resetLayersIndex(); 
     134                    return; 
     135                } 
     136            } 
     137            throw new MergeLayersError(); 
    136138        } 
    137139         
     
    155157        public function removeAt(index:int):void 
    156158        { 
     159            if (layers.length <= 1) 
     160                throw new RemoveLayerError(); 
    157161            layers[index].bitmapData.dispose(); 
    158162            layers.splice(index, 1); 
    159163            spriteToView.removeChildAt(index); 
    160             if (index >= currentIndex) 
     164            if (currentIndex > 0 && index >= currentIndex) 
    161165                currentIndex -= 1; 
    162166            compositeAll(); 
    163167            resetLayersIndex(); 
     168        } 
     169         
     170        public function toDataProvider():Array 
     171        { 
     172            var ret:Array = []; 
     173            var count:uint = layers.length; 
     174            for (var i:uint = 0; i < count; i++) { 
     175                ret.push(layers[i]); 
     176            } 
     177            return ret.reverse(); 
    164178        } 
    165179         
     
    169183            for (var i:uint = 0; i < count; i++) { 
    170184                var layer:LayerBitmap = layers[i]; 
    171                 spriteToView.removeChild(layer); 
     185                layer.bitmapData.dispose(); 
     186                if (spriteToView.contains(layer)) 
     187                    spriteToView.removeChild(layer); 
     188                else 
     189                    trace(layer.name + " is not child of spriteToView."); 
    172190            } 
    173191            layers.length = 0; 
     
    207225                layer.index = i; 
    208226            } 
     227        } 
     228         
     229        /** 
     230         * 現在のレイヤー画像の幅を返す 
     231         *  
     232         * @return レイヤー画像の幅 
     233         */ 
     234        public function get width():uint 
     235        { 
     236            return m_width; 
     237        } 
     238         
     239        /** 
     240         * 現在のレイヤー画像の高さを返す 
     241         *  
     242         * @return レイヤー画像の高さ 
     243         */ 
     244        public function get height():uint 
     245        { 
     246            return m_height; 
    209247        } 
    210248         
  • as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/Painter.as

    r3438 r3488  
    313313                var c:uint = m_layers.count; 
    314314                for (var i:uint = 0; i < c; i++) { 
    315                     var layer:LayerBitmap = m_layers[i]; 
    316                     layer.transform.matrix = matrix; 
     315                    m_layers.at(i).applyMatrix(matrix); 
    317316                } 
    318317            } 
    319318            else { 
    320                 m_layers.currentLayer.transform.matrix = matrix
     319                m_layers.currentLayer.applyMatrix(matrix)
    321320            } 
    322321            m_layers.compositeAll(); 
     
    373372         *  
    374373         * @param value 
    375          */         
     374         */ 
    376375        public function set currentLayerAlpha(value:Number):void 
    377376        { 
     
    384383         *  
    385384         * @param value 
    386          */         
     385         */ 
    387386        public function set currentLayerBlendMode(value:String):void 
    388387        {