|
|
| Line 2: |
Line 2: |
| local utils = require("Module:Utils") | | local utils = require("Module:Utils") |
| local tamnams = require("Module:TAMNAMS") | | local tamnams = require("Module:TAMNAMS") |
| | local step_vis = require("Module:Step vis") |
| local p = {} | | local p = {} |
|
| |
|
| Line 151: |
Line 152: |
|
| |
|
| return next_step_array | | return next_step_array |
| end
| |
|
| |
| -- Helper function
| |
| -- Create a step visualization that's based on the table on the diasem page
| |
| function p.step_pattern_to_simple_visualization(step_pattern)
| |
| local step_pattern = step_pattern or { 2, 2, 2, 1, 2, 2, 1 }
| |
|
| |
| local left_border = "├"
| |
| local right_border = "┤"
| |
| local no_border = "─"
| |
| local double_border = "╫"
| |
| local double_border_left = "╟"
| |
| local double_border_right = "╢"
| |
| local single_border = "┼"
| |
|
| |
| local step_visualization = ""
| |
|
| |
| -- For each step size of k, print a single border, followed by k-1 no-border symbols
| |
| -- If this is the first step, print the left border instead
| |
| -- If the step size is 0, print a double border only; if this happens, the next step should start with a border character
| |
| -- If this is the last step, add a right border after the entire sequence
| |
| for i = 1, #step_pattern do
| |
| local current_step_vis = ""
| |
| local current_step_size = step_pattern[i]
| |
|
| |
| if i == 1 then
| |
| if current_step_size == 0 then
| |
| current_step_vis = double_border_left
| |
| else
| |
| current_step_vis = left_border .. string.rep(no_border, current_step_size - 1)
| |
| end
| |
| elseif i == #step_pattern then
| |
| if current_step_size == 0 then
| |
| current_step_vis = double_border_right
| |
| else
| |
| current_step_vis = single_border .. string.rep(no_border, current_step_size - 1) .. right_border
| |
| end
| |
| else
| |
| if current_step_size == 0 then
| |
| current_step_vis = double_border
| |
| elseif step_pattern[i-1] == 0 then
| |
| current_step_vis = string.rep(no_border, current_step_size - 1)
| |
| else
| |
| current_step_vis = single_border .. string.rep(no_border, current_step_size - 1)
| |
| end
| |
| end
| |
|
| |
| step_visualization = step_visualization .. current_step_vis
| |
| end
| |
|
| |
| return step_visualization
| |
|
| |
| end | | end |
|
| |
|
| Line 406: |
Line 355: |
| | | |
| -- Add the step visualization | | -- Add the step visualization |
| local step_vis = p.step_pattern_to_simple_visualization(current_scale) | | local sv = step_vis.step_pattern_to_visualization(current_scale) |
| result = result .. string.format("| %s\n", step_vis) | | result = result .. string.format("| %s\n", sv) |
| | | |
| -- Add the scale sig | | -- Add the scale sig |