views:

178

answers:

2

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);

alt text

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

A: 

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.

antpaw
this would be the case if I was using lineTo with sprites or movieclips, i'm rendering by hand to a bitmap though.
argonide
A: 

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.

argonide