ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Peter Rolf <indiego@gmx.net>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: mlib plugin question
Date: Wed, 10 Aug 2011 20:00:43 +0200	[thread overview]
Message-ID: <4E42C74B.7060208@gmx.net> (raw)

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
___________________________________________________________________________________
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
___________________________________________________________________________________


             reply	other threads:[~2011-08-10 18:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-10 18:00 Peter Rolf [this message]
2011-08-14 17:47 ` Hans Hagen
2011-08-15  9:37   ` Peter Rolf
2011-08-15 13:26 ` Peter Rolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E42C74B.7060208@gmx.net \
    --to=indiego@gmx.net \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).