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 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
On 10-8-2011 8:00, Peter Rolf wrote:
Usage:
btransp(normaltransparency,.5); <whatever> etransp;
Officially draw image ( whatever ) withtransparency (normaltransparency,.5) should work, but there is a (known) bug in mplib with respect to applying scripts to the components of a picture (color works ok).
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'?
In this respect the converter is kind of black box and there is not something like a stack or disable options. Maybe some day but I'd rather not touch the code now. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Am 14.08.2011 19:47, schrieb Hans Hagen:
On 10-8-2011 8:00, Peter Rolf wrote:
Usage:
btransp(normaltransparency,.5); <whatever> etransp;
Officially
draw image ( whatever ) withtransparency (normaltransparency,.5)
should work, but there is a (known) bug in mplib with respect to applying scripts to the components of a picture (color works ok).
The problem with the current transparency implementation is, that it doesn't use a transparency stack. If you use nested transparency, switching back to non transparent (/Tr0) is not what you always want. That's the only reason for this extra (ugly) plugin.
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'?
In this respect the converter is kind of black box and there is not something like a stack or disable options. Maybe some day but I'd rather not touch the code now.
OK. I think I found a solution in the meantime (but still to be tested). Thanks for taking the time. Peter
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 ___________________________________________________________________________________
participants (2)
-
Hans Hagen
-
Peter Rolf