flash on 2011-2-20
http://dencha.ojaru.jp/programs_07/pg_graphic_07.html
Bresenham
draw Line method
♥0 |
Line 50 |
Modified 2011-02-20 11:27:43 |
MIT License
archived:2017-03-20 05:09:12
ActionScript3 source code
/**
* Copyright yamat1011 ( http://wonderfl.net/user/yamat1011 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/zfpV
*/
/** http://dencha.ojaru.jp/programs_07/pg_graphic_07.html
* Bresenham
* draw Line method
*/
package {
import flash.display.StageQuality;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.display.AVM1Movie;
import flash.events.Event;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
[SWF(frameRate = "30", backgroundColor = "0xffffff", width = "465", height = "465")]
public class FlashTest extends Sprite {
private static const _W:Number = 465;
private static const _H:Number = 465;
private var _canvas:BitmapData;
private var _bresenham:Bresenham;
public function FlashTest() {
// write as3 code here..
if(stage) _init();
else addEventListener(Event.ADDED_TO_STAGE, _init, false, 0, true);
}
private function _init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, _init);
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.quality = StageQuality.HIGH;
_canvas = new BitmapData(_W, _H, true, 0x00000000);
var bmp:Bitmap = addChild(new Bitmap(_canvas)) as Bitmap;
_bresenham = new Bresenham(_canvas);
_bresenham.drawLine(0, 0, 200, 250);//(0, 0) to (200, 250)
}
}
}
import flash.display.BitmapData;
class Bresenham{
private var _bmd:BitmapData
public function Bresenham(bmd:BitmapData)
{
_bmd = bmd;
}
public function drawLine(x1:Number, y1:Number, x2:Number, y2:Number, color:uint = 0xffffff):void
{
var ww:Number = x2 - x1;
var hh:Number = y2 - y1;
var x:int = 0;
var y:int = 0;
}
public function drawDot():void
{
}
}