Create rectangles through a for loop

Hello, could anyone help me with a little logic? I’m trying through a for loop, create 40 rectangles that start with 8 pixels from the left, have 8 pixels between them and end 8 pixels from the right edge, taking up the entire screen (no matter the size of the device) and each queue has 4 their! that is, 10 rows one below the other and each with 4 rectangles. all of which fit into a scrollview I’ve already created.

This is a start. You can work out the rest on your own
 

local cx = display.contentCenterX local cy = display.contentCenterY local fullw = display.actualContentWidth local fullh = display.actualContentHeight local left = cx - fullw/2 local sep = 8 local blockWidth = math.floor((fullw - 39 \* sep)/40) local blockHeight = 10 local function doRow( y ) local curX = left for i = 1, 40 do local tmp = dislay.newRect( curX, y, blockWidth, blockHeight ) tmp.anchorX = 0 curX = curX + sep + blockWidth end end doRow( cy ) doRow( cy + (sep + blockHeight) \* 1 ) doRow( cy + (sep + blockHeight) \* 2 ) doRow( cy + (sep + blockHeight) \* 3 )

Thank you, that’s exactly what I wanted!

This is a start. You can work out the rest on your own
 

local cx = display.contentCenterX local cy = display.contentCenterY local fullw = display.actualContentWidth local fullh = display.actualContentHeight local left = cx - fullw/2 local sep = 8 local blockWidth = math.floor((fullw - 39 \* sep)/40) local blockHeight = 10 local function doRow( y ) local curX = left for i = 1, 40 do local tmp = dislay.newRect( curX, y, blockWidth, blockHeight ) tmp.anchorX = 0 curX = curX + sep + blockWidth end end doRow( cy ) doRow( cy + (sep + blockHeight) \* 1 ) doRow( cy + (sep + blockHeight) \* 2 ) doRow( cy + (sep + blockHeight) \* 3 )

Thank you, that’s exactly what I wanted!