Module:Cropped Map Composite

local p = {} --p stands for package

function p.hello( frame ) -- Retrieve the original arguments local originalWidth = tonumber(frame.args['originalWidth']) local originalHeight = tonumber(frame.args['originalHeight']) local intendedWidth = tonumber(frame.args['intendedWidth']) local intendedHeight = tonumber(frame.args['intendedHeight']) local bounding_box_left = tonumber(frame.args['left']) local bounding_box_right = tonumber(frame.args['right']) local bounding_box_top = tonumber(frame.args['top']) local bounding_box_bottom = tonumber(frame.args['bottom']) local float_x = tonumber(frame.args['x'] or 0) local float_y = tonumber(frame.args['y'] or 0) -- Do some calculations local bounding_box_width = bounding_box_right - bounding_box_left local bounding_box_height = bounding_box_bottom - bounding_box_top local bSize = math.floor((intendedWidth/bounding_box_width)*originalWidth) local bSizeH = math.floor((intendedHeight/bounding_box_height)*originalHeight) local offset_l = math.floor((bounding_box_left/originalWidth)*bSize) local offset_t = math.floor((bounding_box_top/originalHeight)*bSizeH) float_x = math.floor(((float_x - bounding_box_left)/bounding_box_width)*intendedWidth) float_y = math.floor(((float_y - bounding_box_top)/bounding_box_height)*intendedHeight) local mapOverlay = "\n \n\n  \n " if (float_x <= 0) or (float_y <= 0) or (float_x > intendedWidth) or (float_y > intendedHeight) then return mapOverlay else local superimpose = "" .. mapOverlay .. "\n \n " return superimpose end end

return p