From a596680c20618232e248aa4e45bed22749a30e1b Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Tue, 5 Jul 2016 13:37:27 +0200 Subject: 2016-07-05 13:06:00 --- tex/context/base/mkiv/colo-ini.lua | 99 ++++++++++---------------------------- 1 file changed, 26 insertions(+), 73 deletions(-) (limited to 'tex/context/base/mkiv/colo-ini.lua') diff --git a/tex/context/base/mkiv/colo-ini.lua b/tex/context/base/mkiv/colo-ini.lua index a2e761eae..655176f7e 100644 --- a/tex/context/base/mkiv/colo-ini.lua +++ b/tex/context/base/mkiv/colo-ini.lua @@ -44,7 +44,7 @@ local texgettoks = tex.gettoks local a_color = attributes.private('color') local a_transparency = attributes.private('transparency') -local a_colorspace = attributes.private('colormodel') +local a_colormodel = attributes.private('colormodel') local register_color = colors.register local attributes_list = attributes.list @@ -610,74 +610,18 @@ local function mpcolor(model,ca,ta,default) end -- local function mpnamedcolor(name) --- return mpcolor(texgetattribute(a_colorspace),l_color[name] or l_color.black,l_transparency[name] or false) +-- return mpcolor(texgetattribute(a_colormodel),l_color[name] or l_color.black,l_transparency[name] or false) -- end local colornamespace = getnamespace("colornumber") local paletnamespace = getnamespace("colorpalet") --- local function mpnamedcolor(name) --- local prefix = texgettoks("t_colo_prefix") --- local cn --- if prefix ~= "" then --- local v = valid[prefix..name] --- if not v then --- local n = paletnamespace .. prefix .. name --- local p = valid[n] --- if p == true then --- cn = colornamespace .. n --- elseif p then --- cn = colornamespace .. p --- else --- cn = colornamespace .. name --- end --- elseif v == true then --- cn = colornamespace .. paletnamespace .. prefix .. name --- else --- cn = colornamespace .. v --- end --- elseif valid[name] then --- cn = colornamespace .. name --- else --- return mpcolor(texgetattribute(a_colorspace),l_color.black) --- end --- -- return mpcolor(texgetattribute(a_colorspace),l_color[name] or l_color.black) --- return mpcolor(texgetattribute(a_colorspace),texgetcount(cn),l_transparency[name]) --- end - --- local function mpnamedcolor(name) --- local colorspace = texgetattribute(a_colorspace) --- local prefix = texgettoks("t_colo_prefix") --- local cn --- if prefix ~= "" then --- local v = valid[prefix..name] --- if not v then --- local n = paletnamespace .. prefix .. name --- local p = valid[n] --- if p == true then --- cn = n --- elseif p then --- cn = p --- else --- cn = name --- end --- elseif v == true then --- cn = paletnamespace .. prefix .. name --- else --- cn = v --- end --- elseif valid[name] then --- cn = name --- else --- return mpcolor(colorspace,l_color.black) --- end --- cn = counts[cn] --- cn = cn and texgetcount(cn) or l_color[name] or l_color.black -- fall back to old method --- return mpcolor(colorspace,cn,l_transparency[name]) --- end +function colors.currentmodel() + return texgetattribute(a_colormodel) +end -local function mpnamedcolor(name) - local space = texgetattribute(a_colorspace) +local function namedcolorattributes(name) + local space = texgetattribute(a_colormodel) local prefix = texgettoks("t_colo_prefix") local color if prefix ~= "" then @@ -696,7 +640,7 @@ local function mpnamedcolor(name) elseif valid[name] then color = name else - return mpcolor(space,l_color.black) + return space, l_color.black end color = counts[color] if color then @@ -705,17 +649,19 @@ local function mpnamedcolor(name) color = l_color[name] -- fall back on old method end if color then - return mpcolor(space,color,l_transparency[name]) + return space, color, l_transparency[name] else - return mpcolor(space,l_color.black) + return space, l_color.black end end --- mp.NamedColor = function(str) --- mpprint(mpnamedcolor(str)) --- end +colors.namedcolorattributes = namedcolorattributes -- can be used local + +local function mpnamedcolor(name) + return mpcolor(namedcolorattributes(name)) +end -local function mpoptions(model,ca,ta,default) -- will move to mlib-col +local function mpoptions(model,ca,ta,default) -- will move to mlib-col .. not really needed return formatters["withcolor %s"](mpcolor(model,ca,ta,default)) end @@ -723,6 +669,13 @@ colors.mpcolor = mpcolor colors.mpnamedcolor = mpnamedcolor colors.mpoptions = mpoptions +-- elsewhere: +-- +-- mp.NamedColor = function(str) +-- mpprint(mpnamedcolor(str)) +-- end + + -- local function formatcolor(ca,separator) -- local cv = colorvalues[ca] -- if cv then @@ -1014,9 +967,9 @@ implement { implement { name = "setcolormodel", - arguments = { "string", "boolean" }, + arguments = { "string", "string" }, actions = function(model,weight) - texsetattribute(a_colorspace,setcolormodel(model,weight)) + texsetattribute(a_colormodel,setcolormodel(model,weight)) end } @@ -1144,7 +1097,7 @@ do if model and model ~= 0 then model = model else - model = forcedmodel(texgetattribute(a_colorspace)) + model = forcedmodel(texgetattribute(a_colormodel)) if model == 1 then model = cv[1] end -- cgit v1.2.3