ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Marco <netuse@lavabit.com>
To: ntg-context@ntg.nl
Subject: metapost: shading and transparency
Date: Thu, 17 Jun 2010 19:01:58 +0200	[thread overview]
Message-ID: <20100617190158.2ff64522@vorbis> (raw)

Hi,

while using shading in metapost I cannot get transparency work.
The transparency is simply ignored and the result is the same colour as with
no transparency specified.

Here's an example that demonstrates the problem:

\definecolor [a]  [darkyellow]
\definecolor [b]  [r=1,  g=1,  b=1, a=1, t=0]
\definecolor [c]  [r=1,  g=1,  b=1, a=1, t=.5]
\definecolor [bg] [r=.8, g=.8, b=1]

% Define test background to see transparency (not) working
\defineoverlay[bg][\uniqueMPgraphic{bg}]
\startuniqueMPgraphic {bg}
  fill unitsquare
    xyscaled (\overlaywidth, \overlayheight) withcolor \MPcolor{bg};
    picture pic; pic := nullpicture;
    addto pic contour fullcircle scaled .5mm withcolor .2white;
    for i=1 upto 52:
      for j=1 upto 73:
	addto currentpicture also pic shifted (4mm*i, 4mm*j);
      endfor;
    endfor;
\stopuniqueMPgraphic
\setupbackgrounds [page] [background=bg]

\starttext
\startMPcode
  path p[];
  p1 := unitsquare xyscaled (4cm, 2cm);
  p2 := p1 yshifted -2.5cm;
  p3 := p2 yshifted -2.5cm;

  % Transparency does not work, background is white instead of full alpha
  linear_shade(p1,0,\MPcolor{a},\MPcolor{b});

  % Setting 2nd colour to background colour works only with plain coloured
  % backgrounds not with patterns
  linear_shade(p2,0,\MPcolor{a},\MPcolor{bg});

  % Transparency with simple »fill« works as expected
  fill p3 withcolor \MPcolor{c};
\stopMPcode
\stoptext

Thanks for any hints
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
___________________________________________________________________________________

             reply	other threads:[~2010-06-17 17:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-17 17:01 Marco [this message]
2010-06-18  7:19 ` Taco Hoekwater
2010-06-18  7:39   ` Mojca Miklavec
2010-06-18  8:43     ` Hans Hagen
2010-06-18  9:13     ` Mojca Miklavec
2010-06-18  9:38       ` Hans Hagen
2010-06-18 11:48         ` Marco
2010-06-18 19:56           ` Hans Hagen
2010-06-19  4:30             ` Marco
2010-06-18 11:47       ` Marco

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=20100617190158.2ff64522@vorbis \
    --to=netuse@lavabit.com \
    --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).