summaryrefslogtreecommitdiff
path: root/tex/context/base/grph-inc.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/grph-inc.lua')
-rw-r--r--tex/context/base/grph-inc.lua48
1 files changed, 26 insertions, 22 deletions
diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua
index 9603419ae..be1b7f45a 100644
--- a/tex/context/base/grph-inc.lua
+++ b/tex/context/base/grph-inc.lua
@@ -55,6 +55,10 @@ local allocate = utilities.storage.allocate
local setmetatableindex = table.setmetatableindex
local replacetemplate = utilities.templates.replace
+local images = img
+
+local context = context
+
local variables = interfaces.variables
local codeinjections = backends.codeinjections
local nodeinjections = backends.nodeinjections
@@ -67,8 +71,6 @@ local trace_inclusion = false trackers.register("graphics.inclusion", functi
local report_inclusion = logs.reporter("graphics","inclusion")
-local context, img = context, img
-
local f_hash_part = formatters["%s->%s->%s"]
local f_hash_full = formatters["%s->%s->%s->%s->%s->%s->%s"]
@@ -82,7 +84,7 @@ local v_default = variables.default
local maxdimen = 2^30-1
-function img.check(figure)
+function images.check(figure)
if figure then
local width = figure.width
local height = figure.height
@@ -103,36 +105,38 @@ end
--- some extra img functions --- can become luat-img.lua
-local imgkeys = img.keys()
+local allimagekeys = images.keys()
-function img.totable(imgtable)
+local function imagetotable(imgtable)
local result = { }
- for k=1,#imgkeys do
- local key = imgkeys[k]
+ for k=1,#allimagekeys do
+ local key = allimagekeys[k]
result[key] = imgtable[key]
end
return result
end
-function img.serialize(i,...)
- return table.serialize(img.totable(i),...)
+images.totable = imagetotable
+
+function images.serialize(i,...)
+ return table.serialize(imagetotable(i),...)
end
-function img.print(i,...)
- return table.print(img.totable(i),...)
+function images.print(i,...)
+ return table.print(imagetotable(i),...)
end
-function img.clone(i,data)
+function images.clone(i,data)
i.width = data.width or i.width
i.height = data.height or i.height
-- attr etc
return i
end
-local validsizes = table.tohash(img.boxes())
-local validtypes = table.tohash(img.types())
+local validsizes = table.tohash(images.boxes())
+local validtypes = table.tohash(images.types())
-function img.checksize(size)
+function images.checksize(size)
if size then
size = gsub(size,"box","")
return validsizes[size] and size or "crop"
@@ -143,7 +147,7 @@ end
local indexed = { }
-function img.ofindex(n)
+function images.ofindex(n)
return indexed[n]
end
@@ -430,7 +434,7 @@ function figures.initialize(request)
request.height = h > 0 and h or nil
--
request.page = math.max(tonumber(request.page) or 1,1)
- request.size = img.checksize(request.size)
+ request.size = images.checksize(request.size)
request.object = request.object == v_yes
request["repeat"] = request["repeat"] == v_yes
request.preview = request.preview == v_yes
@@ -1033,7 +1037,7 @@ function checkers.generic(data)
local hash = f_hash_full(name,page,size,color,conversion,resolution,mask)
local figure = figures_loaded[hash]
if figure == nil then
- figure = img.new {
+ figure = images.new {
filename = name,
page = page,
pagebox = dr.size,
@@ -1041,7 +1045,7 @@ function checkers.generic(data)
}
codeinjections.setfigurecolorspace(data,figure)
codeinjections.setfiguremask(data,figure)
- figure = figure and img.check(img.scan(figure)) or false
+ figure = figure and images.check(images.scan(figure)) or false
local f, d = codeinjections.setfigurealternative(data,figure)
figure, data = f or figure, d or data
figures_loaded[hash] = figure
@@ -1084,15 +1088,15 @@ function includers.generic(data)
if figure == nil then
figure = ds.private
if figure then
- figure = img.copy(figure)
- figure = figure and img.clone(figure,data.request) or false
+ figure = images.copy(figure)
+ figure = figure and images.clone(figure,data.request) or false
end
figures_used[hash] = figure
end
if figure then
local nr = figures.boxnumber
-- it looks like we have a leak in attributes here .. todo
- local box = node.hpack(img.node(figure)) -- img.node(figure) not longer valid
+ local box = node.hpack(images.node(figure)) -- images.node(figure) not longer valid
indexed[figure.index] = figure
box.width, box.height, box.depth = figure.width, figure.height, 0 -- new, hm, tricky, we need to do that in tex (yet)
texbox[nr] = box