チェンジセット 3542
- コミット日時:
- 2010/03/14 22:08:11 (2 年前)
- ファイル:
-
- as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/CanvasModule.as (更新) (4 diffs)
- as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/CircleModule.as (更新) (5 diffs)
- as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/DropperModule.as (更新) (1 diff)
- as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/EllipseModule.as (更新) (1 diff)
- as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/FloodFillModule.as (更新) (1 diff)
- as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/FreeHandModule.as (更新) (1 diff)
- as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/ICanvasModule.as (更新) (2 diffs)
- as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/LineModule.as (更新) (1 diff)
- as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/PixelModule.as (更新) (1 diff)
- as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/RectModule.as (更新) (1 diff)
- as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/RoundRectModule.as (更新) (1 diff)
- as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/CircleModuleTest.as (更新) (3 diffs)
- as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/DropperModuleTest.as (更新) (1 diff)
- as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/EllipseModuleTest.as (更新) (2 diffs)
- as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/FloodFillModuleTest.as (更新) (1 diff)
- as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/FreeHandModuleTest.as (更新) (2 diffs)
- as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/LineModuleTest.as (更新) (2 diffs)
- as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/ModuleTestUtil.as (更新) (2 diffs)
- as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/PixelModuleTest.as (更新) (2 diffs)
- as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/RectModuleTest.as (更新) (2 diffs)
- as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/RoundRectModuleTest.as (更新) (2 diffs)
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/CanvasModule.as
r3532 r3542 102 102 103 103 /** 104 * 最後に移動した座標を保存する 104 * 始点と終点を取得する(現在は単体テスト用に使われているのみ) 105 * 106 * @param start 始点 107 * @param end 終点 108 */ 109 public function getLineSegment(start:Point, end:Point):void 110 { 111 start.x = s_startPointX; 112 start.y = s_startPointY; 113 end.x = s_endPointX; 114 end.y = s_endPointY; 115 } 116 117 /** 118 * 始点と終点の座標を保存する 105 119 * 106 120 * @param x 107 121 * @param y 108 122 */ 109 p ublicfunction saveCoordinate(x:Number, y:Number):void110 { 111 s_ coordinateXWithButtonDown= s_coordinateX;112 s_ coordinateYWithButtonDown= s_coordinateY;113 s_ coordinateXWithButtonUp= x;114 s_ coordinateYWithButtonUp= y;123 protected function saveCoordinate(x:Number, y:Number):void 124 { 125 s_startPointX = s_coordinateX; 126 s_startPointY = s_coordinateY; 127 s_endPointX = x; 128 s_endPointY = y; 115 129 } 116 130 … … 138 152 protected function setCoordinate(x:Number, y:Number):void 139 153 { 140 if (s_should StartAfterDrawing) {141 s_coordinateX = s_ coordinateXWithButtonUp;142 s_coordinateY = s_ coordinateYWithButtonUp;154 if (s_shouldDrawFromEndPoint) { 155 s_coordinateX = s_endPointX; 156 s_coordinateY = s_endPointY; 143 157 } 144 else if (s_should StartBeforeDrawing) {145 s_coordinateX = s_ coordinateXWithButtonDown;146 s_coordinateY = s_ coordinateYWithButtonDown;158 else if (s_shouldDrawFromStartPoint) { 159 s_coordinateX = s_startPointX; 160 s_coordinateY = s_startPointY; 147 161 } 148 162 else { … … 224 238 } 225 239 226 /** 227 * 開始座標を描写終了後の座標に設定するかどうか (R) 228 * 229 * @param value 230 */ 231 public function set shouldStartAfterDrawing(value:Boolean):void 232 { 233 s_shouldStartAfterDrawing = value; 234 } 235 236 /** 237 * 開始座標を描写開始時の座標に設定するかどうか (T) 238 * 239 * @param value 240 */ 241 public function set shouldStartBeforeDrawing(value:Boolean):void 242 { 243 s_shouldStartBeforeDrawing = value; 240 public function set shouldDrawFromStartPoint(value:Boolean):void 241 { 242 s_shouldDrawFromStartPoint = value; 243 } 244 245 public function set shouldDrawFromEndPoint(value:Boolean):void 246 { 247 s_shouldDrawFromEndPoint = value; 244 248 } 245 249 … … 341 345 private static var s_coordinateX:Number = 0; 342 346 private static var s_coordinateY:Number = 0; 343 private static var s_ coordinateXWithButtonUp:Number = 0;344 private static var s_ coordinateYWithButtonUp:Number = 0;345 private static var s_ coordinateXWithButtonDown:Number = 0;346 private static var s_ coordinateYWithButtonDown:Number = 0;347 private static var s_startPointX:Number = 0; 348 private static var s_startPointY:Number = 0; 349 private static var s_endPointX:Number = 0; 350 private static var s_endPointY:Number = 0; 347 351 private static var s_keyA:Boolean = false; 348 352 private static var s_keyQ:Boolean = false; 349 private static var s_should StartBeforeDrawing:Boolean = false;350 private static var s_should StartAfterDrawing:Boolean = false;353 private static var s_shouldDrawFromStartPoint:Boolean = false; 354 private static var s_shouldDrawFromEndPoint:Boolean = false; 351 355 protected var m_recorder:Recorder; 352 356 } as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/CircleModule.as
r3532 r3542 14 14 public function CircleModule(recorder:Recorder) 15 15 { 16 m_rectangle = new Rectangle(0, 0, 0, 0); 16 17 super(recorder); 17 18 } … … 29 30 m_recorder.clear(); 30 31 m_recorder.resetPen(); 31 m_recorder.moveTo( s_rectangle.x, s_rectangle.y);32 m_recorder.drawCircle( s_rectangle.width);32 m_recorder.moveTo(m_rectangle.x, m_rectangle.y); 33 m_recorder.drawCircle(m_rectangle.width); 33 34 } 34 35 … … 40 41 m_recorder.commitCommand( 41 42 MoveToCommand.ID, 42 getArgumentsFromCoordinate( s_rectangle.x, s_rectangle.y)43 getArgumentsFromCoordinate(m_rectangle.x, m_rectangle.y) 43 44 ); 44 45 m_recorder.commitCommand( 45 46 DrawCircleCommand.ID, 46 { "radius": s_rectangle.width }47 { "radius": m_rectangle.width } 47 48 ); 48 49 m_recorder.commitCommand( … … 51 52 ); 52 53 } 54 saveCoordinate(x, y); 53 55 } 54 56 … … 63 65 } 64 66 65 pr otectedfunction storeCircleCoordinate(x:Number, y:Number):void67 private function storeCircleCoordinate(x:Number, y:Number):void 66 68 { 67 69 var dx:Number = x - coordinateX; 68 70 var dy:Number = y - coordinateY; 69 71 if (key_A) { 70 s_rectangle.x = x + dx;71 s_rectangle.y = y - dy;72 m_rectangle.x = x + dx; 73 m_rectangle.y = y - dy; 72 74 } 73 75 else if (key_Q) { 74 s_rectangle.x = x - dx;75 s_rectangle.y = x + dy;76 m_rectangle.x = x - dx; 77 m_rectangle.y = x + dy; 76 78 } 77 79 else { 78 s_rectangle.x = coordinateX;79 s_rectangle.y = coordinateY;80 m_rectangle.x = coordinateX; 81 m_rectangle.y = coordinateY; 80 82 } 81 s_rectangle.width = Math.sqrt(dx * dx + dy * dy); 82 s_rectangle.height = 0; 83 m_rectangle.width = Math.sqrt(dx * dx + dy * dy); 83 84 } 84 85 85 private static var s_rectangle:Rectangle = new Rectangle();86 private var m_rectangle:Rectangle; 86 87 } 87 88 } as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/DropperModule.as
r3524 r3542 26 26 { 27 27 drop(x, y); 28 saveCoordinate(x, y); 28 29 } 29 30 as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/EllipseModule.as
r3532 r3542 37 37 // TODO: implement this 38 38 } 39 saveCoordinate(x, y); 39 40 } 40 41 as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/FloodFillModule.as
r3524 r3542 33 33 public function stop(x:Number, y:Number):void 34 34 { 35 saveCoordinate(x, y); 35 36 } 36 37 as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/FreeHandModule.as
r3532 r3542 76 76 {} 77 77 ); 78 saveCoordinate(x, y); 78 79 } 79 80 as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/ICanvasModule.as
r3524 r3542 38 38 */ 39 39 function interrupt(x:Number, y:Number):void; 40 41 /**42 * 最後に移動した位置を保存する43 *44 * @param x x座標45 * @param y y座標46 function saveCoordinate(x:Number, y:Number):void;47 */48 40 49 41 /** … … 113 105 114 106 function set keyA(value:Boolean):void; 107 115 108 function set keyQ(value:Boolean):void; 116 function set shouldStartAfterDrawing(value:Boolean):void; 117 function set shouldStartBeforeDrawing(value:Boolean):void; 109 110 /** 111 * 描写開始時に終点固定を設定するかどうか (T) 112 * 113 */ 114 function set shouldDrawFromStartPoint(value:Boolean):void; 115 116 /** 117 * 描写開始時に始点固定を設定するかどうか (R) 118 * 119 */ 120 function set shouldDrawFromEndPoint(value:Boolean):void; 118 121 119 122 /** as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/LineModule.as
r3532 r3542 40 40 m_recorder.commitCommand(CompositeCommand.ID, {}); 41 41 } 42 saveCoordinate(x, y); 42 43 } 43 44 as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/PixelModule.as
r3532 r3542 26 26 public function stop(x:Number, y:Number):void 27 27 { 28 saveCoordinate(x, y); 28 29 } 29 30 as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/RectModule.as
r3532 r3542 37 37 // TODO: implement this 38 38 } 39 saveCoordinate(x, y); 39 40 } 40 41 as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/RoundRectModule.as
r3532 r3542 30 30 // TODO: implement this 31 31 } 32 saveCoordinate(x, y); 32 33 } 33 34 as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/CircleModuleTest.as
r3534 r3542 6 6 import org.libspark.gunyarapaint.framework.Recorder; 7 7 import org.libspark.gunyarapaint.framework.commands.ICommand; 8 import org.libspark.gunyarapaint.framework.modules.CanvasModule; 8 9 import org.libspark.gunyarapaint.framework.modules.CanvasModuleContext; 9 10 import org.libspark.gunyarapaint.framework.modules.CircleModule; … … 33 34 m_module.start(1, 1); 34 35 m_module.stop(1, 1); 35 var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 36 Assert.assertEquals(0, commands.length); 36 ModuleTestUtil.countCommands(0, m_bytes); 37 37 } 38 38 … … 43 43 m_module.move(2, 2); 44 44 m_module.stop(3, 3); 45 var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 46 Assert.assertEquals(3, commands.length); 45 ModuleTestUtil.countCommands(3, m_bytes); 46 } 47 48 [Test] 49 public function getLineSegment():void 50 { 51 ModuleTestUtil.getLineSegment(m_module); 47 52 } 48 53 as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/DropperModuleTest.as
r3534 r3542 34 34 m_module.move(2, 2); 35 35 m_module.stop(3, 3); 36 var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 37 Assert.assertEquals(3, commands.length); 36 ModuleTestUtil.countCommands(3, m_bytes); 37 } 38 39 [Test] 40 public function getLineSegment():void 41 { 42 ModuleTestUtil.getLineSegment(m_module); 38 43 } 39 44 as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/EllipseModuleTest.as
r3534 r3542 35 35 m_module.start(1, 1); 36 36 m_module.stop(1, 1); 37 var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 38 Assert.assertEquals(0, commands.length); 37 ModuleTestUtil.countCommands(0, m_bytes); 39 38 } 40 39 … … 44 43 } 45 44 45 [Test] 46 public function getLineSegment():void 47 { 48 ModuleTestUtil.getLineSegment(m_module); 49 } 50 46 51 private var m_bytes:ByteArray; 47 52 private var m_module:ICanvasModule; as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/FloodFillModuleTest.as
r3534 r3542 34 34 m_module.move(2, 2); 35 35 m_module.stop(3, 3); 36 var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 37 Assert.assertEquals(2, commands.length); 36 ModuleTestUtil.countCommands(2, m_bytes); 37 } 38 39 [Test] 40 public function getLineSegment():void 41 { 42 ModuleTestUtil.getLineSegment(m_module); 38 43 } 39 44 as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/FreeHandModuleTest.as
r3534 r3542 33 33 m_module.start(1, 1); 34 34 m_module.stop(1, 1); 35 var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 36 Assert.assertEquals(7, commands.length); 35 ModuleTestUtil.countCommands(7, m_bytes); 37 36 } 38 37 … … 43 42 m_module.move(2, 2); 44 43 m_module.stop(3, 3); 45 var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 46 Assert.assertEquals(3, commands.length); 44 ModuleTestUtil.countCommands(3, m_bytes); 45 } 46 47 [Test] 48 public function getLineSegment():void 49 { 50 ModuleTestUtil.getLineSegment(m_module); 47 51 } 48 52 as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/LineModuleTest.as
r3534 r3542 33 33 m_module.start(1, 1); 34 34 m_module.stop(1, 1); 35 var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 36 Assert.assertEquals(0, commands.length); 35 ModuleTestUtil.countCommands(0, m_bytes); 37 36 } 38 37 … … 43 42 m_module.move(2, 2); 44 43 m_module.stop(3, 3); 45 var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 46 Assert.assertEquals(3, commands.length); 44 ModuleTestUtil.countCommands(3, m_bytes); 45 } 46 47 [Test] 48 public function getLineSegment():void 49 { 50 ModuleTestUtil.getLineSegment(m_module); 47 51 } 48 52 as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/ModuleTestUtil.as
r3534 r3542 2 2 { 3 3 import flash.errors.IllegalOperationError; 4 import flash.geom.Point; 4 5 import flash.utils.ByteArray; 5 6 7 import org.flexunit.Assert; 6 8 import org.libspark.gunyarapaint.framework.FakePainter; 7 9 import org.libspark.gunyarapaint.framework.Parser; 8 10 import org.libspark.gunyarapaint.framework.Recorder; 9 11 import org.libspark.gunyarapaint.framework.commands.ICommand; 12 import org.libspark.gunyarapaint.framework.modules.CanvasModule; 13 import org.libspark.gunyarapaint.framework.modules.ICanvasModule; 10 14 11 15 internal final class ModuleTestUtil … … 39 43 return commands; 40 44 } 45 46 public static function countCommands(expected:uint, bytes:ByteArray):void 47 { 48 Assert.assertEquals(expected, getCommands(bytes).length); 49 } 50 51 public static function getLineSegment(module:ICanvasModule):void 52 { 53 var start:Point = new Point(); 54 var end:Point = new Point(); 55 module.start(12, 34); 56 module.stop(56, 78); 57 CanvasModule(module).getLineSegment(start, end); 58 Assert.assertEquals(start.x, 12); 59 Assert.assertEquals(start.y, 34); 60 Assert.assertEquals(end.x, 56); 61 Assert.assertEquals(end.y, 78); 62 } 41 63 } 42 64 } as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/PixelModuleTest.as
r3534 r3542 33 33 m_module.start(1, 1); 34 34 m_module.stop(1, 1); 35 var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 36 Assert.assertEquals(1, commands.length); 35 ModuleTestUtil.countCommands(1, m_bytes); 37 36 } 38 37 … … 43 42 m_module.move(2, 2); 44 43 m_module.stop(3, 3); 45 var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 46 Assert.assertEquals(2, commands.length); 44 ModuleTestUtil.countCommands(2, m_bytes); 45 } 46 47 [Test] 48 public function getLineSegment():void 49 { 50 ModuleTestUtil.getLineSegment(m_module); 47 51 } 48 52 as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/RectModuleTest.as
r3534 r3542 33 33 m_module.start(1, 1); 34 34 m_module.stop(1, 1); 35 var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 36 Assert.assertEquals(0, commands.length); 35 ModuleTestUtil.countCommands(0, m_bytes); 37 36 } 38 37 … … 42 41 } 43 42 43 [Test] 44 public function getLineSegment():void 45 { 46 ModuleTestUtil.getLineSegment(m_module); 47 } 48 44 49 private var m_bytes:ByteArray; 45 50 private var m_module:ICanvasModule; as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/RoundRectModuleTest.as
r3534 r3542 33 33 m_module.start(1, 1); 34 34 m_module.stop(1, 1); 35 var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 36 Assert.assertEquals(0, commands.length); 35 ModuleTestUtil.countCommands(0, m_bytes); 37 36 } 38 37 … … 42 41 } 43 42 43 [Test] 44 public function getLineSegment():void 45 { 46 ModuleTestUtil.getLineSegment(m_module); 47 } 48 44 49 private var m_bytes:ByteArray; 45 50 private var m_module:ICanvasModule;

