66 392
contributi
mNessun oggetto della modifica |
(TItles in example output) |
||
(7 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 100: | Riga 100: | ||
-- @return name of the color | -- @return name of the color | ||
function p.TextColor(frame) | function p.TextColor(frame) | ||
local hex = string.sub(frame.args[1], | 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 | |||
G = tonumber("0x"..hex:sub(3,4))/255 | |||
B = tonumber("0x"..hex:sub(5,6))/255 | |||
end | end | ||
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 |