Changes
Jump to navigation
Jump to search
allow nil values as input to most of the functions, to make call-chaining with conditional variables easier
function data:format(s, filename)
checkSelf(self, 'image:format')
checkType('image:format', 1, s, 'string', true)
checkType('image:format', 2, format, 'string', true)
local validFormats = {
frameless = true
}
if s == nil or validFormats[s] then
data.theFormat = s
data.theFormatFilename = filename
function data:width(px)
checkSelf(self, 'image:width')
checkType('image:width', 1, px, 'number', true) if px and data.isUpright then
sizeError('image:width')
end
function data:height(px)
checkSelf(self, 'image:height')
checkType('image:height', 1, px, 'number', true) if px and data.isUpright then
sizeError('image:height')
end
end
function data:upright(isUpright, factor)
checkSelf(self, 'image:upright')
checkType('image:upright', 1, isUpright, 'boolean', true) checkType('image:upright', 2, factor, 'number', true) if isUpright and (data.theWidth or data.theHeight ) then
sizeError('image:upright')
end
data.isUpright = trueisUpright
data.uprightFactor = factor
return self
function data:location(s)
checkSelf(self, 'image:location')
checkType('image:location', 1, s, 'string', true)
local validLocations = {
right = true,
none = true
}
if s == nil or validLocations[s] then
data.theLocation = s
else
function data:alignment(s)
checkSelf(self, 'image:alignment')
checkType('image:alignment', 1, s, 'string', true)
local validAlignments = {
baseline = true,
bottom = true
}
if s == nil or validAlignments[s] then
data.theAlignment = s
else
end
function data:border(hasBorder)
checkSelf(self, 'image:border')
checkType('image:border', 1, hasBorder, 'boolean', true) data.hasBorder = truehasBorder
return self
end
function data:link(s)
checkSelf(self, 'image:link')
checkType('image:link', 1, s, 'string', true)
data.theLink = s
return self
function data:alt(s)
checkSelf(self, 'image:alt')
checkType('image:alt', 1, s, 'string', true)
data.theAlt = s
return self
function data:caption(s)
checkSelf(self, 'image:caption')
checkType('image:caption', 1, s, 'string', true)
data.theCaption = s
return self