Skip to content

Commit

Permalink
textureutil.dummy does now also accept strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertZenz committed Oct 8, 2015
1 parent a8844fe commit f89ef0b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
6 changes: 4 additions & 2 deletions doc/modules/textureutil.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ <h2><a name="Functions"></a>Functions</h2>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">inner_color</span>
The color for the inner part.
The color for the inner part, either a string with
leading "#" or a Color.
</li>
<li><span class="parameter">border_color</span>
The color for the border.
The color for the border, either a string with
leading "#" or a Color.
</li>
</ul>

Expand Down
17 changes: 13 additions & 4 deletions mods/utils/textureutil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,21 @@ textureutil = {}

--- Creates a dummy texture with the two given colors.
--
-- @param inner_color The color for the inner part.
-- @param border_color The color for the border.
-- @param inner_color The color for the inner part, either a string with
-- leading "#" or a Color.
-- @param border_color The color for the border, either a string with
-- leading "#" or a Color.
-- @return The dummy texture (string).
function textureutil.dummy(inner_color, border_color)
local inner = "(dummy_inner.png^[colorize:#" .. inner_color.hex .. ":240)"
local border = "(dummy_border.png^[colorize:#" .. border_color.hex .. ":255)"
if type(inner_color) == "table" then
inner_color = "#" .. inner_color.hex
end
if type(outer_color) == "table" then
outer_color = "#" .. outer_color.hex
end

local inner = "(dummy_inner.png^[colorize:" .. inner_color .. ":240)"
local border = "(dummy_border.png^[colorize:" .. border_color .. ":255)"

return inner .. "^" .. border
end
Expand Down

0 comments on commit f89ef0b

Please sign in to comment.