2023年政策修订增补工作正在进行中,欢迎参与!
Module:Sandbox/Leranjun/MinecraftSkin
< Module:Sandbox | Leranjun
{{MinecraftSkin/Auto}}的另一种实现方式。
local p = {}
function p.main(frame)
-- Frames per second: 24
local FPS = tonumber(frame.args.FPS)
-- Animation duration: 1s
local DUR = 1
-- Initial delay (for loading): 1.5s
local DEL = 1.5
-- <img src="https://render.namemc.com/skin/3d/body.png?skin={{{skin}}}&model={{{model}}}&theta={{{theta}}}&phi={{{phi}}}&time={{{time}}}&width={{{width}}}&height={{{height}}}"/>
local skin = tostring(frame.args.skin)
local model = tostring(frame.args.model)
local theta = tostring(frame.args.theta)
local phi = tostring(frame.args.phi)
local width = tostring(frame.args.width)
local height = tostring(frame.args.height)
if (width == "") then
if (height == "") then
width = "40"
height = "80"
else
width = tostring(tonumber(height) / 2)
end
else
if (height == "") then
height = tostring(tonumber(width) * 2)
end
end
local r =
mw.html.create("div"):addClass("lr-mc"):css("width", width .. "px"):css("height", height .. "px"):css(
"pointer-events",
"none"
):css("user-select", "none")
for timee = 1, 360, (360 / FPS / DUR) do
local imgSrc =
string.format(
"https://render.namemc.com/skin/3d/body.png?skin=%s&model=%s&theta=%s&phi=%s&time=%s&width=%s&height=%s",
skin,
model,
theta,
phi,
timee,
width,
height
)
local imgDelay = tostring(DEL + (1 / FPS) * ((timee - 1) / (360 / FPS / DUR))) .. "s"
local curImg = mw.html.create("img"):attr("src", imgSrc)
local imgWrapper = mw.html.create("div"):css("animation-delay", imgDelay):node(tostring(curImg))
r:node(tostring(imgWrapper))
end
return tostring(r)
end
return p