チェンジセット 1096
- コミット日時:
- 2008/08/27 18:16:22 (5 年前)
- ファイル:
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/gunyarapaint/trunk/gunyarapaint/src/gunyarapaint.as
r1095 r1096 24 24 25 25 private const ALERT_TITLE:String = 'お絵カキコ'; 26 private const DEBUG:Boolean = true; 26 27 27 28 public function init():void { … … 45 46 } 46 47 } else { 47 //undoBufferSize = 16; 48 return; 48 if (DEBUG) { 49 undoBufferSize = 16; 50 } else { 51 return; 52 } 49 53 } 50 54 if (parameters['oekakiId'] && parameters['baseImgUrl']) { … … 66 70 } 67 71 } else { 68 //canvasWidth = 16; canvasHeight = 16; 69 return; 72 if (DEBUG) { 73 canvasWidth = 300; canvasHeight = 400; 74 } else { 75 return; 76 } 70 77 } 71 78 gpCanvas = new gunyarapaint.Canvas(canvasWidth, canvasHeight, undoBufferSize, null, null); as3/gunyarapaint/trunk/gunyarapaint/src/gunyarapaint/Canvas.as
r1095 r1096 12 12 import flash.events.Event; 13 13 import flash.events.MouseEvent; 14 import flash.geom.Point; 14 15 import flash.utils.ByteArray; 15 16 import flash.utils.clearInterval; … … 254 255 this.dispatchEvent(new Event('changeColor')); 255 256 } 257 // 描画関係のフラグ 258 private var isMouseDownAndOut:Boolean = false; 259 private var isMoveTo:Boolean = false; 260 private var isDrawnLine:Boolean; 261 private var currentPoint:Point = new Point; 256 262 private function moveTo(x:Number, y:Number):void { 257 263 lineShape.graphics.moveTo(x, y); 258 264 setLineStyle(); 259 265 logWrite(['moveTo', x, y]); 266 isDrawnLine = false; 267 isMoveTo = true; 268 currentPoint.x = x; 269 currentPoint.y = y; 260 270 } 261 271 private function lineTo(x:Number, y:Number):void { 262 272 lineShape.graphics.lineTo(x, y); 263 273 logWrite(['lineTo', x, y]); 274 isDrawnLine = true; 275 currentPoint.x = x; 276 currentPoint.y = y; 264 277 } 265 278 public function mouseDown(evt:MouseEvent):void { … … 273 286 } 274 287 } 288 289 private function isInCanvas(evt:MouseEvent):Boolean { 290 return (evt.localX >= 0 && evt.localY >= 0 && 291 evt.localX < canWidth && evt.localY < canHeight); 292 } 293 275 294 public function mouseMove(evt:MouseEvent):void { 276 295 if (evt.buttonDown) { 277 if (evt.localX < 0 || evt.localY < 0 ||278 evt.localX > canWidth || evt.localY > canHeight) {279 mouseUp(evt);280 }281 296 switch (penMode) { 282 297 case MODE_PEN: 283 if (lineShape) { 284 lineTo(evt.localX, evt.localY); 285 } else { 286 // マウス押しっぱなしで領域外に出て、また戻ってきた場合 287 mouseDown(evt); 298 if (isInCanvas(evt)) { 299 if (isMouseDownAndOut) { 300 // マウス押しっぱなしで領域外に出て、また戻ってきた場合 301 mouseDown(evt); 302 isMouseDownAndOut = false; 303 } else { 304 lineTo(evt.localX, evt.localY); 305 } 306 } else { 307 // TODO: 直線と枠との交点を座標とする。 288 308 } 289 309 break; 290 310 case MODE_DROPPER: 291 getColor(evt); 311 if (isInCanvas(evt)) { 312 getColor(evt); 313 } 292 314 break; 293 315 } … … 306 328 undoFirstIndex = (undoFirstIndex + 1) % undoBufferSize; 307 329 } 308 // 描画用シェイプは空にしておく 。330 // 描画用シェイプは空にしておく 309 331 lineShape.graphics.clear(); 332 isMoveTo = false; 310 333 this.dispatchEvent(new Event('changeUndoRedo')); 311 334 logWrite(['drawShapeOnBitmap']); 312 335 } 313 336 public function mouseUp(evt:MouseEvent):void { 314 if (lineShape) { 315 drawShapeOnBitmap(); 316 } 337 if (!isDrawnLine) { 338 lineShape.graphics.drawRect(currentPoint.x, currentPoint.y, 1, 1); 339 } 340 drawShapeOnBitmap(); 317 341 } 318 342 public function mouseOut(evt:MouseEvent):void { 319 if (evt.buttonDown) { 320 // マウスボタンを離したことにする 321 mouseUp(evt); 343 if (isMoveTo) { 344 isMouseDownAndOut = true; 322 345 } 323 346 } … … 386 409 return log.getCompressedLog(); 387 410 } 388 411 412 // ログ関係のローカル変数 389 413 private var playLogIntervalId:uint; 390 414 private var playLogSpeed:uint;

