summaryrefslogtreecommitdiff
path: root/tex/context/base/colo-ini.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2010-04-07 17:58:00 +0200
committerHans Hagen <pragma@wxs.nl>2010-04-07 17:58:00 +0200
commitc63da592cc7ecde38ec1749525c072e79adebdcf (patch)
tree1c1f26222d9c7867d56ef32ecc5c993aec980354 /tex/context/base/colo-ini.lua
parent6de1d37f23278896de0a7f022c700ba5ff714904 (diff)
downloadcontext-c63da592cc7ecde38ec1749525c072e79adebdcf.tar.gz
beta 2010.04.07 17:58
Diffstat (limited to 'tex/context/base/colo-ini.lua')
-rw-r--r--tex/context/base/colo-ini.lua21
1 files changed, 12 insertions, 9 deletions
diff --git a/tex/context/base/colo-ini.lua b/tex/context/base/colo-ini.lua
index ac68df495..4546f5279 100644
--- a/tex/context/base/colo-ini.lua
+++ b/tex/context/base/colo-ini.lua
@@ -415,18 +415,21 @@ end
-- experiment (a bit of a hack, as we need to get the attribute number)
-local min, abs = math.min, math.abs
+local min = math.min
+
+-- a[b,c] -> b+a*(c-b)
local function f(one,two,i,fraction)
- local a, b = one[i], two[i]
- if a > b then
- return min(fraction*(a+b),1)
- else
- return min(1-fraction*(a+b),1)
+ local o, t = one[i], two[i]
+ local otf = o + fraction * (t - o)
+ if otf > 1 then
+ otf = 1
end
+ return otf
end
function colors.defineintermediatecolor(name,fraction,c_one,c_two,a_one,a_two,specs,global,freeze)
+ fraction = tonumber(fraction) or 1
local one, two = colors.value(c_one), colors.value(c_two)
if one and two then
local csone, cstwo = one[1], two[1]
@@ -448,10 +451,10 @@ function colors.defineintermediatecolor(name,fraction,c_one,c_two,a_one,a_two,sp
end
local one, two = transparencies.value(a_one), transparencies.value(a_two)
local t = settings_to_hash_strict(specs)
- local ta = (t and t.a) or (one and one[1]) or (two and two[1])
- local tt = (t and t.t) or (one and two and f(one,two,2,fraction))
---~ print(t,table.serialize(t),ta,tt)
+ local ta = tonumber((t and t.a) or (one and one[1]) or (two and two[1]))
+ local tt = tonumber((t and t.t) or (one and two and f(one,two,2,fraction)))
if ta and tt then
+--~ print(ta,tt)
definetransparent(name,transparencies.register(name,ta,tt),global)
end
end