Just for the records (or for the masses of mlib plugin programmers/lovers out there)... ;-) Am 10.08.2011 20:00, schrieb Peter Rolf:
Hi,
I use a mlib plugin to manually start/stop transparency. All graphics in between will be drawn with the defined state. Not very useful in general, but I need it for some graphics in Aero.
This is the simple code..
MP side:
def btransp(expr a, t) = draw origin withprescript "mtr_transp=start" withprescript "mtr_alternative=" & decimal a withprescript "mtr_transparency=" & decimal t ; enddef ;
def etransp = draw origin withprescript "mtr_transp=stop" ; enddef ;
TEX side:
local function mtr_process(object,prescript,before,after) local mtr_alternative = prescript.mtr_alternative if prescript.mtr_transp == "start" then if mtr_alternative then mtr_alternative = tonumber(mtr_alternative) local mtr_transparency = tonumber(prescript.mtr_transparency) before[#before+1] = format("q /Tr%s gs %% mtr",registertransparency(nil,mtr_alternative,mtr_transparency,true)) end elseif prescript.mtr_transp == "stop" then after[#after+1] = "Q % mtr" else -- fatal error end -- object.path = true -- 'true' gives runtime error, 'false' distorts content object.grouped = true object.type = false -- don't draw object.color = false end
local function mtr_process(object,prescript,before,after) local mtr_alternative = prescript.mtr_alternative if prescript.mtr_transp == "start" then if mtr_alternative then mtr_alternative = tonumber(mtr_alternative) local mtr_transparency = tonumber(prescript.mtr_transparency) before[#before+1] = format("q /Tr%s gs %% mtr",registertransparency(nil,mtr_alternative,mtr_transparency,true)) end elseif prescript.mtr_transp == "stop" then after[#after+1] = "Q % mtr" else -- fatal error end -- get rid of the 'draw <whatever> ...' trigger code object.type = "mtr-plugin" -- don't use an existing type object.path = false -- ignore path from 'draw <whatever>' trigger code object.grouped = false -- no additional 'miterlimit, linejoin, linecap' for grouping object.miterlimit, object.linejoin, object.linecap = -1,-1,-1 -- use default values, so a setting is unnecessary object.pen = false -- don't set pen line width object.color = false end
Usage:
btransp(normaltransparency,.5); <whatever> etransp;
This works so far (no visible artefacts), but part of the 'draw origin' is (although not drawn) still existent in the code.
[..] q /Tr1 gs % mtr 10.000000 M % unwanted setup for 'origin' 1 j 1 J 0.500000 w 0.000000 0.000000 m 0.000000 0.000000 l
<whatever>
10.000000 M % unwanted setup for 'origin' 1 j 1 J 0.500000 w 0.000000 0.000000 m 0.000000 0.000000 l Q % mtr [..]
I had a solution for the old 'specials', but I can't find one for the plugin handler. How can I get rid of the 'trigger code'?
Peter ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________