colors.jl support

This commit is contained in:
Mike J Innes 2019-03-12 14:25:17 +00:00
parent 02c4ada05a
commit 0c110d70da
1 changed files with 18 additions and 3 deletions

View File

@ -48,9 +48,24 @@ function update!(opt, ::Nothing, gs::Globals)
if inplace(x, )
update!(opt, x, )
else
isconst(id.mod, id.name) && error("Can't update constant $id")
x, state = update(opt, x, )
setglobal!(id.mod, id.name, x)
if isconst(id.mod, id.name)
id.mod == Main && error("Can't update constant $id")
else
x, state = update(opt, x, )
setglobal!(id.mod, id.name, x)
end
end
end
end
# Package Integration
using Requires
@init @require Colors="5ae59095-9a9b-59fe-a467-6f913c188581" begin
function update(opt, x::Colors.RGB{T}, ::NamedTuple) where T
Colors.RGB{T}(clamp(update(opt, x.r, .r)[1], 0, 1),
clamp(update(opt, x.g, .g)[1], 0, 1),
clamp(update(opt, x.b, .b)[1], 0, 1)), nothing
end
end