function RED() return 1.0, 0.0, 0.0 end

function GREEN() return 0.0, 0.5, 0.0 end

function BLUE() return 0.0, 0.0, 1.0 end

function YELLOW() return 1.0, 1.0, 0.0 end

function UiPCChooseColor() SetColorFromHEX("#FFFF7F") end

function UiPCApplayedColor() SetColorFromHEX("#47B66D") end

function UiPCCantDoItColor() SetColorFromHEX("#d76161") end

function UiDisableColor() SetColorFromHEX("#BABABA") end

function SetColorFromRGBA(red, green, blue, alpha)
    if alpha then
        UiColor(red / 255, green / 255, blue / 255, alpha)
    else
        UiColor(red / 255, green / 255, blue / 255)
    end
end

-- example SetColorFromHEX(hex_color, transparancy) where
-- hex_color - color in HEX variants
-- transparancy - if set then chagenged transparency in hex_color
-- warning: heavily unoptimized
function SetColorFromHEX(hex_color, opt_transparency)
    -- upper string
    hex_color = hex_color:upper()
    -- Clear # in 1st place
    if hex_color:sub(1, 1) == "#" then
        hex_color = hex_color:sub(2, #hex_color)
    end
    -- Check match set symbols
    local HEX = hex_color:match("^[%dA-F]+$")
    -- Check correcting HEX
    if not HEX or (#HEX ~= 8 and #HEX ~= 6) then
        return
    end
    local r, g, b, a
    r = tonumber(HEX:sub(1, 2), 16) / 255
    g = tonumber(HEX:sub(3, 4), 16) / 255
    b = tonumber(HEX:sub(5, 6), 16) / 255
    if opt_transparency then
        a = opt_transparency / 100
    else
        a = (tonumber(HEX:sub(7, 8), 16) or 255) /255
    end
    UiColor(r, g, b, a)
    return r,g,b,a
end

function highlightBlock(width, height, stroke_size, color, speed)
    local stroke = math.sin(GetTime() * (speed or 3) ) * (stroke_size or 6)
    UiPush()
        if color then UiColor(unpack(color)) else SetColorFromRGBA(151, 190, 34, 0.75) end
        UiTranslate(-stroke, -stroke)
        UiRect(width + 2*stroke, height + 2*stroke)
    UiPop()
end
