Currently I am drawing a line graphic which I then rotate depending on the the slope(Block 1). It so far is working pretty well in terms of creating the outline. I then create a table of all the (xMax,xMin,yMax,yMin) for each line and then create an additional connection line between each point. After the user has finished the crop selection , I then draw a continuous line (Block 2), the challenge then is to fill the area outside the line. I have tried display.newPolygon but if I have an polygon failures ( which there will be a couple) then it doesn’t fill it in completely.
(Block 1)
local line = display.newImageRect( “images/MarchingAnt.png”,4,1 )
local slopea= (linePoints[#linePoints].y-linePoints[#linePoints-1].y)
local slopeb= (linePoints[#linePoints].x-linePoints[#linePoints-1].x)
local slope = math.deg(math.atan2(slopea,slopeb))
(Block 2)
if tableToColor[i].slope<-90 then
line = display.newLine(tableToColor[i].xm,tableToColor[i].ym+1,tableToColor[i].xx-1,tableToColor[i].yx)
elseif tableToColor[i].slope<0 then
line = display.newLine(tableToColor[i].xx-1,tableToColor[i].ym,tableToColor[i].xm,tableToColor[i].yx-1)
elseif tableToColor[i].slope<90 then
line = display.newLine(tableToColor[i].xm+1,tableToColor[i].ym,tableToColor[i].xx,tableToColor[i].yx-1)
else
line = display.newLine(tableToColor[i].xx,tableToColor[i].ym+1,tableToColor[i].xm+1,tableToColor[i].yx)
end