I have an issue when drawing and placing sprite with height and width that do not perfectly fit an integer number of pixels.
For example, I tried to create an hexmap (a map with hexagonal tiles) where I define each tile as a sprite. When I place these hexagonal sprites constituting my map side by side, I see some thin 1 pixel spacing horizontaly each 2 raws:
I assume this is because the height of my hexagones do not match an exact number of pixels so rather than drawing a blurry border, it is some kind of rounded to the closest pixel limit.
The same issue appear when I try to have a regular spacing between my tiles:
You can see that the horizontal spacing kind of vary each 2 raws…
So how can I fix this problem? Is there some kind of option I could use to tell I prefer having blurry shapes than net ones but with 1pixel changing dimensions?
I should also mention that this problem occur both on flash and cpp targets.
And here is the function I use to create my hexagonal sprites:
var bm:BitmapData = new BitmapData(Std.int(hex_radius*2+0.5),Std.int(hex_radius*2+0.5), true, 0x00000000);
var lRadians:Float = Math.PI / 3;
var hs:Shape = new Shape();
var g:Graphics = hs.graphics;
g.moveTo (hex_radius * Math.cos (0), hex_radius * Math.sin (0));
g.lineStyle (1, color, 0);
g.beginFill (color, 1);
for (i in 0...6){
g.lineTo (hex_radius * Math.cos (lRadians * (i + 1)), hex_radius * Math.sin (lRadians * (i + 1)));
}
g.endFill();
var mat:Matrix = new Matrix();
mat.translate(hex_radius, hex_radius);
bm.draw(hs, mat);
var bitmap:Bitmap = new Bitmap(bm);
addChild(bitmap);
(I don’t know. The problem might be linked to the way I create my hexagon pictures. Maybe the “pixel rounding” occur when the the sape is drawn into the bitmapdata by the BitmapData.draw() function…)