Module:Ups and downs sharpness: Difference between revisions
Tristanbay (talk | contribs) tried forcing cell width |
Tristanbay (talk | contribs) added forced cell widths |
||
| Line 9: | Line 9: | ||
function p.ud_sharpness(frame) -- generate table | function p.ud_sharpness(frame) -- generate table | ||
local sharp = sharp_n(frame.args["edo"]) | local sharp = sharp_n(frame.args["edo"]) | ||
local spanf = "| <div style=\"width: | local spanf = "| <div style=\"width:%sem; margin-bottom:-45px; transform:translate(0, %spx); white-space:nowrap;\">%s</div>\n" | ||
local cell_width -- forced cell width in ems | |||
local arrow_marg = -2.5 | local arrow_marg = -2.5 | ||
local sharp_marg = -15 | local sharp_marg = -15 | ||
| Line 27: | Line 28: | ||
.. "|-\n" | .. "|-\n" | ||
.. "! Symbol\n" | .. "! Symbol\n" | ||
.. string.format(spanf, arrow_marg, string.rep(" [[File:Down arrow petaluma script.svg|10px]]", 3)) | .. string.format(spanf, 2, arrow_marg, string.rep(" [[File:Down arrow petaluma script.svg|10px]]", 3)) | ||
.. string.format(spanf, arrow_marg, string.rep(" [[File:Down arrow petaluma script.svg|10px]]", 2)) | .. string.format(spanf, 2, arrow_marg, string.rep(" [[File:Down arrow petaluma script.svg|10px]]", 2)) | ||
.. string.format(spanf, arrow_marg, " [[File:Down arrow petaluma script.svg|10px]]") | .. string.format(spanf, 2, arrow_marg, " [[File:Down arrow petaluma script.svg|10px]]") | ||
.. string.format(spanf, arrow_marg - 15, " [[File:Heji18.svg|15px]]") | .. string.format(spanf, 2, arrow_marg - 15, " [[File:Heji18.svg|15px]]") | ||
.. string.format(spanf, arrow_marg, " [[File:Up arrow petaluma script.svg|10px]]") | .. string.format(spanf, 2, arrow_marg, " [[File:Up arrow petaluma script.svg|10px]]") | ||
.. string.format(spanf, arrow_marg, string.rep(" [[File:Up arrow petaluma script.svg|10px]]", 2)) | .. string.format(spanf, 2, arrow_marg, string.rep(" [[File:Up arrow petaluma script.svg|10px]]", 2)) | ||
.. string.format(spanf, arrow_marg, string.rep(" [[File:Up arrow petaluma script.svg|10px]]", 3)) | .. string.format(spanf, 2, arrow_marg, string.rep(" [[File:Up arrow petaluma script.svg|10px]]", 3)) | ||
.. "|}\n</div>" | .. "|}\n</div>" | ||
elseif sharp == 1 then | elseif sharp == 1 then | ||
| Line 46: | Line 47: | ||
end | end | ||
tab = tab .. "\n|-\n! Sharp symbol\n" | tab = tab .. "\n|-\n! Sharp symbol\n" | ||
.. "| rowspan=\"2\" style=\"white-space:nowrap;\" |  [[File:Heji18.svg|15px]]\n" | .. "| rowspan=\"2\" style=\"white-space:nowrap; width:2em\" |  [[File:Heji18.svg|15px]]\n" | ||
for i = 1, sharp * 2 do | for i = 1, sharp * 2 do | ||
local cs = math.ceil((i / sharp) - 0.5) -- sharpness of note | local cs = math.ceil((i / sharp) - 0.5) -- sharpness of note | ||
| Line 54: | Line 55: | ||
if cs == 0 then | if cs == 0 then | ||
marg = arrow_marg | marg = arrow_marg | ||
cell_width = 0 | |||
elseif cs == 1 then | elseif cs == 1 then | ||
marg = sharp_marg | marg = sharp_marg | ||
cell_width = 2 | |||
elseif cs == 2 then | elseif cs == 2 then | ||
marg = double_sharp_marg | marg = double_sharp_marg | ||
cell_width = 3 | |||
else | else | ||
marg = 0 -- Failsafe | marg = 0 -- Failsafe | ||
| Line 65: | Line 69: | ||
if (i - (sharp * math.floor(i / sharp))) % 5 == 4 then | if (i - (sharp * math.floor(i / sharp))) % 5 == 4 then | ||
s = s .. " [[File:Down arrow petaluma script.svg|10px]] [[File:Quip narrow.svg|9px]]" | s = s .. " [[File:Down arrow petaluma script.svg|10px]] [[File:Quip narrow.svg|9px]]" | ||
cell_width = cell_width + 4 | |||
else | else | ||
for j = 1, (i - (sharp * math.floor(i / sharp))) % 5 do | for j = 1, (i - (sharp * math.floor(i / sharp))) % 5 do | ||
s = s .. " [[File:Up arrow petaluma script.svg|10px]]" | s = s .. " [[File:Up arrow petaluma script.svg|10px]]" | ||
cell_width = cell_width + 2 | |||
end | end | ||
end | end | ||
for j = 1, math.floor((i - (sharp * math.floor(i / sharp))) / 5) do | for j = 1, math.floor((i - (sharp * math.floor(i / sharp))) / 5) do | ||
s = s .. " [[File:Quip narrow.svg|9px]]" | s = s .. " [[File:Quip narrow.svg|9px]]" | ||
cell_width = cell_width + 2 | |||
end | end | ||
else | else | ||
if ((sharp * math.ceil(i / sharp)) - i) % 5 == 4 then | if ((sharp * math.ceil(i / sharp)) - i) % 5 == 4 then | ||
s = s .. " [[File:Up arrow petaluma script.svg|10px]] [[File:Quid narrow.svg|9px]]" | s = s .. " [[File:Up arrow petaluma script.svg|10px]] [[File:Quid narrow.svg|9px]]" | ||
cell_width = cell_width + 4 | |||
else | else | ||
for j = 1, ((sharp * math.ceil(i / sharp)) - i) % 5 do | for j = 1, ((sharp * math.ceil(i / sharp)) - i) % 5 do | ||
s = s .. " [[File:Down arrow petaluma script.svg|10px]]" | s = s .. " [[File:Down arrow petaluma script.svg|10px]]" | ||
cell_width = cell_width + 2 | |||
end | end | ||
end | end | ||
for j = 1, math.floor(((sharp * math.ceil(i / sharp)) - i) / 5) do | for j = 1, math.floor(((sharp * math.ceil(i / sharp)) - i) / 5) do | ||
s = s .. " [[File:Quid narrow.svg|9px]]" | s = s .. " [[File:Quid narrow.svg|9px]]" | ||
cell_width = cell_width + 2 | |||
end | end | ||
end | end | ||
| Line 90: | Line 100: | ||
s = s .. "  [[File:Heji32.svg|21px]]" | s = s .. "  [[File:Heji32.svg|21px]]" | ||
end | end | ||
tab = tab .. string.format(spanf, marg, s) | tab = tab .. string.format(spanf, cell_width, marg, s) | ||
end | end | ||
| Line 102: | Line 112: | ||
if cs == 0 then | if cs == 0 then | ||
marg = arrow_marg | marg = arrow_marg | ||
elseif cs == 1 | cell_width = 0 | ||
elseif cs == 1 then | |||
marg = flat_marg | |||
cell_width = 2 | |||
elseif cs == 2 then | |||
marg = flat_marg | marg = flat_marg | ||
cell_width = 4 | |||
end | end | ||
| Line 109: | Line 124: | ||
if (i - (sharp * math.floor(i / sharp))) % 5 == 4 then | if (i - (sharp * math.floor(i / sharp))) % 5 == 4 then | ||
s = s .. " [[File:Up arrow petaluma script.svg|10px]] [[File:Quid narrow.svg|9px]]" | s = s .. " [[File:Up arrow petaluma script.svg|10px]] [[File:Quid narrow.svg|9px]]" | ||
cell_width = cell_width + 4 | |||
else | else | ||
for j = 1, (i - (sharp * math.floor(i / sharp))) % 5 do | for j = 1, (i - (sharp * math.floor(i / sharp))) % 5 do | ||
s = s .. " [[File:Down arrow petaluma script.svg|10px]]" | s = s .. " [[File:Down arrow petaluma script.svg|10px]]" | ||
cell_width = cell_width + 2 | |||
end | end | ||
end | end | ||
for j = 1, math.floor((i - (sharp * math.floor(i / sharp))) / 5) do | for j = 1, math.floor((i - (sharp * math.floor(i / sharp))) / 5) do | ||
s = s .. " [[File:Quid narrow.svg|9px]]" | s = s .. " [[File:Quid narrow.svg|9px]]" | ||
cell_width = cell_width + 2 | |||
end | end | ||
else | else | ||
if ((sharp * math.ceil(i / sharp)) - i) % 5 == 4 then | if ((sharp * math.ceil(i / sharp)) - i) % 5 == 4 then | ||
s = s .. " [[File:Down arrow petaluma script.svg|10px]] [[File:Quip narrow.svg|9px]]" | s = s .. " [[File:Down arrow petaluma script.svg|10px]] [[File:Quip narrow.svg|9px]]" | ||
cell_width = cell_width + 4 | |||
else | else | ||
for j = 1, ((sharp * math.ceil(i / sharp)) - i) % 5 do | for j = 1, ((sharp * math.ceil(i / sharp)) - i) % 5 do | ||
s = s .. " [[File:Up arrow petaluma script.svg|10px]]" | s = s .. " [[File:Up arrow petaluma script.svg|10px]]" | ||
cell_width = cell_width + 2 | |||
end | end | ||
end | end | ||
for j = 1, math.floor(((sharp * math.ceil(i / sharp)) - i) / 5) do | for j = 1, math.floor(((sharp * math.ceil(i / sharp)) - i) / 5) do | ||
s = s .. " [[File:Quip narrow.svg|9px]]" | s = s .. " [[File:Quip narrow.svg|9px]]" | ||
cell_width = cell_width + 2 | |||
end | end | ||
end | end | ||
| Line 134: | Line 155: | ||
s = s .. "  [[File:Heji4.svg|27px]]" | s = s .. "  [[File:Heji4.svg|27px]]" | ||
end | end | ||
tab = tab .. string.format(spanf, marg, s) | tab = tab .. string.format(spanf, cell_width, marg, s) | ||
end | end | ||