开发者

Perfect line rendering in as3

开发者 https://www.devze.com 2022-12-15 15:14 出处:网络
开发者_如何学GoI\'m making an arcade game in as3 and I want to draw pixely(unsmoothed by flash) lines.I\'m drawing the pixels \'by hand\'(not with flash\'s lineTo or anything) onto a bitmapdata object
开发者_如何学Go

I'm making an arcade game in as3 and I want to draw pixely(unsmoothed by flash) lines. I'm drawing the pixels 'by hand'(not with flash's lineTo or anything) onto a bitmapdata object.

The lines don't appear quite right though, when zoomed out the line is rendered 2 pixels thick at some parts. However by zooming it its apparent that the algorithm is fine and its not doubling the pixels. Changing the quality doesn't seem to change anything. Any idea how i can get pixel perfect lines?

g=new BitmapData(w,h,false,0x000000);
var bmp:Bitmap=new Bitmap(g);
addChild(bmp);
//...
Util.drawLine(x1,y1,x2,y2,0xFFFFFF,g);

Perfect line rendering in as3

The algorithm isn't relevant since I know from the zoom in its not really doubling, and since its drawing to a bitmap it has to be drawn in pixel increments. But its just a as3 version of the 2nd one listed on this page


if I'm not mistaken lines in flash are paths with stroke and no filling. so the problem is that the path is at the exact pixel value, but the stroke is divided in 2 lines (one left, one right) each 0,5 flash pixel wide (or 2 actual pixel, as we know them, wide with 0.5 alpha) i think moving the line + 0.5 will solve the problem.


Ok, I fixed it. The flash was being scaled by the browser.

stage.scaleMode=StageScaleMode.NO_SCALE;

Was all that was needed to get rid of the artifacts.

0

精彩评论

暂无评论...
验证码 换一张
取 消