mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 19:19:21 +01:00
52 lines
1.1 KiB
Lua
Executable File
52 lines
1.1 KiB
Lua
Executable File
|
|
local color = require("Color")
|
|
local materials = {}
|
|
|
|
------------------------------------------------------------------------------------------------------------------------
|
|
|
|
materials.types = {
|
|
textured = 1,
|
|
solid = 2,
|
|
}
|
|
|
|
function materials.newDebugTexture(width, height, h)
|
|
local texture = {width = width, height = height}
|
|
|
|
local bStep = 1 / height
|
|
local sStep = 1 / width
|
|
|
|
local s, b = 0, 0
|
|
local blackSquare = false
|
|
for y = 1, height do
|
|
texture[y] = {}
|
|
for x = 1, width do
|
|
texture[y][x] = blackSquare == true and 0x0 or color.HSBToInteger(h, s, b)
|
|
blackSquare = not blackSquare
|
|
b = b + bStep
|
|
end
|
|
b = 0
|
|
s = s + sStep
|
|
blackSquare = not blackSquare
|
|
end
|
|
return texture
|
|
end
|
|
|
|
function materials.newSolidMaterial(color)
|
|
return {
|
|
type = materials.types.solid,
|
|
color = color
|
|
}
|
|
end
|
|
|
|
function materials.newTexturedMaterial(texture)
|
|
return {
|
|
type = materials.types.textured,
|
|
texture = texture
|
|
}
|
|
end
|
|
|
|
------------------------------------------------------------------------------------------------------------------------
|
|
|
|
return materials
|
|
|