Add new neovim welcome screen and change probability definitions
This commit is contained in:
parent
1ea00e644d
commit
949e930a56
@ -4,7 +4,7 @@
|
|||||||
local function clamp(x, min, max) return math.max(math.min(x, max), min) end
|
local function clamp(x, min, max) return math.max(math.min(x, max), min) end
|
||||||
|
|
||||||
local function get_random_image()
|
local function get_random_image()
|
||||||
images = {
|
local images = {
|
||||||
{
|
{
|
||||||
[[██╗ █████╗ ██████╗██╗ ██╗███████╗]],
|
[[██╗ █████╗ ██████╗██╗ ██╗███████╗]],
|
||||||
[[██║ ██╔══██╗██╔════╝██║ ██║██╔════╝]],
|
[[██║ ██╔══██╗██╔════╝██║ ██║██╔════╝]],
|
||||||
@ -29,21 +29,53 @@ local function get_random_image()
|
|||||||
[[██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║]],
|
[[██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║]],
|
||||||
[[██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║]],
|
[[██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║]],
|
||||||
[[╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝]]
|
[[╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝]]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
[[ ▄ ]],
|
||||||
|
[[ ▟█▙ ]],
|
||||||
|
[[ ▟███▙ ]],
|
||||||
|
[[ ▟█████▙ ]],
|
||||||
|
[[ ▟███████▙ ]],
|
||||||
|
[[ ▂▔▀▜██████▙ ]],
|
||||||
|
[[ ▟██▅▂▝▜█████▙ ]],
|
||||||
|
[[ ▟█████████████▙ ]],
|
||||||
|
[[ ▟███████████████▙ ]],
|
||||||
|
[[ ▟█████████████████▙ ]],
|
||||||
|
[[ ▟███████████████████▙ ]],
|
||||||
|
[[ ▟█████████▛▀▀▜████████▙ ]],
|
||||||
|
[[ ▟████████▛ ▜███████▙ ]],
|
||||||
|
[[ ▟█████████ ████████▙ ]],
|
||||||
|
[[ ▟██████████ █████▆▅▄▃▂ ]],
|
||||||
|
[[ ▟██████████▛ ▜█████████▙ ]],
|
||||||
|
[[ ▟██████▀▀▀ ▀▀██████▙ ]],
|
||||||
|
[[ ▟███▀▘ ▝▀███▙ ]],
|
||||||
|
[[▟▛▀ ▀▜▙]],
|
||||||
|
[[ btw ]]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local i = 3
|
local pmf = {0.25, 0.25, 0.25, 0.25}
|
||||||
|
local cdf = {}
|
||||||
|
|
||||||
math.randomseed(os.time())
|
cdf[1] = 0
|
||||||
if math.fmod(math.random(100), 5) == 0 then
|
for j = 2, #pmf+1 do
|
||||||
if math.random(0, 1) == 0 then
|
cdf[j] = cdf[j - 1] + pmf[j - 1]
|
||||||
i = 1
|
|
||||||
else
|
|
||||||
i = 2
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return images[i]
|
if math.abs(cdf[#cdf] - 1) > 0.01 then
|
||||||
|
error("Probabilities do not add up to 1")
|
||||||
|
elseif #images ~= #pmf then
|
||||||
|
error("Number of images and probabilities do not match")
|
||||||
|
end
|
||||||
|
|
||||||
|
math.randomseed(os.time())
|
||||||
|
local r = math.random(100)
|
||||||
|
|
||||||
|
for j = 2, #cdf do
|
||||||
|
if r <= cdf[j] * 100 then
|
||||||
|
return images[j-1]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-----------------
|
-----------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user