RSS LinkedIn Twitter

ActionScript Drawing API: 3px long by 1px wide Line Segments

December 14th, 2010 Categories: Uncategorized

The ActionScript 3.0 reference describes the effects of pixelHinting settings on curves between lines pretty well, but it also affects line segments. Particularly short line segments.

The problem is that trying to draw short, thin line segments (1px thick and 3px shorter, or less) will cause the segments to actually appear to be 2px thick. You can solve this problem by not using the default value for pixelHinting (false) when you set your lineStyle. Set it to true instead.

The following code snippet shows the problem and the fix:

var g : Graphics =;
// 3 pixel line segments with pixel hinting = false
g.lineStyle(1, 0x000000, 1.0);
g.lineTo(5, 4);
g.lineTo(10, 4);
// 3 pixel line segments with pixel hinting = true
g.lineStyle(1, 0x000000, 1.0, true);
g.lineTo(5, 10);
g.lineTo(10, 10);

Here’s an image of the output. You’ll also note that the segments that don’t use pixel hinting appear shorter. Adobe’s documentation makes a bit more sense to me now, when it mentions ‘adjusted to full pixel widths’:

pixelHinting true vs false on short segments

See the Adobe Graphics documentation here


One Response to “ActionScript Drawing API: 3px long by 1px wide Line Segments”

  1. December 3rd, 2011 at 05:52

    It’s great helpful information. Thanks.

Leave a Comment