Module:MOS mode degrees: Difference between revisions

Ganaram inukshuk (talk | contribs)
m Added skeleton code for simplified cell color function
Ganaram inukshuk (talk | contribs)
Added back cell colors for true-mos modes
Line 554: Line 554:
-- Finds the row color for a single cell
-- Finds the row color for a single cell
function p.cell_color(interval, input_mos)
function p.cell_color(interval, input_mos)
local interval = interval or {['L']=3, ['s']=1}
local input_mos = input_mos or mos.new(5,2)
local period_step_count = mos.period_step_count(input_mos)
local interval_step_count = mos.interval_step_count(interval)
local chroma_count = mos.interval_chroma_count(interval, input_mos)
local is_period_interval = interval_step_count % period_step_count == 0
local color = p.cell_color_none
if is_period_interval then
if chroma_count > 0 then
color = p.cell_color_lg_altered_size
elseif chroma_count == 0 then
color = p.cell_color_none
elseif chroma_count < 0 then
color = p.cell_color_sm_altered_size
end
else
if chroma_count > 0 then
color = p.cell_color_lg_altered_size
elseif chroma_count == 0 then
color = p.cell_color_large_size
elseif chroma_count == -1 then
color = p.cell_color_small_size
elseif chroma_count < -1 then
color = p.cell_color_sm_altered_size
end
end
return color
end
end


Line 576: Line 605:
-- Get step matrices for every mode
-- Get step matrices for every mode
local step_matrices = mos.modes_to_step_matrices(input_mos)
local step_matrices = mos.modes_to_step_matrices(input_mos)
 
-- Get row colors
-- Equave step count
--local row_colors = p.calculate_row_colors(input_mos, step_matrices)
local equave_step_count = mos.equave_step_count(input_mos)
-- Create table
-- Create table
Line 596: Line 625:
-- Add header for scale degrees
-- Add header for scale degrees
result = result .. string.format('! colspan="%d" class="unsortable" | Scale degree (%sdegree)\n', mossteps_per_equave + 1, mos_prefix)
result = result .. string.format('! colspan="%d" class="unsortable" | Scale degree (%sdegree)\n', equave_step_count + 1, mos_prefix)
-- Add second row of headers
-- Add second row of headers
result = result .. "|-\n"
result = result .. "|-\n"
for i = 1, mossteps_per_equave + 1 do
for i = 1, equave_step_count + 1 do
result = result .. string.format('! class="unsortable" |%d\n', i-1)
result = result .. string.format('! class="unsortable" |%d\n', i-1)
end
end
Line 621: Line 650:
-- Add scale degrees with cell coloring
-- Add scale degrees with cell coloring
-- This includes period intervals bold and alterations italicized
for j = 1, #step_matrices[i] do
for j = 1, #step_matrices[i] do
local degree_quality = tamnams.decode_quality(step_matrices[i][j], input_mos, "shortened")
local current_interval = step_matrices[i][j]
result = result .. string.format('| %s\n', degree_quality)
local degree_quality = tamnams.decode_quality(current_interval, input_mos, "shortened")
local cell_color = p.cell_color(current_interval, input_mos)
local style_code = cell_color == p.cell_color_none and "" or string.format('style="background: #%s" | ', cell_color)
result = result .. string.format('| %s%s\n', style_code, degree_quality)