I am having trouble drawing a very short line with actionscript3:
var cSp:Sprite = new Sprite(); var cGx:Graphics = cSp.graphics; cGx.lineStyle( 1, 0xFF0000, 1, false, LineScaleMode.NONE, null, null, 1 ); cGx.moveTo( 2, 10 ); cGx.lineTo( 3, 10 );
This creates two vertically stacked pixels which are not quite red (#7f0000)!
vertical line? http://www.freeimagehosting.net/uploads/449212bd1f.png
(here it is zoomed in:)
zoomed in http://www.freeimagehosting.net/uploads/5c9014a148.png
Since I am trying to draw a horizontal line, this is not what I expected. I assume there is some alias/sub-pixel trickery going on here. What’s the magic combination of commands to draw a really short line or one pixel?
Note: if I make my really short line 4 pixels (or more) long, it is rendered as expected (4+ pixels long, 1 pixel tall, every rendered pixel #FF0000)
Did you try playing with the various caps and joints settings? Your values of null/null would direct Flash to use round caps and round joints. Your [last] parameter of ‘1’ for the miter limit would also be ignored as you wouldn’t be using miter joints.
I would suggest trying CapsStyle.NONE first. Then maybe miter joints. For reference: Graphics.lineStyle().
Edit: Try using pixel hinting, too.