Module:Interval ruler: Difference between revisions
From Xenharmonic Reference
No edit summary |
m Easier to copy into Scale Workshop |
||
| (One intermediate revision by one other user not shown) | |||
| Line 4: | Line 4: | ||
length = tonumber(frame.args[3]) or 1200 | length = tonumber(frame.args[3]) or 1200 | ||
addsteps = tonumber(frame.args[4] or 1 | addsteps = tonumber(frame.args[4]) or 1 | ||
resolution = tonumber(frame.args[1]) | resolution = tonumber(frame.args[1]) | ||
intervals = frame.args[2] or {} | intervals = frame.args[2] or {} | ||
| Line 63: | Line 63: | ||
z[#z+1]= (math.floor(intervals[kn]/1200 * resolution + 0.5) - math.floor(intervals[kn-1]/1200 * resolution + 0.5)) | z[#z+1]= (math.floor(intervals[kn]/1200 * resolution + 0.5) - math.floor(intervals[kn-1]/1200 * resolution + 0.5)) | ||
if(kn ~= #intervals) then | if(kn ~= #intervals) then | ||
z[#z+1] = " | z[#z+1] = " " | ||
end | end | ||
end | end | ||
Latest revision as of 22:46, 15 May 2026
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
addsteps = tonumber(frame.args[4]) or 1
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
if(addsteps == 1) then
z[#z+1]=" "
for kn = 2, #intervals do
z[#z+1]= (math.floor(intervals[kn]/1200 * resolution + 0.5) - math.floor(intervals[kn-1]/1200 * resolution + 0.5))
if(kn ~= #intervals) then
z[#z+1] = " "
end
end
end
if(addsteps == 2) then
z[#z+1]=" ["
for kn = 2, #intervals do
z[#z+1]= (math.floor(intervals[kn]/1200 * resolution + 0.5))
if(kn ~= #intervals) then
z[#z+1] = " "
end
end
z[#z+1] = "]"
end
return table.concat(z,"",0)
end
return p
