チェンジセット 3492
- コミット日時:
- 2010/03/06 23:04:26 (3 年前)
- ファイル:
-
- as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/CommandCollection.as (更新) (1 diff)
- as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/LayerBitmapCollection.as (更新) (4 diffs)
- as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/Logger.as (削除)
- as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/Recorder.as (更新) (5 diffs)
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/CommandCollection.as
r3438 r3492 123 123 } 124 124 125 /** 126 * 引数からコマンドオブジェクトを返す 127 * 128 * @return ICommand コマンドオブジェクト 129 * @throws ArgumentError 引数の値が0x80または0x40とビット演算レベルで一致する場合 130 */ 131 public function getCommand(id:uint):ICommand 132 { 133 if (id & 0x80 || id & 0x40) { 134 throw new ArgumentError(); 135 } 136 else { 137 return m_commands[id]; 138 } 139 } 140 125 141 protected var m_commands:Vector.<ICommand>; 126 142 } as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/LayerBitmapCollection.as
r3488 r3492 101 101 * 現在のレイヤーを下のレイヤーと合成する 102 102 * 103 * @throws MergeLayersError レイヤーが一つ、あるいは対象のうち片方が不可視の場合 103 104 */ 104 105 public function merge():void … … 115 116 * 116 117 * @param index レイヤー番号 118 * @throws MergeLayersError レイヤーが一つ、あるいは対象のうち片方が不可視の場合 117 119 */ 118 120 public function mergeAt(index:int):void 119 121 { 120 // 両方可視である必要がある122 // レイヤーは必ず2つ以上 121 123 if (currentIndex > 0) { 122 124 var current:LayerBitmap = layers[index]; 123 125 var prev:LayerBitmap = layers[index - 1]; 126 // 両方可視である必要がある 124 127 if (current.visible && prev.visible) { 125 128 current.compositeTo(prev.bitmapData); … … 141 144 * 現在のレイヤーを削除する 142 145 * 146 * @throws RemoveLayerError レイヤーが一つの場合 143 147 */ 144 148 public function remove():void … … 154 158 * 155 159 * @param index 現在のレイヤー番号 160 * @throws RemoveLayerError レイヤーが一つの場合 156 161 */ 157 162 public function removeAt(index:int):void as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/Recorder.as
r3487 r3492 1 1 package org.libspark.gunyarapaint.framework 2 2 { 3 import flash.utils.ByteArray; 4 import flash.utils.Endian; 5 3 6 import org.libspark.gunyarapaint.framework.commands.ICommand; 4 7 import org.libspark.gunyarapaint.framework.events.CommandEvent; … … 8 11 public static const DEFAULT_UNDO_MAX:uint = 16; 9 12 10 public function Recorder( logger:Logger)13 public function Recorder(bytes:ByteArray, commands:CommandCollection = null) 11 14 { 12 m_logger = logger; 15 bytes.endian = Endian.BIG_ENDIAN; 16 bytes.position = 0; 17 m_bytes = bytes; 18 m_command = commands ? commands : new CommandCollection(); 13 19 super(); 14 20 } … … 23 29 public function prepare(width:int, height:int, undo:int):void 24 30 { 25 m_ logger.writeHeader(PAINTER_LOG_VERSION, width, height, undo);26 m_logger.loadCommands();31 m_command.loadCommands(); 32 writeHeader(PAINTER_LOG_VERSION, width, height, undo); 27 33 createPainter(width, height, undo); 28 34 setUndo(new UndoStack(painter, undo)); 35 } 36 37 /** 38 * ログヘッダーを書き出す 39 * 40 * @param version ログのバージョン番号 41 * @param width 画像の幅 42 * @param height 画像の高さ 43 * @param undo やり直しできる回数 44 */ 45 private function writeHeader(version:uint, width:uint, height:uint, undo:uint):void 46 { 47 var signature:String = "GUNYARA_PAINT:" 48 + (version / 100) + ":" 49 + ((version % 100) / 10) + ":" 50 + (version % 10) + ":" 51 m_bytes.writeUTFBytes(signature); 52 m_bytes.writeShort(width); 53 m_bytes.writeShort(height); 54 m_bytes.writeShort(undo); 29 55 } 30 56 … … 37 63 public function commitCommand(id:uint, args:Object):void 38 64 { 39 var command:ICommand = m_ logger.getCommand(id);40 command.write(m_ logger.bytes, args);65 var command:ICommand = m_command.getCommand(id); 66 command.write(m_bytes, args); 41 67 command.execute(this); 42 68 if (hasEventListener(CommandEvent.COMMITTED)) … … 44 70 } 45 71 46 private var m_logger:Logger; 72 private var m_command:CommandCollection; 73 private var m_bytes:ByteArray; 47 74 } 48 75 }

