Modulo:FunzioniGeneriche: differenze tra le versioni

Vai alla navigazione Vai alla ricerca
TItles in example output
(First TextColor iteration)
(TItles in example output)
(9 versioni intermedie di uno stesso utente non sono mostrate)
Riga 20: Riga 20:


     local Intro = 'Questo esempio è automaticamente generato tramite script LUA a partire dal codice di esempio presente in <code>[[' .. SubPageTitle.prefixedText .. ']]</code>'
     local Intro = 'Questo esempio è automaticamente generato tramite script LUA a partire dal codice di esempio presente in <code>[[' .. SubPageTitle.prefixedText .. ']]</code>'
     local CodeString = 'Il codice'
     local CodeString = '=== Il codice ==='
     local ReturnString = 'restituisce'
     local ReturnString = '=== restituisce ==='


Content = SubPageTitle:getContent()
Content = SubPageTitle:getContent()
Riga 99: Riga 99:
-- @param BackColor The hex code of the background color
-- @param BackColor The hex code of the background color
-- @return name of the color
-- @return name of the color
function p.TextColor(BackColor)
function p.TextColor(frame)
local hex = BackColor:gsub("#","")
local hex = string.sub(frame.args[1], 2)
local R, G, B
local R, G, B
local L
     if hex:len() == 3 then
     if hex:len() == 3 then
       --return (tonumber("0x"..hex:sub(1,1))*17)/255, (tonumber("0x"..hex:sub(2,2))*17)/255, (tonumber("0x"..hex:sub(3,3))*17)/255
       --return (tonumber("0x"..hex:sub(1,1))*17)/255, (tonumber("0x"..hex:sub(2,2))*17)/255, (tonumber("0x"..hex:sub(3,3))*17)/255
Riga 108: Riga 110:
       B = tonumber("0x"..hex:sub(3,3))*17/255
       B = tonumber("0x"..hex:sub(3,3))*17/255
     else
     else
      R = tonumber("0x"..hex:sub(1,2))/255
    R = tonumber("0x"..hex:sub(1,2))/255
      G = tonumber("0x"..hex:sub(3,4))/255
    G = tonumber("0x"..hex:sub(3,4))/255
      B = tonumber("0x"..hex:sub(5,6))/255
    B = tonumber("0x"..hex:sub(5,6))/255
     end
     end
      
      
     return (R * 0.299 + G * 0.587 + B * 0.114) / 256
     L = (R * 0.299 + G * 0.587 + B * 0.114) --/ 256
    if L < 0.5 then
    return "white"
    else
    return "black"
    end
end
end
return p
return p

Menu di navigazione