Rong filling result of poligon display object

Hello everyone! 

Program generates  polygons (display object) by rules and math functions.

Sizes of polygons and their sides are different. But polygons are symmetric along the axis X.

After that I am filling them by Image (512*512, format png) - sizes of polygons as a rule are bigger than picture.

I am using code for filling and repeating. But sometimes image quantity is bad on some of polygons.

Code:

local o = display.newPolygon( xCentr,yCentr,  dots)

 o.fill = { type=“image”, filename=“bg.png” }

 scaleFactorX = 1 ;  scaleFactorY = 1

if ( o.width > o.height ) then

   scaleFactorY = o.width / o.height

else

   scaleFactorX = o.height / o.width

end 

o.fill.scaleX =0.3*scaleFactorX

o.fill.scaleY = 0.3*scaleFactorY 

in attach screenshot of two polygons - the bottom polygon has bad shape.

Is it a bug or i need to edit my logic of scaling ?

I don’t think I’m seeing the attached screenshots correctly, so maybe I got the issue wrong.
But it should be enough to do 512/o.width and 512/o.height to properly scale the image inside the polygon (assuming your image is 512x512).

So 

display.setDefault("textureWrapX", "repeat"); display.setDefault("textureWrapY", "repeat"); local o = display.newPolygon( xCentr,yCentr, dots) o.fill = { type="image", filename="bg.png" } o.fill.scaleX = 512/o.width; o.fill.scaleY = 512/o.height;

Should bring the same result, and maybe fix your issue.

Yes, it’s work fine now. No strange effects now! 

Thank you! 

I don’t think I’m seeing the attached screenshots correctly, so maybe I got the issue wrong.
But it should be enough to do 512/o.width and 512/o.height to properly scale the image inside the polygon (assuming your image is 512x512).

So 

display.setDefault("textureWrapX", "repeat"); display.setDefault("textureWrapY", "repeat"); local o = display.newPolygon( xCentr,yCentr, dots) o.fill = { type="image", filename="bg.png" } o.fill.scaleX = 512/o.width; o.fill.scaleY = 512/o.height;

Should bring the same result, and maybe fix your issue.

Yes, it’s work fine now. No strange effects now! 

Thank you!