These scripts are licensed under CC0: https://creativecommons.org/publicdomain/zero/1.0/
These scripts convert any image supported by ImageMagick to Roblox model or GUI.
Todo:
- Skybox
- Lua code generator
~uyjulian
These scripts are licensed under CC0: https://creativecommons.org/publicdomain/zero/1.0/
These scripts convert any image supported by ImageMagick to Roblox model or GUI.
Todo:
~uyjulian
--bit.ly/uyjulian | |
--Licenced under Creative Commons Zero 1.0 | |
local magick = require"magick" --https://github.com/leafo/magick | |
local ExportXML_S = [[<roblox xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.roblox.com/roblox.xsd" version="4"> | |
<External>null</External> | |
<External>nil</External> | |
<Item class="Model" referent="RBX0">]] | |
local ExportXML_Part = [[<Item class="Part" referent="RBX12"> | |
<Properties> | |
<bool name="Anchored">true</bool> | |
<token name="BottomSurface">0</token> | |
<Color3 name="Color"> | |
<R>$r</R> | |
<G>$g</G> | |
<B>$b</B> | |
</Color3> | |
<CoordinateFrame name="CFrame"> | |
<X>$x</X> | |
<Y>$y</Y> | |
<Z>$z</Z> | |
<R00>1</R00> | |
<R01>0</R01> | |
<R02>0</R02> | |
<R10>0</R10> | |
<R11>1</R11> | |
<R12>0</R12> | |
<R20>0</R20> | |
<R21>0</R21> | |
<R22>1</R22> | |
</CoordinateFrame> | |
<token name="FormFactor">0</token> | |
<token name="TopSurface">0</token> | |
<float name="Transparency">$t</float> | |
<Vector3 name="size"> | |
<X>1</X> | |
<Y>$height</Y> | |
<Z>1</Z> | |
</Vector3> | |
</Properties> | |
<Item class="SpecialMesh" referent="RBX1"> | |
<Properties> | |
<token name="LODX">2</token> | |
<token name="LODY">2</token> | |
<Content name="MeshId"><url>http://www.roblox.com/Asset/?id=9856898</url></Content> | |
<token name="MeshType">5</token> | |
<string name="Name">Mesh</string> | |
<Vector3 name="Scale"> | |
<X>2</X> | |
<Y>2</Y> | |
<Z>2</Z> | |
</Vector3> | |
<Content name="TextureId"><url>http://www.roblox.com/asset/?ID=1361097</url></Content> | |
<Vector3 name="VertexColor"> | |
<X>$r</X> | |
<Y>$g</Y> | |
<Z>$b</Z> | |
</Vector3> | |
</Properties> | |
</Item> | |
</Item>]] | |
local ExportXML_E = [[</Item></roblox>]] | |
local img, err = magick.load_image(arg[1]) | |
if img == nil then | |
error(err) | |
end | |
local out = io.open(arg[2], "w") | |
out:write(ExportXML_S) | |
local width = img:get_width() | |
local height = img:get_height() | |
for x = 1, width do | |
for y = 1, height do | |
local r, g, b, a = img:get_pixel(x, y) | |
a = 1 - a | |
if a ~= 1 then | |
local rpls, n = ExportXML_Part:gsub("$r", r):gsub("$g", g):gsub("$b", b):gsub("$x", width - x):gsub("$y", height - y):gsub("$z", 1):gsub("$height", 1):gsub("$t", a) | |
out:write(rpls) | |
end | |
end | |
end | |
out:write(ExportXML_E) |
--bit.ly/uyjulian | |
--Licenced under Creative Commons Zero 1.0 | |
local magick = require"magick" --https://github.com/leafo/magick | |
local ExportXML_S = [[<roblox xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.roblox.com/roblox.xsd" version="4"> | |
<External>null</External> | |
<External>nil</External> | |
<Item class="ScreenGui" referent="RBXfad51c4a90b346ee8036c5346dab7d66"> | |
<Properties> | |
<string name="Name">ScreenGui</string> | |
</Properties> | |
<Item class="Frame" referent="RBX48ddfeec1b96458aab86395cc814e2e2"> | |
<Properties> | |
<float name="BackgroundTransparency">1</float> | |
<int name="BorderSizePixel">0</int> | |
<string name="Name">Frame</string> | |
<UDim2 name="Size"> | |
<XS>0</XS> | |
<XO>$width</XO> | |
<YS>0</YS> | |
<YO>$height</YO> | |
</UDim2> | |
</Properties> | |
]] | |
local ExportXML_Part = [[<Item class="Frame" referent="RBX1dcfb1ddaca648c99bfacdb25878cd03"> | |
<Properties> | |
<Color3 name="BackgroundColor3">$c</Color3> | |
<float name="BackgroundTransparency">$t</float> | |
<int name="BorderSizePixel">0</int> | |
<UDim2 name="Position"> | |
<XS>0</XS> | |
<XO>$x</XO> | |
<YS>0</YS> | |
<YO>$y</YO> | |
</UDim2> | |
<float name="Rotation">0</float> | |
<UDim2 name="Size"> | |
<XS>0</XS> | |
<XO>1</XO> | |
<YS>0</YS> | |
<YO>1</YO> | |
</UDim2> | |
</Properties> | |
</Item>]] | |
local ExportXML_E = [[</Item></Item></roblox>]] | |
local img, err = magick.load_image(arg[1]) | |
if img == nil then | |
error(err) | |
end | |
local out = io.open(arg[2], "w") | |
local width = img:get_width() | |
local height = img:get_height() | |
local rpls, n = ExportXML_S:gsub("$width", width):gsub("$height", height) | |
out:write(rpls) | |
local function tohex(num) | |
return string.format("%02x", num) | |
end | |
function math.normalize(x,y) | |
local l=(x*x+y*y)^.5 | |
if l==0 then | |
return 0,0,0 | |
else | |
return x/l,y/l,l | |
end | |
end | |
for x = 1, width do | |
for y = 1, height do | |
local r, g, b, a = img:get_pixel(x, y) | |
a = 1 - a | |
if a ~= 1 then | |
local gencolor = tonumber("0xff" .. tohex(r*255) .. tohex(g*255) .. tohex(b*255)) | |
local rpls, n = ExportXML_Part:gsub("$c", gencolor):gsub("$x", x - 1):gsub("$y", y - 1):gsub("$t", a) | |
out:write(rpls) | |
end | |
end | |
end | |
out:write(ExportXML_E) |