StarlingGraphics / Starling-Extension-Graphics

flash.display.Graphics style extension for the Starling Flash GPU rendering framework
https://github.com/StarlingGraphics/Starling-Extension-Graphics/wiki
MIT License
285 stars 88 forks source link

Unnecessary border when using lineTexture() #102

Closed sannam closed 10 years ago

sannam commented 10 years ago

Hi, I'm seeing a weird border when using texture as a stroke for the lines.

This happens only when I use lineTexture() and not when I use lineStyle()

            var wireBitmap:Bitmap = new WIRE_PNG();
            var wireTexture:Texture = Texture.fromBitmap(wireBitmap,false);

            shape=new Shape();
            shape.width = shape.height = 400;
            shape.graphics.lineTexture(wireTexture.height,wireTexture);
            shape.graphics.moveTo(50,50);
            shape.graphics.lineTo(150,50);
            shape.graphics.lineTo(200,100);
            shape.graphics.lineTo(200,200);
            addChild(shape);

I have attached couple of screenshots and the ActionScript project can be downloaded here - https://docs.google.com/uc?id=0B_py8ocVzd4eTExfbHBwaUVza2M&export=download

Is there a fix or workaround for this ? Does anybody else see this?

Any help is greatly appreciated. Thanks for your time

Srini

errorborder_1x errorborder_2x

pjh00 commented 10 years ago

Try 32X32 texture.

IonSwitz commented 10 years ago

@sannam Thank you for using the Starling Extension Graphics.

I see that you are using the height of the wireTexture as the line thickness. Is it possible that the wireTexture height isn't a multiple of 2? ( 4, 8, 16 or so)

When I use a texture that is 4, 8 or 16, I get no odd artifacts, but when I use a texture that has a "bad" height and width, such as 17, it looks awful. The texture needs to be an even multiple of two, in both width and height.

I hope this will solve the problem.

sannam commented 10 years ago

Thanks a lot for the quick reply guys.

Using a 32x32 texture solves my issue. I should be able to change my app to use textures that are multiples of 2 without any issues.

Btw, this is a great extension. Very handy & easy to use.