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] Bug with linenumbering

2012-05-03 Thread Wolfgang Schuster

Am 03.05.2012 um 06:58 schrieb Aditya Mahajan:

 On Wed, 2 May 2012, Hans Hagen wrote:
 
 On 1-5-2012 21:43, Aditya Mahajan wrote:
 Hi,
 Line numbering does not respect the parameters given with
 \startlinenumbering. For example:
 
 Line numbering is a delayed operation. As they are handled when the page is 
 constructed the settings of that moment apply. In practice only the start 
 key is handled when you pass settings to \start (the only reason for  
 having the second argument is number start/restart etc). If you want 
 different renderings, the best is to define a specific instance of line 
 numbering.
 
 A little background: In the initial version of the vim module, I used to do 
 line numbering manually (each line started with \NL macro, which expanded to 
 a number in an appropriate style depending on whether line numbering was 
 enabled or not. When I rewrote the module to use the filter module, I also 
 rewrote the line numbering mechanism to use ConTeXt's inbuilt line numbering 
 macros, but I cannot get them to work.
 
 Consider the following example. I want to define an environment, which, 
 amongst other things does line numbering. I want the user to control the 
 style and color of line numbering, so I define keys numberstyle and 
 numbercolor, which are then passed on to the line numbering macros. The most 
 obvious implementation of this does not work.
 
 […]
 
 \appendtoks
   \definelinenumbering
 [\currentwhatever]
 [
   color=\whateverparameter{numbercolor},
   style=\whateverparameter{numberstyle},
 ]%
   \setvalue{start\currentwhatever}{\dostartwhatever[\currentwhatever]}%
   \setvalue{stop\currentwhatever}{\dostopwhatever}%
 \to\everydefinewhatever

You assume \definelinenumbering has a second argument for the settings but this 
isn’t the case and you need \setuplinenumbering to set them.

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


Re: [NTG-context] Bug with linenumbering

2012-05-03 Thread Aditya Mahajan

On Thu, 3 May 2012, Wolfgang Schuster wrote:


You assume \definelinenumbering has a second argument for the settings but this 
isn’t the case


D'oh.


and you need \setuplinenumbering to set them.


I also needed to change \setvalue to \setevalue in the example, and add an 
\expanded to get it to work.


\definenamespace
 [whatever]
 [
   type=module,
   name=whatever,
   command=yes,
   setup=yes,
   parent=whatever,
 ]

\appendtoks
 \definelinenumbering
   [\currentwhatever]%
 \expanded{\setuplinenumbering
   [\currentwhatever]
   [
 color=\whateverparameter{numbercolor},
 style=\whateverparameter{numberstyle},
   ]}%

\setevalue{start\currentwhatever}{\dostartwhatever[\currentwhatever]}%
 \setevalue{stop\currentwhatever}{\dostopwhatever}%
\to\everydefinewhatever

% For illustration. The actual macro is more complicated.
\def\dostartwhatever[#1]%
 {\startlinenumbering[#1]}

\def\dostopwhatever
 {\stoplinenumbering}



\definewhatever[testing][numbercolor=red,numberstyle=bold]

\starttext
\starttesting
   \input knuth
\stoptesting
\stoptext

Thanks,
Aditya___
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] Indentation for beginner

2012-05-03 Thread hwitloc

Marco,
  thank you for kindly showing me how to do the resume section : itemize format 
that I needed in a very clear way.  The example you provided works very well.  

I appreciate your help.

Regards,
  hwitloc



  
Marco net...@lavabit.com wrote:
 On 2012-05-02 hwit...@gmail.com wrote:
 
  %Whereas I want it to be like this:
  
  
EDUCATION* bozo the clown
 * is here today
  
WORK * UCLA BoA
EXPERIENCE   * LMU BSCS
  
  In other words I want the first item of an itemization to line up with the
  resume section description header's first or last line.
 
 \defineparagraphs [rpara] [n=2]
 \setupparagraphs  [rpara] [1] [width=3cm, style=\sc]
 \setupitemize [5, packed]
 
 \starttext
 
 \startrpara
   Education
 \nextrpara
   \startitemize
   \startitem bozo the clown \stopitem
   \startitem is here today  \stopitem
   \stopitemize
 \stoprpara
 
 \startrpara
   Work\crlf Experience % or use \startlines … \stoplines
 \nextrpara
   \startitemize
   \startitem UCLA BoA \stopitem
   \startitem LMU BSCS \stopitem
   \stopitemize
 \stoprpara
 
 \stoptext
 
 
 ___
 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
 ___
___
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] \inputif(file)exist(s)

2012-05-03 Thread Procházka Lukáš Ing . - Pontex s . r . o .

Hello,

just a quick question - is there a command like \inputif(file)exist(s), which 
will \input a file if it exists, i.e. with no error if it doesn't?

TIA.

Lukas


--
Ing. Lukáš Procházka [mailto:l...@pontex.cz]
Pontex s. r. o.  [mailto:pon...@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

___
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] \inputif(file)exist(s)

2012-05-03 Thread Aditya Mahajan

On Thu, 3 May 2012, Procházka Lukáš Ing. - Pontex s. r. o. wrote:


Hello,

just a quick question - is there a command like \inputif(file)exist(s), 
which will \input a file if it exists, i.e. with no error if it doesn't?


\readfile.

From file-res.mkvi

%D \macros
%D   {readfile,ReadFile}
%D
%D One cannot be sure if a file exists. When no file can be
%D found, the \type{\input} primitive gives an error message
%D and switches to interactive mode. The macro \type{\readfile}
%D takes care of non||existing files. This macro has two faces.
%D
%D \starttyping
%D \ReadFile {filename}
%D \readfile {filename} {before loading} {not found}
%D \stoptyping
%D
%D Many \TEX\ implementations have laid out some strategy for
%D locating files. This can lead to unexpected results,
%D especially when one loads files that are not found in the
%D current directory. Let's give an example of this. In
%D \CONTEXT\ illustrations can be defined in an external file.
%D The resizing macro first looks if an illustration is defined
%D in the local definitions file. When no such file is found,
%D it searches for a global file and when this file is not
%D found either, the illustration itself is scanned for
%D dimensions. One can imagine what happens if an adapted,
%D localy stored illustration, is scaled according to
%D dimensions stored somewhere else.
%D
%D When some \TEX\ implementation starts looking for a file, it
%D normally first looks in the current directory. When no file
%D is found, \TEX\ starts searching on the path where format
%D and|/|or style files are stored. Depending on the implementation
%D this can considerably slow down processing speed.
%D
%D In \CONTEXT, we support a project||wise ordening of files.
%D In such an approach it seems feasible to store common files
%D in a lower directory. When for instance searching for a
%D general layout file, we therefore have to backtrack.
%D
%D These three considerations have lead to a more advanced
%D approach for loading files.
%D
%D We first present an earlier implementation of
%D \type{\readfile}. This command backtracks parent
%D directories, upto a predefined level. Users can change this
%D level (on the commandline using a directive); we default to~3.
%D
%D We use \type{\normalinput} instead of \type{\input}
%D because we want to be able to redefine the original
%D \type{\input} when needed, for instance when loading third
%D party libraries.


Aditya___
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] \inputif(file)exist(s)

2012-05-03 Thread Wolfgang Schuster

Am 03.05.2012 um 17:37 schrieb Procházka Lukáš Ing. - Pontex s. r. o.:

 Hello,
 
 just a quick question - is there a command like \inputif(file)exist(s), 
 which will \input a file if it exists, i.e. with no error if it doesn't?

\ReadFile{…}

Wolfgang
___
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] Bug with linenumbering

2012-05-03 Thread Wolfgang Schuster

Am 03.05.2012 um 17:18 schrieb Aditya Mahajan:

 On Thu, 3 May 2012, Wolfgang Schuster wrote:
 
 You assume \definelinenumbering has a second argument for the settings but 
 this isn’t the case
 
 D'oh.
 
 and you need \setuplinenumbering to set them.
 
 I also needed to change \setvalue to \setevalue in the example, and add an 
 \expanded to get it to work.

In MkIV \setuevalue is better the \setevalue and \normalunexpanded is faster 
than \expanded.

The problem in your approach is that you can only set the style and color value 
with \definewhatever
where I think it’s better to use \setupwhatever.

\unprotect

\installnamespace{whatever}
\installcommandhandler \whatever {whatever} \whatever

\appendtoks
  \definelinenumbering[\currentwhatever]%
\to \everydefinewhatever

\appendtoks
  \setuevalue{\e!start\currentwhatever}{\whatever_start[\currentwhatever]}%
  \setuevalue{\e!stop\currentwhatever }{\whatever_stop   }%
\to \everydefinewhatever

\appendtoks
  \normalexpanded{\setuplinenumbering
[\currentwhatever]
[\c!color=\whateverparameter\c!numbercolor,
 \c!style=\whateverparameter\c!numberstyle]}%
\to \everysetupwhatever

\unexpanded\def\whatever_start[#1]%
  {\begingroup
   \edef\currentwhatever{#1}%
   \startlinenumbering[\currentwhatever]}

\unexpanded\def\whatever_stop
  {\stoplinenumbering
   \endgroup}

\protect

\definewhatever[testing][numbercolor=red,numberstyle=bold]
\setupwhatever [testing][numbercolor=blue]

\starttext
\starttesting
\input knuth
\stoptesting
\stoptext

Wolfgang
___
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] \systemparameter{n}

2012-05-03 Thread Peter Rolf
Hi,

the system parameter 'n' is not properly set on the third run.

% test.tex
\starttext

\ifnum\systemparameter{n}=1\relax
  \ctxlua{print(*** 1st run)}\fi
\ifnum\systemparameter{n}=2\relax
  \ctxlua{print(*** 2nd run)}\fi
\ifnum\systemparameter{n}=3\relax
  \ctxlua{print(*** 3rd run)}\fi

\stoptext
% 

A fresh run (three runs) gives

*** 1st run
*** 2nd run
*** 2nd run


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
___


Re: [NTG-context] Bug with linenumbering

2012-05-03 Thread Aditya Mahajan

On Thu, 3 May 2012, Wolfgang Schuster wrote:



Am 03.05.2012 um 17:18 schrieb Aditya Mahajan:


On Thu, 3 May 2012, Wolfgang Schuster wrote:


You assume \definelinenumbering has a second argument for the settings but this 
isn’t the case


D'oh.


and you need \setuplinenumbering to set them.


I also needed to change \setvalue to \setevalue in the example, and add an 
\expanded to get it to work.


In MkIV \setuevalue is better the \setevalue and \normalunexpanded is faster 
than \expanded.

The problem in your approach is that you can only set the style and color value 
with \definewhatever
where I think it’s better to use \setupwhatever.


Thanks for both the tips!

Aditya___
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] \inputif(file)exist(s)

2012-05-03 Thread Procházka Lukáš Ing . - Pontex s . r . o .

... Great, thank you.

Lukas


On Thu, 03 May 2012 17:41:18 +0200, Aditya Mahajan adit...@umich.edu wrote:


On Thu, 3 May 2012, Procházka Lukáš Ing. - Pontex s. r. o. wrote:


Hello,

just a quick question - is there a command like \inputif(file)exist(s),
which will \input a file if it exists, i.e. with no error if it doesn't?


\readfile.

From file-res.mkvi

%D \macros
%D   {readfile,ReadFile}
%D
%D One cannot be sure if a file exists. When no file can be
%D found, the \type{\input} primitive gives an error message
%D and switches to interactive mode. The macro \type{\readfile}
%D takes care of non||existing files. This macro has two faces.
%D
%D \starttyping
%D \ReadFile {filename}
%D \readfile {filename} {before loading} {not found}
%D \stoptyping
%D
%D Many \TEX\ implementations have laid out some strategy for
%D locating files. This can lead to unexpected results,
%D especially when one loads files that are not found in the
%D current directory. Let's give an example of this. In
%D \CONTEXT\ illustrations can be defined in an external file.
%D The resizing macro first looks if an illustration is defined
%D in the local definitions file. When no such file is found,
%D it searches for a global file and when this file is not
%D found either, the illustration itself is scanned for
%D dimensions. One can imagine what happens if an adapted,
%D localy stored illustration, is scaled according to
%D dimensions stored somewhere else.
%D
%D When some \TEX\ implementation starts looking for a file, it
%D normally first looks in the current directory. When no file
%D is found, \TEX\ starts searching on the path where format
%D and|/|or style files are stored. Depending on the implementation
%D this can considerably slow down processing speed.
%D
%D In \CONTEXT, we support a project||wise ordening of files.
%D In such an approach it seems feasible to store common files
%D in a lower directory. When for instance searching for a
%D general layout file, we therefore have to backtrack.
%D
%D These three considerations have lead to a more advanced
%D approach for loading files.
%D
%D We first present an earlier implementation of
%D \type{\readfile}. This command backtracks parent
%D directories, upto a predefined level. Users can change this
%D level (on the commandline using a directive); we default to~3.
%D
%D We use \type{\normalinput} instead of \type{\input}
%D because we want to be able to redefine the original
%D \type{\input} when needed, for instance when loading third
%D party libraries.


Aditya



--
Ing. Lukáš Procházka [mailto:l...@pontex.cz]
Pontex s. r. o.  [mailto:pon...@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

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