[HELPER] Math Constant Helper
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RozaniGhani-RG

//@version=5
indicator('[HELPER] Math Constant Helper', shorttitle = 'HMCH')

// 0. Tooltips
// 1. Inputs for table
// 3. New array
// 4. Construct

// ————————————————————————————————————————————————————————————————————————————— 0. Tooltips {
T0 = 'Small font size recommended for mobile app or multiple layout'
T1 = 'Tick to hide'
// }
// ————————————————————————————————————————————————————————————————————————————— 1. Inputs for table {
i_s_font          = input.string('normal',       'Font size', tooltip = T0, options = ['tiny', 'small',  'normal', 'large', 'huge'])
i_s_Y             = input.string('top',     'Table Position', inline = '0', options = ['top',  'middle', 'bottom'])
i_s_X             = input.string('right',                 '', inline = '0', options = ['left', 'center', 'right'])
i_c_text          = input.color(color.black,          'Text')
i_c_bg            = input.color(color.white,    'Background')
i_c_border        = input.color(color.black,        'Border')
// }
// ————————————————————————————————————————————————————————————————————————————— 2. Inputs for array {
i_b_e             = input.bool(true,                  'Euler', inline ='1', group = 'math')
i_b_pi            = input.bool(true,             'Archimedes', inline ='2', group = 'math')
i_b_phi           = input.bool(true,           'Golden Ratio', inline ='3', group = 'math')
i_b_rphi          = input.bool(true, 'Golden Ratio Conjugate', inline ='4', group = 'math')
// }
// ————————————————————————————————————————————————————————————————————————————— 3. New array {
table[] arr_table = array.new_table()
arr_bool          = array.new_bool(4)
math_name         = array.from( 'Euler', 'Archimedes', 'Golden Ratio', 'Golden Ratio Conjugate')
math_short_name   = array.from(     'e',         'pi',          'phi',                   'rphi')
math_constant     = array.from(  math.e,      math.pi,       math.phi,                math.rphi)
math_string       = array.from('math.e',    'math.pi',     'math.phi',              'math.rphi')
array.push(arr_table, table.new(position = i_s_Y + '_' + i_s_X, rows = 12, columns = 5, frame_color = i_c_border, frame_width = 1, border_color = i_c_border, border_width = 1))
array.set(arr_bool, 0, i_b_e)
array.set(arr_bool, 1, i_b_pi)
array.set(arr_bool, 2, i_b_phi)
array.set(arr_bool, 3, i_b_rphi)
// }
// ————————————————————————————————————————————————————————————————————————————— 4. Construct {
if barstate.islast
    table.cell(array.get(arr_table, 0), 0, 0,       'Name', text_color = i_c_text, text_size = i_s_font, bgcolor = i_c_bg)
    table.cell(array.get(arr_table, 0), 1, 0, 'Short Name', text_color = i_c_text, text_size = i_s_font, bgcolor = i_c_bg)
    table.cell(array.get(arr_table, 0), 2, 0,   'Constant', text_color = i_c_text, text_size = i_s_font, bgcolor = i_c_bg)
    table.cell(array.get(arr_table, 0), 3, 0,      'Value', text_color = i_c_text, text_size = i_s_font, bgcolor = i_c_bg)
    for _row = 0 to 3
        if array.get(arr_bool, _row)
            table.cell(array.get(arr_table, 0), 0, _row + 1,                array.get(      math_name, _row),           text_color = i_c_text, text_size = i_s_font, bgcolor = i_c_bg)
            table.cell(array.get(arr_table, 0), 1, _row + 1,                array.get(math_short_name, _row),           text_color = i_c_text, text_size = i_s_font, bgcolor = i_c_bg)
            table.cell(array.get(arr_table, 0), 2, _row + 1,                array.get(    math_string, _row),           text_color = i_c_text, text_size = i_s_font, bgcolor = i_c_bg)
            table.cell(array.get(arr_table, 0), 3, _row + 1, str.tostring(array.get(    math_constant, _row), '0.000'), text_color = i_c_text, text_size = i_s_font, bgcolor = i_c_bg)
// }