チェンジセット 1117
- コミット日時:
- 2008/08/27 18:17:57 (5 年前)
- ファイル:
-
- as3/gunyarapaint/trunk/gunyarapaint/src/gplogplayer.mxml (更新) (4 diffs)
- as3/gunyarapaint/trunk/gunyarapaint/src/gunyarapaint.as (更新) (4 diffs)
- as3/gunyarapaint/trunk/gunyarapaint/src/gunyarapaint.mxml (更新) (2 diffs)
- as3/gunyarapaint/trunk/gunyarapaint/src/gunyarapaint/controls/GPCanvas.as (更新) (4 diffs)
- as3/gunyarapaint/trunk/gunyarapaint/src/gunyarapaint/controls/GPCanvasWindowControl.as (更新) (4 diffs)
- as3/gunyarapaint/trunk/gunyarapaint/src/gunyarapaint/entities/GPLogger.as (更新) (10 diffs)
- as3/gunyarapaint/trunk/gunyarapaint/src/gunyarapaint/entities/GPPen.as (更新) (1 diff)
- as3/gunyarapaint/trunk/gunyarapaint/src/gunyarapaint/utils/MiscUtils.as (追加)
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/gunyarapaint/trunk/gunyarapaint/src/gplogplayer.mxml
r1115 r1117 18 18 import gunyarapaint.entities.GPLogger; 19 19 import gunyarapaint.controls.GPCanvas; 20 import gunyarapaint.utils.MiscUtils; 20 21 22 import mx.controls.Alert; 21 23 import mx.events.FlexEvent; 22 24 import mx.events.SliderEvent; … … 29 31 private var postUrl:String; 30 32 33 /*** debug ***/ 34 private var debugOekakiId:uint = 0; // 0でデバッグしない 35 private var commDebug:Com; 36 private var debugCheckPngUrl:String; 37 private var debugCheckPng:ByteArray; 38 /*** debug end ***/ 39 31 40 public function init():void { 32 41 this.enabled = false; 33 42 34 43 // for debug 35 // parameters['oelogUrl'] = 'http://dic.nicovideo.jp/oelog/3647'; 44 if (debugOekakiId != 0) { 45 parameters['oelogUrl'] = 'http://dic.nicovideo.jp/oelog/' + debugOekakiId; 46 debugCheckPngUrl = 'http://dic.nicovideo.jp/oekaki/' + debugOekakiId + '.png'; 47 commDebug = new Com(); 48 commDebug.sendGetUrlRequest(debugCheckPngUrl); 49 commDebug.addEventListener('completeGetData', function(evt:Event):void { debugCheckPng = commDebug.getData();}); 50 } 36 51 37 52 if (parameters['oelogUrl']) { … … 105 120 106 121 private function refButtonHandler(evt:Event):void { 107 Com.redirectOekakiForm(postUrl, oekakiId); 122 if (debugCheckPng) { 123 checkImage(); 124 } else if (postUrl) { 125 Com.redirectOekakiForm(postUrl, oekakiId); 126 } else { 127 Alert.show('続きが描けません!'); 128 } 108 129 } 109 130 … … 111 132 playButton.enabled = false; 112 133 createLogCan(); 113 // FIXME:!!!!!!!! 114 // logcan.addEventListener('completePlayLog', completePlayLogHandler); 134 logcan.addEventListener('completePlayLog', completePlayLogHandler); 115 135 logger.play(logcan, playSpeedHSlider.value); 116 136 } 117 137 118 138 private function completePlayLogHandler(evt:Event):void { 119 139 playButton.enabled = true; 120 } 140 } 141 142 private function checkImage():void { 143 if (MiscUtils.compareObject( 144 logcan.getPNGImage(), debugCheckPng)) { 145 Alert.show('合ってる。'); 146 } else { 147 Alert.show('違うよ!'); 148 } 149 } 121 150 ]]> 122 151 </mx:Script> as3/gunyarapaint/trunk/gunyarapaint/src/gunyarapaint.as
r1115 r1117 1 private const DEBUG:Boolean = true;1 private const DEBUG:Boolean = false; 2 2 3 3 import flash.events.Event; … … 7 7 import gunyarapaint.controls.GPCanvas; 8 8 import gunyarapaint.entities.GPLogger; 9 import gunyarapaint.utils.MiscUtils; 9 10 10 11 import mx.controls.Alert; … … 95 96 if (DEBUG) { 96 97 logPlayButton.addEventListener(FlexEvent.BUTTON_DOWN, playLogHandler); 98 checkPngButton.addEventListener(FlexEvent.BUTTON_DOWN, checkPngHandler); 99 logPlayButton.visible = true; 100 checkPngButton.visible = true; 97 101 } 98 102 … … 239 243 } 240 244 245 private var logger:GPLogger; 246 private var logcan:GPCanvas; 247 241 248 private function playLogHandler(evt:FlexEvent):void { 242 var logger:GPLogger = gpCanvas.logger;243 var logcan:GPCanvas= logger.createViewerCanvas(null);249 logger = gpCanvas.logger; 250 logcan = logger.createViewerCanvas(null); 244 251 this.addChild(logcan); 245 logger.play(logcan, 100); 246 } 252 logger.play(logcan, 1000); 253 } 254 255 private function checkPngHandler(evt:FlexEvent):void { 256 if (MiscUtils.compareObject( 257 logcan.getPNGImage(), gpCanvas.getPNGImage())) { 258 Alert.show('合ってる。'); 259 } else { 260 Alert.show('違うよ!'); 261 } 262 } as3/gunyarapaint/trunk/gunyarapaint/src/gunyarapaint.mxml
r1115 r1117 30 30 <mx:Button id="undoButton" x="469" y="36" label="アンドゥ" enabled="false" paddingLeft="3" paddingRight="3"/> 31 31 <mx:Button id="redoButton" x="555" y="36" label="リドゥ" enabled="false" paddingLeft="3" paddingRight="3"/> 32 <mx:Button id="logPlayButton" x="610" y="36" label="ログプレイ"/>33 32 </mx:Canvas> 34 33 <gpcontrol:PenDetailWindowControl id="penDetailWindow" x="10" y="101" layout="absolute" title="ペン"> … … 36 35 <gpcontrol:GPCanvasWindowControl id="gpCanvasWindow" x="146" y="101" width="379" height="382" layout="absolute" title="キャンバス"> 37 36 </gpcontrol:GPCanvasWindowControl> 37 <mx:Button id="logPlayButton" x="601" y="101" label="ログプレイ" visible="false"/> 38 <mx:Button id="checkPngButton" x="601" y="131" label="同一check" visible="false"/> 38 39 </mx:Application> as3/gunyarapaint/trunk/gunyarapaint/src/gunyarapaint/controls/GPCanvas.as
r1115 r1117 224 224 private var currentPoint:Point = new Point; 225 225 226 public function moveTo(x:Number, y:Number):void { 226 // 0.0.1の互換性のため 227 public function oldMoveTo(x:Number, y:Number):void { 227 228 lineShape.graphics.moveTo(x, y); 228 229 setLineStyle(); … … 231 232 isMoveTo = true; 232 233 currentPoint.x = x; 233 currentPoint.y = y; 234 } 235 public function lineTo(x:Number, y:Number):void { 236 if (x == currentPoint.x && 237 y == currentPoint.y) { 238 return; 239 } 234 currentPoint.y = y; 235 } 236 237 public function moveTo(x:Number, y:Number):void { 238 x = Math.floor(x) + 0.5; 239 y = Math.floor(y) + 0.5; 240 oldMoveTo(x, y); 241 } 242 243 // 0.0.1の互換性のため 244 public function oldLineTo(x:Number, y:Number):void { 240 245 lineShape.graphics.lineTo(x, y); 241 246 logWrite(['lineTo', x, y]); 242 247 isDrawnLine = true; 243 248 currentPoint.x = x; 244 currentPoint.y = y; 249 currentPoint.y = y; 250 } 251 252 public function lineTo(x:Number, y:Number):void { 253 x = Math.floor(x) + 0.5; 254 y = Math.floor(y) + 0.5; 255 if (x == currentPoint.x && 256 y == currentPoint.y) { 257 return; 258 } 259 oldLineTo(x, y); 245 260 } 246 261 247 262 public function drawRect(x:Number, y:Number, width:uint, height:uint):void { 263 x = Math.floor(x) + 0.5; 264 y = Math.floor(y) + 0.5; 248 265 setLineStyle(); 249 266 lineShape.graphics.drawRect(x, y, width, height); … … 256 273 } 257 274 258 public function drawCircle(x:Number, y:Number, radius:Number):void { 275 public function drawCircle(radius:Number):void { 276 var x:Number = currentPoint.x; 277 var y:Number = currentPoint.y; 259 278 setLineStyle(); 260 279 lineShape.graphics.drawCircle(x, y, radius); 261 logWrite(['drawCircle', x, y, radius]); 280 // moveToでx, yは保存されているので、半径のみ保存 281 logWrite(['drawCircle', radius]); 262 282 } 263 283 … … 376 396 return _log.getCompressedLog(); 377 397 } 398 public function completePlayLog():void { 399 this.dispatchEvent(new Event('completePlayLog')); 400 } 378 401 } 379 402 } as3/gunyarapaint/trunk/gunyarapaint/src/gunyarapaint/controls/GPCanvasWindowControl.as
r1115 r1117 21 21 public function GPCanvasWindowControl() { 22 22 super(); 23 this.setStyle('backgroundColor', 0x000000); 23 24 // this.setStyle('backgroundAlpha', 0); 24 25 … … 49 50 } 50 51 52 public function moveCanvas():void { 53 var deg:Number = _canvas.rotation; 54 var rad:Number = deg * Math.PI / 180; 55 var scale:Number = _container.scaleX; 56 57 // TODO: dasai 58 if (deg >= 0) { 59 if (deg <= 90) { 60 _container.x = (Math.sin(rad) * _canvas.canvasHeight * scale); 61 _container.y = 0; 62 } else { 63 _container.x = _canvas.canvasHeight * scale * Math.sin(rad) - Math.cos(rad) * _canvas.canvasWidth * scale; 64 _container.y = - Math.cos(rad) * _canvas.canvasHeight * scale; 65 } 66 } else { 67 if (deg >= -90) { 68 _container.x = 0; 69 _container.y = - Math.sin(rad) * _canvas.canvasWidth * scale; 70 } else { 71 _container.x = - Math.cos(rad) * _canvas.canvasWidth * scale; 72 _container.y = - Math.sin(rad) * _canvas.canvasWidth * scale - Math.cos(rad) * _canvas.canvasHeight * scale; 73 } 74 } 75 } 76 51 77 public function zoomCanvas(m:Number):void { 52 78 //_canvas.scaleX = m; … … 60 86 _container.scaleX = m; 61 87 _container.scaleY = m; 88 moveCanvas(); 62 89 /* 63 90 this.validateNow(); … … 79 106 public function rotateCanvas(deg:int):void { 80 107 _canvas.rotation = deg; 81 var rad:Number = deg * Math.PI / 180; 82 // TODO: dasai 83 if (deg >= 0) { 84 if (deg <= 90) { 85 _container.x = Math.sin(rad) * _canvas.canvasHeight * _container.scaleX; 86 _container.y = 0; 87 } else { 88 _container.x = _canvas.canvasHeight * Math.sin(rad) - Math.cos(rad) * _canvas.canvasWidth * _container.scaleX; 89 _container.y = - Math.cos(rad) * _canvas.canvasHeight * _container.scaleY; 90 } 91 } else { 92 if (deg >= -90) { 93 _container.x = 0; 94 _container.y = - Math.sin(rad) * _canvas.canvasWidth * _container.scaleY; 95 } else { 96 _container.x = - Math.cos(rad) * _canvas.canvasWidth * _container.scaleX; 97 _container.y = - Math.sin(rad) * _canvas.canvasWidth - Math.cos(rad) * _canvas.canvasHeight * _container.scaleY; 98 } 99 } 100 } 101 } 108 moveCanvas(); 109 } 110 } 102 111 } as3/gunyarapaint/trunk/gunyarapaint/src/gunyarapaint/entities/GPLogger.as
r1115 r1117 167 167 break; 168 168 default: 169 Alert ('対応していないラインスタイルがログされました!');169 Alert.show('対応していないラインスタイルがログされました!'); 170 170 break; 171 171 } … … 189 189 break; 190 190 case 'drawCircle': 191 // 直前のmoveToの座標を中心。よって、半径のみ保存 191 192 writeByte(ACTION_DRAW_CIRCLE); 193 writeDouble(info[1]); 192 194 break; 193 195 194 196 default: 195 Alert ('対応していないアクションがログされました!');197 Alert.show('対応していないアクションがログされました!'); 196 198 return; 197 199 } … … 273 275 switch (action) { 274 276 case GPLogger.ACTION_MOVETO: 275 _playCanvas.moveTo(a[1], a[2]); 277 if (compatibility_0_0_1) { 278 _playCanvas.oldMoveTo(a[1], a[2]); 279 } else { 280 _playCanvas.moveTo(a[1] + 0.5, a[2] + 0.5); 281 } 276 282 break; 277 283 case GPLogger.ACTION_LINETO: 278 _playCanvas.lineTo(a[1], a[2]); 279 break; 280 case GPLogger.ACTION_DRAW_RECT: 281 _playCanvas.drawRect(a[1], a[2], a[3], a[4]); 282 break; 284 if (compatibility_0_0_1) { 285 _playCanvas.oldLineTo(a[1], a[2]); 286 } else { 287 _playCanvas.lineTo(a[1] + 0.5, a[2] + 0.5); 288 } 289 break; 283 290 case GPLogger.ACTION_LINESTYLE: 284 291 switch (a[1]) { … … 311 318 break; 312 319 default: 313 Alert ('未対応のラインスタイルです。');320 Alert.show('未対応のラインスタイルです。'); 314 321 break; 315 322 } … … 328 335 isBreak = true; 329 336 break; 337 case GPLogger.ACTION_BEGIN_FILL: 338 _playCanvas.beginFill(a[1], a[2]); 339 break; 340 case GPLogger.ACTION_END_FILL: 341 _playCanvas.endFill(); 342 break; 343 case GPLogger.ACTION_DRAW_CIRCLE: 344 _playCanvas.drawCircle(a[1]); 345 break; 330 346 default: 331 Alert ('未対応のアクションです。');347 Alert.show('未対応のアクションです。'); 332 348 break; 333 349 } … … 339 355 } else { 340 356 flash.utils.clearInterval(playLogIntervalId); 341 // this.dispatchEvent(new Event('completePlayLog'));357 _playCanvas.completePlayLog(); 342 358 break; 343 359 } … … 350 366 var short:uint; 351 367 var obj:Object; 368 var obj2:Object; 369 var obj3:Object; 352 370 353 371 try { … … 388 406 obj = readBoolean(); 389 407 break; 408 default: 409 Alert.show('未対応のラインスタイルです。'); 410 break; 390 411 } 391 412 return [ACTION_LINESTYLE, dx, obj]; … … 396 417 case ACTION_REDO: 397 418 return [ACTION_REDO]; 419 case ACTION_BEGIN_FILL: 420 obj = readUInt(); 421 obj2 = readDouble(); 422 return [ACTION_BEGIN_FILL, obj, obj2]; 423 case ACTION_END_FILL: 424 return [ACTION_END_FILL]; 425 case ACTION_DRAW_CIRCLE: 426 obj = readDouble(); 427 return [ACTION_DRAW_CIRCLE, obj]; 398 428 default: 399 429 if (byte & 0x80) { … … 422 452 return [ACTION_MOVETO, preX, preY]; 423 453 } else { 454 Alert.show('未対応のアクションです。'); 424 455 // error 425 456 } as3/gunyarapaint/trunk/gunyarapaint/src/gunyarapaint/entities/GPPen.as
r1115 r1117 192 192 alpha = 0; 193 193 _canvas.beginFill(color, tmpAlpha); 194 _canvas.drawCircle( evt.localX, evt.localY,thickness / 2);194 _canvas.drawCircle(thickness / 2); 195 195 _canvas.endFill(); 196 196 alpha = tmpAlpha;

