* drawarrow and transparency
@ 2012-05-02 15:35 Alan BRASLAU
2012-05-02 19:42 ` Marco
2012-05-05 9:19 ` Hans Hagen
0 siblings, 2 replies; 6+ messages in thread
From: Alan BRASLAU @ 2012-05-02 15:35 UTC (permalink / raw)
To: mailing list for ConTeXt users
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: drawarrow and transparency
2012-05-02 15:35 drawarrow and transparency Alan BRASLAU
@ 2012-05-02 19:42 ` Marco
2012-05-03 10:32 ` Alan BRASLAU
2012-05-05 9:19 ` Hans Hagen
1 sibling, 1 reply; 6+ messages in thread
From: Marco @ 2012-05-02 19:42 UTC (permalink / raw)
To: ntg-context
On 2012-05-02 Alan BRASLAU <alan.braslau@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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: drawarrow and transparency
2012-05-02 19:42 ` Marco
@ 2012-05-03 10:32 ` Alan BRASLAU
2012-05-03 12:47 ` Rogers, Michael K
2012-05-03 14:09 ` Peter Rolf
0 siblings, 2 replies; 6+ messages in thread
From: Alan BRASLAU @ 2012-05-03 10:32 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Wed, 2 May 2012 21:42:24 +0200
Marco <netuse@lavabit.com> wrote:
> On 2012-05-02 Alan BRASLAU <alan.braslau@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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: drawarrow and transparency
2012-05-03 10:32 ` Alan BRASLAU
@ 2012-05-03 12:47 ` Rogers, Michael K
2012-05-03 14:09 ` Peter Rolf
1 sibling, 0 replies; 6+ messages in thread
From: Rogers, Michael K @ 2012-05-03 12:47 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 1714 bytes --]
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).
[-- Attachment #1.2: Type: text/html, Size: 2671 bytes --]
[-- Attachment #2: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: drawarrow and transparency
2012-05-03 10:32 ` Alan BRASLAU
2012-05-03 12:47 ` Rogers, Michael K
@ 2012-05-03 14:09 ` Peter Rolf
1 sibling, 0 replies; 6+ messages in thread
From: Peter Rolf @ 2012-05-03 14:09 UTC (permalink / raw)
To: ntg-context
Hi Alan,
Am 03.05.2012 12:32, schrieb Alan BRASLAU:
> On Wed, 2 May 2012 21:42:24 +0200
> Marco <netuse@lavabit.com> wrote:
>
>> On 2012-05-02 Alan BRASLAU <alan.braslau@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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: drawarrow and transparency
2012-05-02 15:35 drawarrow and transparency Alan BRASLAU
2012-05-02 19:42 ` Marco
@ 2012-05-05 9:19 ` Hans Hagen
1 sibling, 0 replies; 6+ messages in thread
From: Hans Hagen @ 2012-05-05 9:19 UTC (permalink / raw)
To: mailing list for ConTeXt users
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-05-05 9:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-02 15:35 drawarrow and transparency Alan BRASLAU
2012-05-02 19:42 ` Marco
2012-05-03 10:32 ` Alan BRASLAU
2012-05-03 12:47 ` Rogers, Michael K
2012-05-03 14:09 ` Peter Rolf
2012-05-05 9:19 ` Hans Hagen
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).