Re: [NTG-context] drawarrow and transparency

2012-05-05 Thread Hans Hagen

On 2-5-2012 17:35, Alan BRASLAU wrote:

I have a MetaPost question concerning drawarrow withtransparency
(or any other compound object).

Is there some clever way to achieve uniform transparency
for a compound object? For example, in the minimal example
below, how can one obtain a transparent arrow without getting
an X-ray vision of the arrowhead?

\starttext
\startMPpage
drawarrow origin--(1cm,0) withtransparency(1,.5) ;
drawarrow origin--(0,1cm) withtransparency(1,.5) ;
\stopMPpage
\stoptext


This is a side effect of an arrow being a composed graphic. I 
experimented a bit with transparency grouping and after several variants 
I settled to the following approach:


\starttext

\startMPpage[offset=1mm]

drawarrow (1cm,0cm) -- (0cm,0cm) withcolor red 
withtransparency(1,.5)  ;


draw image (
drawarrow (1cm,0cm) -- (0cm,0cm) withcolor red 
withtransparency(1,.5)  ;

) shifted (0,2mm) asgroup  ;

draw image (
drawarrow (1cm,0cm) -- (0cm,0cm) withcolor red 
withtransparency(1,.5)  ;

) shifted (0,4mm) asgroup isolated ;

draw image (
drawarrow (1cm,0cm) -- (0cm,0cm) withcolor red 
withtransparency(1,.5)  ;

) shifted (0,6mm) asgroup knockout ;

draw image (
drawarrow (1cm,0cm) -- (0cm,0cm) withcolor red 
withtransparency(1,.5)  ;

) shifted (0,8mm) asgroup isolated,knockout ;

addbackground withcolor green ;

\stopMPpage

\stoptext

As we have to use xforms (a pitty that this is needed) there is the 
usual interference and something fishy with clipping is going on.


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


Re: [NTG-context] drawarrow and transparency

2012-05-03 Thread Alan BRASLAU
On Wed, 2 May 2012 21:42:24 +0200
Marco net...@lavabit.com wrote:

 On 2012-05-02 Alan BRASLAU alan.bras...@cea.fr wrote:
 
  For  example, in  the minimal  example below,  how can  one obtain
  a  transparent  arrow  without  getting an  X-ray  vision  of  the
  arrowhead?
 
 Maybe I'm  reinventing the  wheel here,  but you  can write  a small
 macro that only draws the lines you want. Here is an idea:
 
 \starttext
 \startMPpage
 
   linecap  := squared;
   penscale := .5bp;
   pickup pencircle scaled penscale;
 
   def drawmyarrow expr p = _apth:=p; _myfinarr enddef;
   def _myfinarr text t =
   draw _apth cutafter point (-ahlength+.1penscale) on
 _apth t; fill arrowhead _apth  t
   enddef;
 
   drawarrow   origin-- (1cm,0) withtransparency(1,.5) ;
   drawarrow   origin-- (0,1cm) withtransparency(1,.5) ;
   drawmyarrow (1.5cm,0) -- (2.5cm,0)   withtransparency(1,.5) ;
   drawmyarrow (1.5cm,0) -- (1.5cm,1cm) withtransparency(1,.5) ;
 
 \stopMPpage
 \stoptext
 
 The (-ahlength+.1penscale)  are of  course empiric. You  should find
 the correct  formula to always have  a nice match of  line and arrow
 whatever ahlength and ahangle values are in use.
 
 Marco

Yes, this is somewhat reinventing the wheel.

I believe that this is somewhat a bug with transparency under MetaFun.
For I tried the following:

\startMPcode
picture pic ; pic := image(drawarrow origin--(1cm,0)) ;

draw pic withtransparency(1,.5) ;
draw pic rotated 90 withtransparency(1,.5) ;
\stopMPcode

Here, the arrowhead is totally opaque and only the stem
has transparency. Something is fishy.

Alan
___
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
___


Re: [NTG-context] drawarrow and transparency

2012-05-03 Thread Rogers, Michael K
On May 3, 2012, at 6:32 AM, Alan BRASLAU wrote:

I believe that this is somewhat a bug with transparency under MetaFun.
For I tried the following:

\startMPcode
picture pic ; pic := image(drawarrow origin--(1cm,0)) ;

draw pic withtransparency(1,.5) ;
draw pic rotated 90 withtransparency(1,.5) ;
\stopMPcode

Here, the arrowhead is totally opaque and only the stem
has transparency. Something is fishy.

Alan

I noticed the same thing.  I think original problem is with how an arrow is 
converted to PDF/Postscript drawing commands and how the color is computed when 
commands are combined.  The only solution I can imagine is to define a new 
arrow macro that constructs the boundary path of the arrow and fills it (i.e., 
up one side of the stem, around the arrowhead, and down the other side of the 
stem).  As far as I can tell, MetaPost/Postscript does not have commands that 
compute the boundary path of the region painted by a sequence of commands.  (I 
think that computing the boundary might be a much harder problem in general 
than computing which points to paint.  A straight arrow would be fairly simple.)

Michael



This e-mail message (including any attachments) is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, distribution
or copying of this message (including any attachments) is strictly
prohibited.

If you have received this message in error, please contact
the sender by reply e-mail message and destroy all copies of the
original message (including attachments).
___
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
___

Re: [NTG-context] drawarrow and transparency

2012-05-03 Thread Peter Rolf
Hi Alan,

Am 03.05.2012 12:32, schrieb Alan BRASLAU:
 On Wed, 2 May 2012 21:42:24 +0200
 Marco net...@lavabit.com wrote:
 
 On 2012-05-02 Alan BRASLAU alan.bras...@cea.fr wrote:

 For  example, in  the minimal  example below,  how can  one obtain
 a  transparent  arrow  without  getting an  X-ray  vision  of  the
 arrowhead?

 Maybe I'm  reinventing the  wheel here,  but you  can write  a small
 macro that only draws the lines you want. Here is an idea:

 \starttext
 \startMPpage

  linecap  := squared;
  penscale := .5bp;
  pickup pencircle scaled penscale;

  def drawmyarrow expr p = _apth:=p; _myfinarr enddef;
  def _myfinarr text t =
  draw _apth cutafter point (-ahlength+.1penscale) on
 _apth t; fill arrowhead _apth  t
  enddef;

  drawarrow   origin-- (1cm,0) withtransparency(1,.5) ;
  drawarrow   origin-- (0,1cm) withtransparency(1,.5) ;
  drawmyarrow (1.5cm,0) -- (2.5cm,0)   withtransparency(1,.5) ;
  drawmyarrow (1.5cm,0) -- (1.5cm,1cm) withtransparency(1,.5) ;

 \stopMPpage
 \stoptext

 The (-ahlength+.1penscale)  are of  course empiric. You  should find
 the correct  formula to always have  a nice match of  line and arrow
 whatever ahlength and ahangle values are in use.

 Marco
 
 Yes, this is somewhat reinventing the wheel.
 
 I believe that this is somewhat a bug with transparency under MetaFun.
 For I tried the following:
 
 \startMPcode
   picture pic ; pic := image(drawarrow origin--(1cm,0)) ;


isn't 'image()' a fixed graphic? the only difference from normal drawing
is, that the stuff is not added to 'currentpicture'. think of it more
like a stamp, that is used to create identical copies.

anyhow, it's probably better and cleaner to use a macro here...

   draw pic withtransparency(1,.5) ;
   draw pic rotated 90 withtransparency(1,.5) ;
 \stopMPcode
 
 Here, the arrowhead is totally opaque and only the stem
 has transparency. Something is fishy.
 
 Alan

what you want (if i understand you right) is a non-isolated 'knockout
group'. see 'PLATE 17'**, page 1147, in the pdf reference 1.7 for an
example.

currently no grouping (objects are in the same transparency group) is
supported in metafun.
the only possible way to create such a graphic is to use the tikz module
(search for 'transparency group' in the tikz manual).


hope that helps,

Peter


** the complete graphic is a fake, because all of its parts are opaque,
pixel based graphics; not a single vector graphic, no transparency at
all! what a joke :-D
maybe adobe doesn't trust other (or their own) pdf viewers to show the
right result!?
___
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
___


[NTG-context] drawarrow and transparency

2012-05-02 Thread Alan BRASLAU
I have a MetaPost question concerning drawarrow withtransparency
(or any other compound object).

Is there some clever way to achieve uniform transparency
for a compound object? For example, in the minimal example
below, how can one obtain a transparent arrow without getting
an X-ray vision of the arrowhead?

\starttext
\startMPpage
drawarrow origin--(1cm,0) withtransparency(1,.5) ;
drawarrow origin--(0,1cm) withtransparency(1,.5) ;
\stopMPpage
\stoptext

Alan
___
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
___


Re: [NTG-context] drawarrow and transparency

2012-05-02 Thread Marco
On 2012-05-02 Alan BRASLAU alan.bras...@cea.fr wrote:

 For  example, in  the minimal  example below,  how can  one obtain
 a  transparent  arrow  without  getting an  X-ray  vision  of  the
 arrowhead?

Maybe I'm  reinventing the  wheel here,  but you  can write  a small
macro that only draws the lines you want. Here is an idea:

\starttext
\startMPpage

linecap  := squared;
penscale := .5bp;
pickup pencircle scaled penscale;

def drawmyarrow expr p = _apth:=p; _myfinarr enddef;
def _myfinarr text t =
draw _apth cutafter point (-ahlength+.1penscale) on _apth t;
fill arrowhead _apth  t
enddef;

drawarrow   origin-- (1cm,0) withtransparency(1,.5) ;
drawarrow   origin-- (0,1cm) withtransparency(1,.5) ;
drawmyarrow (1.5cm,0) -- (2.5cm,0)   withtransparency(1,.5) ;
drawmyarrow (1.5cm,0) -- (1.5cm,1cm) withtransparency(1,.5) ;

\stopMPpage
\stoptext

The (-ahlength+.1penscale)  are of  course empiric. You  should find
the correct  formula to always have  a nice match of  line and arrow
whatever ahlength and ahangle values are in use.

Marco


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