チェンジセット 3801: as3/gunyarapaint

差分発生行の前後
無視リスト:
コミット日時:
2010/04/16 01:48:24 (3 年前)
コミッタ:
hkrn
ログメッセージ:

added TransparentLineModule?

ファイル:

凡例:

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

    r3639 r3801  
    1919            registerModule(new RoundRectModule(recorder)); 
    2020            registerModule(new TransparentFloodFill(recorder)); 
     21            registerModule(new TransparentLineModule(recorder)); 
    2122        } 
    2223         
  • as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/TransparentLineModule.as

    r3542 r3801  
    11package org.libspark.gunyarapaint.framework.modules 
    22{ 
     3    import flash.display.BlendMode; 
     4     
     5    import org.libspark.gunyarapaint.framework.Pen; 
    36    import org.libspark.gunyarapaint.framework.Recorder; 
    47    import org.libspark.gunyarapaint.framework.commands.CompositeCommand; 
     
    69    import org.libspark.gunyarapaint.framework.commands.MoveToCommand; 
    710     
    8     public final class LineModule extends CanvasModule implements ICanvasModule 
     11    public final class TransparentLineModule extends CanvasModule implements ICanvasModule 
    912    { 
    10         public static const LINE:String = "line"; 
     13        public static const TRANSPARENT_LINE:String = "transparentLine"; 
    1114         
    12         public function LineModule(recorder:Recorder) 
     15        public function TransparentLineModule(recorder:Recorder) 
    1316        { 
    1417            super(recorder); 
     
    1922            validateLayerState(); 
    2023            setCoordinate(x, y); 
     24            m_blendMode = m_recorder.layers.currentLayer.blendMode; 
    2125            m_recorder.startDrawingSession(); 
    2226        } 
     
    2428        public function move(x:Number, y:Number):void 
    2529        { 
     30            var pen:Pen = m_recorder.pen; 
     31            var blendMode:String = pen.blendMode; 
     32            pen.blendMode = BlendMode.ERASE; 
    2633            m_recorder.clear(); 
    2734            m_recorder.resetPen(); 
    2835            m_recorder.moveTo(coordinateX, coordinateY); 
    2936            m_recorder.lineTo(x, y); 
     37            pen.blendMode = blendMode; 
    3038        } 
    3139         
     
    3644                var from:Object = getArgumentsFromCurrentCoordinate(); 
    3745                var to:Object = getArgumentsFromCoordinate(x, y); 
     46                blendMode = BlendMode.ERASE; 
    3847                m_recorder.commitCommand(MoveToCommand.ID, from); 
    3948                m_recorder.commitCommand(LineToCommand.ID, to); 
    4049                m_recorder.commitCommand(CompositeCommand.ID, {}); 
     50                blendMode = m_blendMode; 
    4151            } 
     52            m_recorder.currentLayerBlendMode = m_blendMode; 
    4253            saveCoordinate(x, y); 
    4354        } 
     
    5061        public function get name():String 
    5162        { 
    52             return LINE; 
     63            return TRANSPARENT_LINE; 
    5364        } 
     65         
     66        private var m_blendMode:String; 
    5467    } 
    5568} 
  • as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/TestSuite.as

    r3796 r3801  
    3939    import org.libspark.gunyarapaint.framework.module.RoundRectModuleTest; 
    4040    import org.libspark.gunyarapaint.framework.module.TransparentFloodFillTest; 
     41    import org.libspark.gunyarapaint.framework.module.TransparentLineTest; 
     42    import org.libspark.gunyarapaint.framework.modules.TransparentLineModule; 
    4143 
    4244    [Suite] 
     
    120122        public var transparentFloodFillModule:TransparentFloodFillTest; 
    121123         
     124        public var transparentLineModule:TransparentLineTest; 
     125         
    122126        public var layerBitmapContainer:LayerBitmapContainerTest; 
    123127         
  • as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/TransparentLineTest.as

    r3605 r3801  
    77    import org.libspark.gunyarapaint.framework.modules.CanvasModuleContext; 
    88    import org.libspark.gunyarapaint.framework.modules.ICanvasModule; 
    9     import org.libspark.gunyarapaint.framework.modules.TransparentFloodFill
     9    import org.libspark.gunyarapaint.framework.modules.TransparentLineModule
    1010 
    11     public final class TransparentFloodFillTest 
     11    public final class TransparentLineTest 
    1212    { 
    1313        [Before] 
     
    1717            var recorder:Recorder = ModuleTestUtil.createRecorder(m_bytes); 
    1818            var context:CanvasModuleContext = new CanvasModuleContext(recorder); 
    19             m_module = context.getModule(TransparentFloodFill.TRANSPARENT_FLOOD_FILL); 
     19            m_module = context.getModule(TransparentLineModule.TRANSPARENT_LINE); 
    2020        } 
    2121         
    2222        [Test] 
    23         public function isFloodFillModule():void 
     23        public function isTransparentLineModule():void 
    2424        { 
    25             Assert.assertTrue(m_module is TransparentFloodFill); 
    26             Assert.assertEquals(m_module.name, TransparentFloodFill.TRANSPARENT_FLOOD_FILL); 
     25            Assert.assertTrue(m_module is TransparentLineModule); 
     26            Assert.assertEquals(m_module.name, TransparentLineModule.TRANSPARENT_LINE); 
    2727        } 
    2828         
    2929        [Test] 
    30         public function floodFill():void 
     30        public function drawWithoutMoving():void 
     31        { 
     32            m_module.start(1, 1); 
     33            m_module.stop(1, 1); 
     34            ModuleTestUtil.countCommands(0, m_bytes); 
     35        } 
     36         
     37        [Test] 
     38        public function drawWithMoving():void 
    3139        { 
    3240            m_module.start(1, 1); 
    3341            m_module.move(2, 2); 
    3442            m_module.stop(3, 3); 
    35             ModuleTestUtil.countCommands(6, m_bytes); 
     43            ModuleTestUtil.countCommands(5, m_bytes); 
    3644        } 
    3745         
     
    3947        public function getLineSegment():void 
    4048        { 
    41             ModuleTestUtil.getLineSegment(m_module, false); 
     49            ModuleTestUtil.getLineSegment(m_module, true); 
    4250        } 
    4351