Actually this is better.
local flw = fe.layout.width;
local flh = fe.layout.height;
// Rows must be either 3 or 5
local rows = 3;
local aspect = flw/flh;
local cols = rows * aspect;
local tlw = flw/cols;
local adw=0;
// Uncomment if monitor is rotated to preserve aspect ratios correctly.
//fe.layout.orient=RotateScreen.Right;
if (fe.layout.orient==RotateScreen.Right) {
fe.layout.width = flh;
fe.layout.height = flw;
flw = fe.layout.width;
flh = fe.layout.height;
aspect = flh/flw;
cols = rows * aspect;
tlw = flw/cols;
adw=flw-tlw;
}
local tlh = flh/rows;
local adx=tlw;
local ady=0;
local adh=flh;
local advert = fe.add_artwork( "flyer", adx, ady, adw, adh)
advert.preserve_aspect_ratio = true;
local tilep2 = fe.add_surface(tlw, tlh);
local tilep1 = fe.add_surface(tlw, tlh);
local tiles = fe.add_surface(tlw, tlh);
local tilen1 = fe.add_surface(tlw, tlh);
local tilen2 = fe.add_surface(tlw, tlh);
tilep2.alpha = 64;
tilep1.alpha = 128;
tiles.alpha = 255;
tilen1.alpha = 128;
tilen2.alpha = 64;
tiles.set_pos ( 0, (flh*0.5)-(tlh*0.5));
tilep1.set_pos ( tiles.x, tiles.y-tlh);
tilep2.set_pos ( tiles.x, tiles.y-tlh-tlh);
tilen1.set_pos ( tiles.x, tiles.y+tlh);
tilen2.set_pos ( tiles.x, tiles.y+tlh+tlh);
local snx=0-(tlw*0.125);
local sny=0-(tlh*0.125);
local snw=tlw*1.25;
local snh=tlh*1.25;
local wlw=tlw*0.9;
local wlh=tlh*0.9;
local wlx=tlw*0.05;
local wly=0;
local tp2 = tilep2.add_artwork( "snap", snx, sny, snw, snh);
local wp2 = tilep2.add_artwork( "wheel", wlx, wly, wlw, wlh);
tp2.index_offset = -2;
wp2.index_offset = -2;
wp2.preserve_aspect_ratio = true;
local tp1 = tilep1.add_artwork( "snap", snx, sny, snw, snh);
local wp1 = tilep1.add_artwork( "wheel", wlx, wly, wlw, wlh);
tp1.index_offset = -1;
wp1.index_offset = -1;
wp1.preserve_aspect_ratio = true;
local tss = tiles.add_artwork( "snap", snx, sny, snw, snh);
local wls = tiles.add_artwork( "wheel", wlx, wly, wlw, wlh);
wls.preserve_aspect_ratio = true;
local tn1 = tilen1.add_artwork( "snap", snx, sny, snw, snh);
local wn1 = tilen1.add_artwork( "wheel", wlx, wly, wlw, wlh);
tn1.index_offset = 1;
wn1.index_offset = 1;
wn1.preserve_aspect_ratio = true;
local tn2 = tilen2.add_artwork( "snap", snx, sny, snw, snh);
local wn2 = tilen2.add_artwork( "wheel", wlx, wly, wlw, wlh);
tn2.index_offset = 2;
tn2.index_offset = 2;
wn2.preserve_aspect_ratio = true;
(I know I should pull out tile creation into a class but this will do for now)