- コミット日時:
- 2010/03/06 18:12:43 (3 年前)
- ファイル:
-
- as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/LayerBitmap.as (更新) (2 diffs)
- as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/LayerBitmapCollection.as (更新) (5 diffs)
- as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/Painter.as (更新) (3 diffs)
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/LayerBitmap.as
r3438 r3488 5 5 import flash.display.IBitmapDrawable; 6 6 import flash.geom.ColorTransform; 7 import flash.geom.Matrix; 7 8 8 9 public final class LayerBitmap extends Bitmap … … 66 67 } 67 68 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 68 77 /** 69 78 * 指定された位置にバケツツールを適用する as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/LayerBitmapCollection.as
r3438 r3488 5 5 6 6 import org.libspark.gunyarapaint.framework.errors.MergeLayersError; 7 7 import org.libspark.gunyarapaint.framework.errors.RemoveLayerError; 8 8 9 public class LayerBitmapCollection 9 10 { … … 117 118 public function mergeAt(index:int):void 118 119 { 119 var current:LayerBitmap = layers[index];120 var prev:LayerBitmap = layers[index - 1];121 120 // 両方可視である必要がある 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(); 136 138 } 137 139 … … 155 157 public function removeAt(index:int):void 156 158 { 159 if (layers.length <= 1) 160 throw new RemoveLayerError(); 157 161 layers[index].bitmapData.dispose(); 158 162 layers.splice(index, 1); 159 163 spriteToView.removeChildAt(index); 160 if ( index >= currentIndex)164 if (currentIndex > 0 && index >= currentIndex) 161 165 currentIndex -= 1; 162 166 compositeAll(); 163 167 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(); 164 178 } 165 179 … … 169 183 for (var i:uint = 0; i < count; i++) { 170 184 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."); 172 190 } 173 191 layers.length = 0; … … 207 225 layer.index = i; 208 226 } 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; 209 247 } 210 248 as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/Painter.as
r3438 r3488 313 313 var c:uint = m_layers.count; 314 314 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); 317 316 } 318 317 } 319 318 else { 320 m_layers.currentLayer. transform.matrix = matrix;319 m_layers.currentLayer.applyMatrix(matrix); 321 320 } 322 321 m_layers.compositeAll(); … … 373 372 * 374 373 * @param value 375 */ 374 */ 376 375 public function set currentLayerAlpha(value:Number):void 377 376 { … … 384 383 * 385 384 * @param value 386 */ 385 */ 387 386 public function set currentLayerBlendMode(value:String):void 388 387 {

