Limitations with display.newPolygon ?

Are there any other known limitations to creating a polygon shape apart from having holes and self-intersecting paths? Is there a limit on the number of points? Distance between points?

The reason I ask is because I’m unable to create a shape when using external software to generate points and then exporting the vertices as data. The shape has 186 points with some points very close to each other and also no holes or self-intersecting paths.

I should note that I’ve been able to successfully create a simpler shape using this same process.

local vertices = {710.5,57.6,527,57.6,527,66.2,531,71.2,527,75.2,529.5,82.2,536,82.2,542,88.2,542.5,94.2,552,94.2,559.5,99.6,555,105.8,562.5,111.8,570,111.8,572.5,121.2,582,123.8,587,127.8,587,158.8,582.5,166.8,584.5,181.8,587.5,188.8,588,251.2,580.5,254.2,573.5,247.8,568.5,264.2,560,264.2,557,270.2,563.5,274.8,558,280.8,556.5,311.8,545,311.8,523.5,307.2,509.5,322.2,509.5,327.8,501,334.2,501,342.8,491.5,342.8,491.5,329.2,482,323.8,482,314.8,472.5,313.2,463.8,312.8,467.5,299.8,466.5,287.8,369.5,308.8,373,313.8,360,314.2,352,322.8,345,324.8,342.5,333.2,342.5,342.8,332.5,348.2,324,343.2,321,337.8,313,329.8,305,335.8,310.5,340.8,309.5,350.8,308.5,363.8,309,404.8,315,411.8,308.5,415.8,314,421.2,324,421.2,328.5,435.8,338,432.2,346,435.8,342.5,442.8,342.5,450.8,352.5,450.8,357,463.2,367,463.2,433.5,466.8,436,473.8,435.5,481.8,446.5,485.8,451.5,495.8,463.8,495.8,459.5,509.2,463.8,531.2,447.5,541.8,424,541.8,408.5,536.8,399,538.8,388.5,538.8,378,535.8,367,535.8,360.5,541.8,349,537.2,340,536.2,324.5,538.8,311,537.2,300,533.2,287.5,536.8,274.5,523.2,279,513.8,272,509.8,263.5,509.8,263.5,497.8,248.5,497.8,244,491.8,244,477.8,230.5,477.8,119.5,483.8,119.5,734.2,836.5,734.2,836.5,682.8,828.5,674.8,831,669.2,819.5,657.8,813.5,648.8,804.5,640.2,791,642.2,778,638.8,770,628.2,754.5,628.2,741,627.2,742.5,619.8,737,614.2,734.5,599.8,723.5,600.2,708,600.2,712.5,585.2,716,574.2,713.5,562.2,706,552.8,694.5,550.2,706.5,538.2,710.5,526.8,721.5,526.8,728,520.2,743,509.2,738,500.2,756,495.2,759,486.2,769,482.8,773.5,474.8,766,468.2,773.5,464.8,773.5,433.2,784.5,433.2,793,422.2,800.5,421.2,804,411.8,797,405.2,806.5,400.2,802.5,341.8,817.5,339.8,822.5,328.8,833.5,327.8,836.5,318.2,824.5,316.2,836.5,308.8,832,251.8,687,247.8,690.5,239.2,686,229.8,679,213.2,684.5,212.8,689,203.8,679.5,202.8,681,195.8,688.5,191.8,685,186.2,689,175.8,685.5,171.2,690.5,168.8,692.5,158.8,687.5,156.2,691.5,151.8,689.5,142.8,696,135.8,705,131.2,706,124.8,698.5,122.8,706.5,119.2,707,113.8,711.5,106.8,707,99.6,711,92.8,714.5,86.8,711,77.8,728,66.2,730,57.6,716,51.8,710.5,57.6 } local myShape = display.newPolygon(0,0, vertices) -- Unable to create this shape "WARNING: Polygon could not be generated. The polygon outline is invalid, possibly due to holes or self-intersection."

try the following code

I should have noticed immediately but you repeated the first point as the last

newPolygon closes polygons automatically so the repeated point caused the error.

local vertices = 

{710.5,57.6,527,57.6,527,66.2,531,71.2,527,75.2,529.5,82.2,536,82.2,542,88.2,542.5,94.2,552,94.2,559.5,99.6,555,105.8,562.5,111.8,570,111.8,572.5,121.2,582,123.8,587,127.8,587,158.8,582.5,166.8,584.5,181.8,587.5,188.8,588,251.2,580.5,254.2,573.5,247.8,568.5,264.2,560,264.2,557,270.2,563.5,274.8,558,280.8,556.5,311.8,545,311.8,523.5,307.2,509.5,322.2,509.5,327.8,501,334.2,501,342.8,491.5,342.8,491.5,329.2,482,323.8,482,314.8,472.5,313.2,463.8,312.8,467.5,299.8,466.5,287.8,369.5,308.8,373,313.8,360,314.2,352,322.8,345,324.8,342.5,333.2,342.5,342.8,332.5,348.2,324,343.2,321,337.8,313,329.8,305,335.8,310.5,340.8,309.5,350.8,308.5,363.8,309,404.8,315,411.8,308.5,415.8,314,421.2,324,421.2,328.5,435.8,338,432.2,346,435.8,342.5,442.8,342.5,450.8,352.5,450.8,357,463.2,367,463.2,433.5,466.8,436,473.8,435.5,481.8,446.5,485.8,451.5,495.8,463.8,495.8,459.5,509.2,463.8,531.2,447.5,541.8,424,541.8,408.5,536.8,399,538.8,388.5,538.8,378,535.8,367,535.8,360.5,541.8,349,537.2,340,536.2,324.5,538.8,311,537.2,300,533.2,287.5,536.8,274.5,523.2,279,513.8,272,509.8,263.5,509.8,263.5,497.8,248.5,497.8,244,491.8,244,477.8,230.5,477.8,119.5,483.8,119.5,734.2,836.5,734.2,836.5,682.8,828.5,674.8,831,669.2,819.5,657.8,813.5,648.8,804.5,640.2,791,642.2,778,638.8,770,628.2,754.5,628.2,741,627.2,742.5,619.8,737,614.2,734.5,599.8,723.5,600.2,708,600.2,712.5,585.2,716,574.2,713.5,562.2,706,552.8,694.5,550.2,706.5,538.2,710.5,526.8,721.5,526.8,728,520.2,743,509.2,738,500.2, 756,495.2,759,486.2,769,482.8,773.5,474.8,766,468.2,773.5,464.8,773.5,433.2,784.5,433.2,793,422.2,800.5,421.2,804,411.8,797,405.2,806.5,400.2,802.5,341.8,817.5,339.8,822.5,328.8,833.5,327.8,836.5,318.2,824.5,316.2,836.5,308.8,832,251.8,687,247.8,690.5,239.2,686,229.8,679,213.2,684.5,212.8,689,203.8,679.5,202.8,681,195.8,688.5,191.8,685,186.2,689,175.8,685.5,171.2,690.5,168.8,692.5,158.8,687.5,156.2,691.5,151.8,689.5,142.8,696,135.8,705,131.2,706,124.8,698.5,122.8,706.5,119.2,707,113.8,711.5,106.8,707,99.6,711,92.8,714.5,86.8,711,77.8, 728,66.2, 730,57.6, 716,51.8,}-- 710.5,57.6 }

local o = display.newPolygon( display.contentCenterX, display.contentCenterY, vertices )

o:setStrokeColor( 0, 1, 1 )

 for i=1, #vertices-3,2 do

   l=display.newLine(vertices[i],vertices[i+1],vertices[i+2],vertices[i+3])

   l:translate(-420, -50)

   l:setStrokeColor( 0, 1, 1 )

 end

Ah good catch. Thanks!

try the following code

I should have noticed immediately but you repeated the first point as the last

newPolygon closes polygons automatically so the repeated point caused the error.

local vertices = 

{710.5,57.6,527,57.6,527,66.2,531,71.2,527,75.2,529.5,82.2,536,82.2,542,88.2,542.5,94.2,552,94.2,559.5,99.6,555,105.8,562.5,111.8,570,111.8,572.5,121.2,582,123.8,587,127.8,587,158.8,582.5,166.8,584.5,181.8,587.5,188.8,588,251.2,580.5,254.2,573.5,247.8,568.5,264.2,560,264.2,557,270.2,563.5,274.8,558,280.8,556.5,311.8,545,311.8,523.5,307.2,509.5,322.2,509.5,327.8,501,334.2,501,342.8,491.5,342.8,491.5,329.2,482,323.8,482,314.8,472.5,313.2,463.8,312.8,467.5,299.8,466.5,287.8,369.5,308.8,373,313.8,360,314.2,352,322.8,345,324.8,342.5,333.2,342.5,342.8,332.5,348.2,324,343.2,321,337.8,313,329.8,305,335.8,310.5,340.8,309.5,350.8,308.5,363.8,309,404.8,315,411.8,308.5,415.8,314,421.2,324,421.2,328.5,435.8,338,432.2,346,435.8,342.5,442.8,342.5,450.8,352.5,450.8,357,463.2,367,463.2,433.5,466.8,436,473.8,435.5,481.8,446.5,485.8,451.5,495.8,463.8,495.8,459.5,509.2,463.8,531.2,447.5,541.8,424,541.8,408.5,536.8,399,538.8,388.5,538.8,378,535.8,367,535.8,360.5,541.8,349,537.2,340,536.2,324.5,538.8,311,537.2,300,533.2,287.5,536.8,274.5,523.2,279,513.8,272,509.8,263.5,509.8,263.5,497.8,248.5,497.8,244,491.8,244,477.8,230.5,477.8,119.5,483.8,119.5,734.2,836.5,734.2,836.5,682.8,828.5,674.8,831,669.2,819.5,657.8,813.5,648.8,804.5,640.2,791,642.2,778,638.8,770,628.2,754.5,628.2,741,627.2,742.5,619.8,737,614.2,734.5,599.8,723.5,600.2,708,600.2,712.5,585.2,716,574.2,713.5,562.2,706,552.8,694.5,550.2,706.5,538.2,710.5,526.8,721.5,526.8,728,520.2,743,509.2,738,500.2, 756,495.2,759,486.2,769,482.8,773.5,474.8,766,468.2,773.5,464.8,773.5,433.2,784.5,433.2,793,422.2,800.5,421.2,804,411.8,797,405.2,806.5,400.2,802.5,341.8,817.5,339.8,822.5,328.8,833.5,327.8,836.5,318.2,824.5,316.2,836.5,308.8,832,251.8,687,247.8,690.5,239.2,686,229.8,679,213.2,684.5,212.8,689,203.8,679.5,202.8,681,195.8,688.5,191.8,685,186.2,689,175.8,685.5,171.2,690.5,168.8,692.5,158.8,687.5,156.2,691.5,151.8,689.5,142.8,696,135.8,705,131.2,706,124.8,698.5,122.8,706.5,119.2,707,113.8,711.5,106.8,707,99.6,711,92.8,714.5,86.8,711,77.8, 728,66.2, 730,57.6, 716,51.8,}-- 710.5,57.6 }

local o = display.newPolygon( display.contentCenterX, display.contentCenterY, vertices )

o:setStrokeColor( 0, 1, 1 )

 for i=1, #vertices-3,2 do

   l=display.newLine(vertices[i],vertices[i+1],vertices[i+2],vertices[i+3])

   l:translate(-420, -50)

   l:setStrokeColor( 0, 1, 1 )

 end

Ah good catch. Thanks!