diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/colo-ini.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/colo-ini.lua | 66 |
1 files changed, 22 insertions, 44 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/colo-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/colo-ini.lua index 3c8d23abc09..921612b0fd4 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/colo-ini.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/colo-ini.lua @@ -43,7 +43,6 @@ local texsetattribute = tex.setattribute local texgetattribute = tex.getattribute local texgetcount = tex.getcount local texgettoks = tex.gettoks -local texgetmacro = tokens.getters.macro local a_color = attributes.private('color') local a_transparency = attributes.private('transparency') @@ -274,9 +273,7 @@ local function forcedmodel(model) -- delayed till the backend but mp directly return 2 end elseif model == 5 then -- spot - if spot_okay then - return 5 - elseif cmyk_okay then + if cmyk_okay then return 4 elseif rgb_okay then return 3 @@ -312,8 +309,7 @@ local function definetransparency(name,n,global) end local settings = settings_to_hash_strict(n) if settings then - local a = settings.a - local t = settings.t + local a, t = settings.a, settings.t if a and t then definetransparent(name, transparencies.register(name,transparent[a] or tonumber(a) or 1,tonumber(t) or 1), global) else @@ -444,23 +440,16 @@ local function defineprocesscolor(name,str,global,freeze) -- still inconsistent else local settings = settings_to_hash_strict(str) if settings then - local r = settings.r - local g = settings.g - local b = settings.b + local r, g, b = settings.r, settings.g, settings.b if r or g or b then -- we can consider a combined rgb cmyk s definition definecolor(name, register_color(name,'rgb', tonumber(r) or 0, tonumber(g) or 0, tonumber(b) or 0), global) else - local c = settings.c - local m = settings.m - local y = settings.y - local k = settings.k + local c, m, y, k = settings.c, settings.m, settings.y, settings.k if c or m or y or k then definecolor(name, register_color(name,'cmyk',tonumber(c) or 0, tonumber(m) or 0, tonumber(y) or 0, tonumber(k) or 0), global) else - local h = settings.h - local s = settings.s - local v = settings.v + local h, s, v = settings.h, settings.s, settings.v if v then r, g, b = colors.hsvtorgb(tonumber(h) or 0, tonumber(s) or 1, tonumber(v) or 1) -- maybe later native definecolor(name, register_color(name,'rgb',r,g,b), global) @@ -479,8 +468,7 @@ local function defineprocesscolor(name,str,global,freeze) -- still inconsistent end end end - local a = settings.a - local t = settings.t + local a, t = settings.a, settings.t if a and t then definetransparent(name, transparencies.register(name,transparent[a] or tonumber(a) or 1,tonumber(t) or 1), global) elseif colors.couple then @@ -532,8 +520,7 @@ local function definespotcolor(name,parent,str,global) do_registerspotcolor(parent,cp,t.e,1,"",tp) -- p not really needed, only diagnostics if name and name ~= "" then definecolor(name,register_color(name,'spot',parent,1,"",tp),true) - local ta = t.a - local tt = t.t + local ta, tt = t.a, t.t if ta and tt then definetransparent(name, transparencies.register(name,transparent[ta] or tonumber(ta) or 1,tonumber(tt) or 1), global) elseif colors.couple then @@ -577,7 +564,7 @@ local function f(i,colors,fraction) return otf end -local function definemixcolor(makecolor,name,fractions,cs,global,freeze) +local function definemixcolor(makename,name,fractions,cs,global,freeze) local values = { } for i=1,#cs do -- do fraction in here local v = colorvalues[cs[i]] @@ -605,15 +592,12 @@ local function definemixcolor(makecolor,name,fractions,cs,global,freeze) end definecolor(name,ca,global,freeze) else - report_colors("invalid specification of components for color %a",makecolor) + report_colors("invalid specification of components for color %a",makename) end end local function definemultitonecolor(name,multispec,colorspec,selfspec) - local dd = { } - local pp = { } - local nn = { } - local max = 0 + local dd, pp, nn, max = { }, { }, { }, 0 for k,v in gmatch(multispec,"([^=,]+)=([^%,]*)") do -- use settings_to_array max = max + 1 dd[max] = k @@ -624,12 +608,12 @@ local function definemultitonecolor(name,multispec,colorspec,selfspec) nn = concat(nn,'_') local parent = gsub(lower(nn),"[^%d%a%.]+","_") if not colorspec or colorspec == "" then - -- this can happens when we come from metapost local cc = { } for i=1,max do +-- cc[i] = l_color[dd[i]] cc[i] = resolvedname(dd[i]) end - definemixcolor(name,parent,pp,cc,true,true) + definemixcolor(name,parent,pp,cc,global,freeze) -- can become local else if selfspec ~= "" then colorspec = colorspec .. "," .. selfspec @@ -661,29 +645,24 @@ colors.definemultitonecolor = definemultitonecolor -- that we cannot cast .. so we really need to use (s,s,s) for gray in order -- to be able to map onto 'color' -local function mpcolor(model,ca,ta,default,name) +local function mpcolor(model,ca,ta,default) local cv = colorvalues[ca] if cv then local tv = transparencyvalues[ta] - -- maybe move the 5 logic into the forcedmodel call - local cm = cv[1] if model == 1 then - model = cm + model = cv[1] end model = forcedmodel(model) - if cm == 5 and model == 4 then - model = 5 -- a cheat but ok as spot colors have a representation - end if tv then if model == 2 then return formatters["transparent(%s,%s,(%s,%s,%s))"](tv[1],tv[2],cv[3],cv[4],cv[5]) elseif model == 3 then return formatters["transparent(%s,%s,(%s,%s,%s))"](tv[1],tv[2],cv[3],cv[4],cv[5]) elseif model == 4 then - return formatters["transparent(%s,%s,(%s,%s,%s,%s))"](tv[1],tv[2],cv[6],cv[7],cv[8],cv[9]) + return formatters["transparent(%s,%s,cmyk(%s,%s,%s,%s))"](tv[1],tv[2],cv[6],cv[7],cv[8],cv[9]) elseif model == 5 then -- return formatters['transparent(%s,%s,multitonecolor("%s",%s,"%s","%s"))'](tv[1],tv[2],cv[10],cv[11],cv[12],cv[13]) - return formatters['transparent(%s,%s,namedcolor("%s"))'](tv[1],tv[2],name or cv[10]) + return formatters['transparent(%s,%s,namedcolor("%s"))'](tv[1],tv[2],cv[10]) else -- see ** in meta-ini.mkiv: return formatters["transparent(%s,%s,(%s))"](tv[1],tv[2],cv[2]) return formatters["transparent(%s,%s,(%s,%s,%s))"](tv[1],tv[2],cv[3],cv[4],cv[5]) end @@ -693,9 +672,10 @@ local function mpcolor(model,ca,ta,default,name) elseif model == 3 then return formatters["(%s,%s,%s)"](cv[3],cv[4],cv[5]) elseif model == 4 then - return formatters["(%s,%s,%s,%s)"](cv[6],cv[7],cv[8],cv[9]) + return formatters["cmyk(%s,%s,%s,%s)"](cv[6],cv[7],cv[8],cv[9]) elseif model == 5 then - return formatters['namedcolor("%s")'](name or cv[10]) + -- return formatters['multitonecolor("%s",%s,"%s","%s")'](cv[10],cv[11],cv[12],cv[13]) + return formatters['namedcolor("%s")'](cv[10]) else -- see ** in meta-ini.mkiv: return formatters["%s"]((cv[2])) return formatters["(%s,%s,%s)"](cv[3],cv[4],cv[5]) end @@ -718,8 +698,7 @@ local paletnamespace = getnamespace("colorpalet") local function namedcolorattributes(name) local space = texgetattribute(a_colormodel) - ----- prefix = texgettoks("t_colo_prefix") - local prefix = texgetmacro("currentcolorprefix") + local prefix = texgettoks("t_colo_prefix") local color if prefix ~= "" then color = valid[prefix..name] @@ -755,8 +734,7 @@ end colors.namedcolorattributes = namedcolorattributes -- can be used local local function mpnamedcolor(name) - local model, ca, ta = namedcolorattributes(name) - return mpcolor(model,ca,ta,nil,name) + return mpcolor(namedcolorattributes(name)) end local function mpoptions(model,ca,ta,default) -- will move to mlib-col .. not really needed @@ -1112,7 +1090,7 @@ implement { implement { name = "defineprocesscolordummy", actions = defineprocesscolor, - arguments = { "'c_o_l_o_r'", "string", false, false } + arguments = { "'d_u_m_m_y'", "string", false, false } } implement { |