Module:Interval ruler: Difference between revisions
From Xenharmonic Reference
No edit summary |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p.e( | function p.e(frame) | ||
length = tonumber( | length = tonumber(frame.args[3]) or 1200 | ||
resolution = tonumber( | resolution = tonumber(frame.args[1]) | ||
intervals = | intervals = frame.args[2] or {} | ||
if(type(intervals) == "string") then | if(type(intervals) == "string") then | ||
local t = {} | local t = {} | ||
Latest revision as of 08:11, 29 December 2025
Documentation for this module may be created at Module:Interval ruler/doc
local p = {}
function p.e(frame)
length = tonumber(frame.args[3]) or 1200
resolution = tonumber(frame.args[1])
intervals = frame.args[2] or {}
if(type(intervals) == "string") then
local t = {}
for item in (intervals):gmatch("%s*([^,]+)%s*") do t[#t+1] = item end
intervals = t
end
if(type(intervals) == "number") then
intervals = {intervals}
end
i = math.floor(length/1200 * resolution + 0.5)
z = {}
for k = 0, i do
z[k] = "─"
end
for n = 1, #intervals do
z[math.floor(intervals[n]/1200 * resolution + 0.5)] = "┴"
end
for m = 0, math.floor(i/resolution) do
if (z[m*resolution] == "┴") then
z[m*resolution] = "┼"
else
z[m*resolution] = "┬"
end end
if(z[0]=="┼") then
z[0]="├"
end
if(z[0]=="┬") then
z[0]="┌"
end
if(z[#z]=="┼") then
z[#z]="┤"
end
if(z[#z]=="┬") then
z[#z]="┐"
end
if(z[#z]=="┴") then
z[#z]="┘"
end
if(z[#z]=="─") then
z[#z]="╮"
end
return table.concat(z,"",0)
end
return p
