Module:ColorParse: Difference between revisions

Jump to navigation Jump to search
244 bytes added ,  22:31, 24 May 2020
implemented of how i assume alternation works
(basic implementation of beta shaders)
(implemented of how i assume alternation works)
Line 116: Line 116:
     strtbl = strtotbl(text)
     strtbl = strtotbl(text)
     finaltbl = {}
     finaltbl = {}
     if type == 'sequence' then
    interval = 1
     if type == 'alternation' then
        interval = math.floor(#strtbl/#colorlist)  --sets interval that color code switches.
        overflowbehavior = function(f) return colorlist[#colorlist] end
    elseif type == 'sequence' then
         overflowbehavior = function(f)  
         overflowbehavior = function(f)  
         e = f%#colorlist  
         e = f%#colorlist  
Line 125: Line 129:
         overflowbehavior = function(f) return 'y' end
         overflowbehavior = function(f) return 'y' end
     end
     end
 
    ci = 1
     for i=1, #strtbl do
     for i=1, #strtbl do
       if i > #colorlist then
       if ci > #colorlist then
           hexcolor = overflowbehavior(i)
           hexcolor = overflowbehavior(ci)
       else
       else
           hexcolor = colorlist[i]
           hexcolor = colorlist[ci]
       end
       end
       finaltbl[i] = "<span style=\"color: " .. luatable.parse(hexcolor) .. ";\">"  .. strtbl[i].. "</span>"
       finaltbl[i] = "<span style=\"color: " .. luatable.parse(hexcolor) .. ";\">"  .. strtbl[i].. "</span>"
       --i = i+1
       if i%interval == 0 then
        
          ci = ci + 1
       end     
     end
     end
     return table.concat(finaltbl)
     return table.concat(finaltbl)
    --return colorlist[3%#strtbl]
end
end


function p.test()
function p.test()
     --return p.shader('structural', 'Y-y-K-y-Y', 'alternation')
     return p.shader('structural', 'Y-y-K-y-Y', 'alternation')
     return p.shader('Stopsvalinn', 'R-r-K-y-Y', 'sequence')
     --return p.shader('Stopsvalinn', 'R-r-K-y-Y', 'sequence')
end
end


return p
return p

Navigation menu