[NTG-context] MetaPost circular_shade Command

2012-05-02 Thread Troy Henderson
The command

circular_shade(fullcircle scaled 4in,0,white,red);

in MetaPost does not act as I think it should.  It performs a gradient fill
starting at the center of the circle by filling this center in white (which
is expected), and changing the color as the radius/diameter changes (which
is also expected), but the final radius appears to have a RGB color of
about (1,0.29,0.29) which is not red (thus is unexpected) since red =
(1,0,0).  However, the command

circular_shade(unitsquare shifted (-0.5,-0.5) scaled 4in,0,white,red);

creates a gradient filled square whose center is white and whose northeast,
northwest, southwest, and southeast corner are red (as somewhat expected)
and thus whose east, north, west, and south tip are about (1,0.29,0.29)
like the circle.

I would appreciate an explanation of why this acts like it does, and (more
importantly), let me know how I can get a gradient filled circle whose
center gets filled with a RGB color c and outer radius color d.  Clearly,

circular_shade(fullcircle scaled 4in,0,c,d);

does not do this.

Thanks in advance,

Troy Henderson
___
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] Font for MetaPost graphics

2012-05-02 Thread Marco
The wiki claims setting up an MPenvironment is enough to change the
font in MetaPost graphics:

\startMPenvironment%[global]
\switchtobodyfont [sans]
\stopMPenvironment

\starttext
This should be serif.

\startMPcode
draw textext(This should be in sans.);
\stopMPcode
\stoptext

However, this has no effect. All text is in default serif font. If
[global] is provided, all text is in sans font. I am aware of a
similar issue in a thread last year¹, but the solution didn't really
address the problem. textext(\sans This should be sans.) works
here, but the point is that the MPenvironment fails. Why is that?

Marco

[1] http://thread.gmane.org/gmane.comp.tex.context/69044


___
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] Font for MetaPost graphics

2012-05-02 Thread Aditya Mahajan

On Thu, 3 May 2012, Marco wrote:


The wiki claims setting up an MPenvironment is enough to change the
font in MetaPost graphics:

\startMPenvironment%[global]
\switchtobodyfont [sans]
\stopMPenvironment

\starttext
This should be serif.

\startMPcode
draw textext(This should be in sans.);
\stopMPcode
\stoptext

However, this has no effect. All text is in default serif font. If
[global] is provided, all text is in sans font. I am aware of a
similar issue in a thread last year¹, but the solution didn't really
address the problem. textext(\sans This should be sans.) works
here, but the point is that the MPenvironment fails. Why is that?


Metapost now runs as a library. All the text is first typeset by ConTeXt 
and metapost only knows the bounding box of the labels.


You can try (untested):

\starttext

This is serif

\switchtobodyfont[sans]
\startMPcode
draw textext(This should be sans);
\stopMPcode

\stoptext

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] MetaPost circular_shade Command

2012-05-02 Thread Troy Henderson
It seems that I should do something like

fill fullcircle scaled 4in withshade
define_circular_shade(origin,origin,0   ,2in,white,red);

Sorry for the premature question.

Troy
___
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] Font for MetaPost graphics

2012-05-02 Thread Marco
On 2012-05-02 Aditya Mahajan adit...@umich.edu wrote:

 Metapost now runs as a library. All the text is first typeset by ConTeXt 
 and metapost only knows the bounding box of the labels.
 
 You can try (untested):
 
 \starttext
 
 This is serif
 
 \switchtobodyfont[sans]
 \startMPcode
 draw textext(This should be sans);
 \stopMPcode
 
 \stoptext

This works, of course. However it continues with sans font even
after \stopMPcode. This is better (but clumsy):

\start
\switchtobodyfont[sans]
\startMPcode
draw textext(This should be sans);
\stopMPcode
\stop
Here serif again.

The text in Metapost adapts to the text set in ConTeXt. But the font
setup should *only* be set for MetaPost, not regular text.

Does that mean, that MPenvironment is deprecated and does not work
at all?

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
___


Re: [NTG-context] Metapost/Metafun Q: using variables and building blocks?

2012-05-01 Thread Peter Rolf
Hi Mari,

Am 30.04.2012 23:40, schrieb Mari Voipio:
 On Mon, Apr 23, 2012 at 20:34, Mari Voipio mari.voi...@iki.fi wrote:
 a) I need to be able to stack four of these on top of each other and
 then four mirrored ones next to them
 
 OK, I really was being stupid - I had already managed to do a shift
 inside a single 'block', somehow I just didn't see that I could do the
 same to the blocks:
 
 
 
 \startMPpage
 
 
 picture ll ; % left-hand loop
 ll :=
   image (
   path p, q, r ;
 
   p := fullcircle scaled 4mm ;
   q := p shifted (0mm,10mm) ;
   r := center p .. (5mm,5mm) .. center q ;
 
   pair pr, qr ;
 
   pr := p intersectionpoint r ;
   qr := q intersectionpoint r ;
 
   r := r cutbefore pr cutafter qr ;
   r := r cutends 0.2mm ;
 
   draw r withpen pencircle scaled 0.2mm withcolor black ; % the 
 connecting curve
   draw p withpen pencircle scaled 0.2mm withcolor black ; fill p
 withcolor black ; % upper shank
   draw q withpen pencircle scaled 0.2mm withcolor black ; fill q
 withcolor black ; % lower shank
   );
 
 
 draw ll ;
 draw ll shifted (0mm,20mm) ;
 draw ll shifted (0mm,40mm) ;
 draw ll shifted (0mm,60mm) ;
 
 
 \stopMPpage
 
 
 Keeping in mind that I
 will have to be able to draw a path/arrow on top, so I need to know
 where they are.
 
 My little brain got an overflow from all this abstract thinking, but
 then it dawned on me that I could use the millimeter grid recipe in
 the MetaFun manual (p. 214) to draw a grid behind my pattern drawing.
 Now placing the arrows should be a walk in the park...
 
 
 
 b) The circles p and q can be filled with the same colour or two
 different colours, and each of the blocks in a pattern can have
 different fill colour

 I assume the answer is use variables, but how?
 
 Gaah, I still cannot figure it out!
 A real example: one of my own patterns has white up and down on first
 loop, black up white down on second, white up and down on third and
 blue up and down on fourth. So I'd need
 
 draw ll ; % and fill both circles with white
 draw ll shifted (0mm,20mm) ; % and fill lower circle with white,
 shifted/upper circle with black
 draw ll shifted (0mm,40mm) ; % fill both circles with white
 draw ll shifted (0mm,60mm) ; % fill both circles with blue

 
 What is the shortest way of doing this? I don't mind writing
 definitions earlier in the file, but I'd rather keep this part as
 short as possible to be able to see the pattern at one glance. The
 main problem comes from the bicoloured loops as I can't just apply the
 same fill on both. And on the whole I'd prefer to make sure I apply
 the fill only locally per each half-loop and not all over the place...

donno what is the shortest way, but this looks at least handy...


\startMPinclusions

patternsize:= 20mm;

def lhl(expr ca,cb,sx,sy) =
 picture lefthandloop;
 lefthandloop := image (
 path p, q, r ;
 p := fullcircle scaled 4mm ;
 q := p shifted (0mm,10mm) ;
 r := center p .. (5mm,5mm) .. center q ;
 r := r cutbefore (p intersectionpoint r) cutafter (q
intersectionpoint r) ;

 draw r withpen pencircle scaled 0.2mm withcolor black ; % the
connecting curve
 fill p withcolor ca;
 draw p withpen pencircle scaled 0.2mm withcolor black ; % upper
shank
 fill q withcolor cb;
 draw q withpen pencircle scaled 0.2mm withcolor black ; % lower
shank
 );
 draw lefthandloop shifted (sx*patternsize,sy*patternsize);
enddef;

\stopMPinclusions


\startMPpage

lhl(white,white,0,0);
lhl(white,black,0,1);
lhl(white,white,0,2);
lhl(blue ,blue ,0,3);

\stopMPpage




Best wishes, 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] Metapost/Metafun Q: using variables and building blocks?

2012-04-30 Thread Mari Voipio
On Mon, Apr 23, 2012 at 20:34, Mari Voipio mari.voi...@iki.fi wrote:
 a) I need to be able to stack four of these on top of each other and
 then four mirrored ones next to them

OK, I really was being stupid - I had already managed to do a shift
inside a single 'block', somehow I just didn't see that I could do the
same to the blocks:



\startMPpage


picture ll ; % left-hand loop
ll :=
image (
path p, q, r ;

p := fullcircle scaled 4mm ;
q := p shifted (0mm,10mm) ;
r := center p .. (5mm,5mm) .. center q ;

pair pr, qr ;

pr := p intersectionpoint r ;
qr := q intersectionpoint r ;

r := r cutbefore pr cutafter qr ;
r := r cutends 0.2mm ;

draw r withpen pencircle scaled 0.2mm withcolor black ; % the 
connecting curve
draw p withpen pencircle scaled 0.2mm withcolor black ; fill p
withcolor black ; % upper shank
draw q withpen pencircle scaled 0.2mm withcolor black ; fill q
withcolor black ; % lower shank
);


draw ll ;
draw ll shifted (0mm,20mm) ;
draw ll shifted (0mm,40mm) ;
draw ll shifted (0mm,60mm) ;


\stopMPpage


 Keeping in mind that I
 will have to be able to draw a path/arrow on top, so I need to know
 where they are.

My little brain got an overflow from all this abstract thinking, but
then it dawned on me that I could use the millimeter grid recipe in
the MetaFun manual (p. 214) to draw a grid behind my pattern drawing.
Now placing the arrows should be a walk in the park...



 b) The circles p and q can be filled with the same colour or two
 different colours, and each of the blocks in a pattern can have
 different fill colour

 I assume the answer is use variables, but how?

Gaah, I still cannot figure it out!
A real example: one of my own patterns has white up and down on first
loop, black up white down on second, white up and down on third and
blue up and down on fourth. So I'd need

draw ll ; % and fill both circles with white
draw ll shifted (0mm,20mm) ; % and fill lower circle with white,
shifted/upper circle with black
draw ll shifted (0mm,40mm) ; % fill both circles with white
draw ll shifted (0mm,60mm) ; % fill both circles with blue


What is the shortest way of doing this? I don't mind writing
definitions earlier in the file, but I'd rather keep this part as
short as possible to be able to see the pattern at one glance. The
main problem comes from the bicoloured loops as I can't just apply the
same fill on both. And on the whole I'd prefer to make sure I apply
the fill only locally per each half-loop and not all over the place...



Getting closer,

Mari


PS. I don't have any photos of the above braid, but here's a typical
fingerloop braid that I did and need to document:
http://www.lucet.fi/2012/04/sydamellista-hearty/
___
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] Commands with arguments with MetaPost

2012-04-25 Thread Troy Henderson
I would like to be able to do something like this

\def\foo#1{
\startMPcode
fill (0,0)--(598,0)--(598,50)--(0,50)--cycle withcolor green;
label.rt(btex #1 etex),(50,25);
  \stopMPcode
}

and then use this in my ConTeXt document by

\foo{Some text}

However, my syntax seems to be incorrect, and I would appreciate any
help in fixing it.

Thanks,

Troy Henderson
___
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] Commands with arguments with MetaPost

2012-04-25 Thread Alan BRASLAU
On Wed, 25 Apr 2012 11:15:10 -0500
Troy Henderson thend...@gmail.com wrote:

 I would like to be able to do something like this
 
 \def\foo#1{
 \startMPcode
 fill (0,0)--(598,0)--(598,50)--(0,50)--cycle withcolor green;
 label.rt(btex #1 etex),(50,25);
   \stopMPcode
 }
 
 and then use this in my ConTeXt document by
 
 \foo{Some text}
 
 However, my syntax seems to be incorrect, and I would appreciate any
 help in fixing it.
 

\framed [frame=off,background=color,backgroundcolor=green,width=598,height=50]
{Some text}

(Of course, you need to put correct dimensions for the width and height
and also set an offset.)

Untested, so the syntax may be not quite correct.

You might want to use
\setupframedtext
and
\startframedtext
\stopframedtext
if you will be doing this often.
There is probably also a way to define a named framed text.

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] Commands with arguments with MetaPost

2012-04-25 Thread Rogers, Michael K

On Apr 25, 2012, at 12:15 PM, Troy Henderson wrote:

 I would like to be able to do something like this

 \def\foo#1{
\startMPcode
fill (0,0)--(598,0)--(598,50)--(0,50)--cycle withcolor green;
label.rt(btex #1 etex),(50,25);
  \stopMPcode
 }



Looks like a misplaced parenthesis:

   label.rt(btex #1 etex,(50,25));

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


[NTG-context] Metapost/Metafun Q: using variables and building blocks?

2012-04-23 Thread Mari Voipio
Hello all,

any graphic experts around who can bump me past a stupid hinder on my
way to understanding MPgraphics?


I'm trying to create a system of describing certain type of braiding
patterns (fingerloop braiding), based on what has been used in the
field before me - but they did it all manually either by pen or
computer, and I just do not fancy doing 40+ patterns by hand in
Inkscape, especially as my pattern recipe book keeps expanding and I'm
planning on that, too.

I think Metapost could be the solution, because I need simple shapes
and sometimes complicated but well-regulated paths/arrows to go
between them; I'm just being a clueless newbie, too much in the
WYSIWYG vector graphics mode to really know what to do.


Mostly with the examples in the Metafun manual I've managed to get as
far as to my basic building block, two circles joined by a curve:


\startMPpage
path p, q, r ;

p := fullcircle scaled 8mm ;
q := p shifted (0cm,24mm) ;
r := center p .. (12mm,12mm) .. center q ;

pair pr, qr ;

pr := p intersectionpoint r ;
qr := q intersectionpoint r ;

r := r cutbefore pr cutafter qr ;
r := r cutends 0.2mm ;

draw r withpen pencircle scaled 0.2mm withcolor black ;
draw p withpen pencircle scaled 0.2mm withcolor black ; fill p withcolor white;
draw q withpen pencircle scaled 0.2mm withcolor black ; fill q withcolor black;
\stopMPpage



However, I don't seem to be able to find the answers to the next questions:

a) I need to be able to stack four of these on top of each other and
then four mirrored ones next to them (all-in-all a 2 x 4 grid/block),
and probably a 1-block space between the two columns. I realize I can
do that with shift, but should I make my single 'building block' a
group, a buffer or overlay or something else? Keeping in mind that I
will have to be able to draw a path/arrow on top, so I need to know
where they are.
(At some point I need to expand to more columns, but the number of
rows is still 4 as we have humans have just four aligned fingers per
hand - thumbs aren't counted - but one can add hands i.e. people to
work wider braids.)


b) The circles p and q can be filled with the same colour or two
different colours, and each of the blocks in a pattern can have
different fill colour (e.g. two totally black, two totally white, two
half-and-half with either black or white on top). The pen/outline
colour should stay as black, which means that I can't implement the
symbol example in the Metafun manual (the smiley that is totally
switched from black to red).
I don't mind having different blocks for monocoloured and bicoloured
versions, but it would be nice to be able to say something like
\usesloop[lh,blue] for 'take a single-coloured left-hand loop in blue'
instead of having to dig deeper into the MP code every time.

I assume the answer is use variables, but how?



I used millimeters here because it just feels more natural to me,
that's what textile crafts does (when not based on inches like
quilting and scrapbooking...). The measurements won't be shown
anywhere - these are graphs or pictograms, not real pictures - so I
can still switch to using something else. Besides, if the building
block approach works, there isn't that much to be changed, get the
first block right and the rest can be calculated from there.



Any ideas on how I can achieve the ease that surely exists somewhere there?
I'll take plain Metapost or a combination of Metapost and Metafun +
ConTeXt as I'll use ConTeXt anyway to achieve multi-format output with
a minimum of fuss.



Help thankfully received, as always,

Mari



PS. Today's craft related metaphor: I feel just like I was staring at
a messed up skein of yarn: I know  that I'm now holding one of the
ends, I thus can start to untangle the knot - and the more I pry
loose, the less there's left to sort out. However, in the beginning
the process tends to be very slow and awkward...
___
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] Metapost/Metafun Q: using variables and building blocks?

2012-04-23 Thread Hans Hagen

On 23-4-2012 19:34, Mari Voipio wrote:

Hello all,

any graphic experts around who can bump me past a stupid hinder on my
way to understanding MPgraphics?


I'm trying to create a system of describing certain type of braiding
patterns (fingerloop braiding), based on what has been used in the
field before me - but they did it all manually either by pen or
computer, and I just do not fancy doing 40+ patterns by hand in
Inkscape, especially as my pattern recipe book keeps expanding and I'm
planning on that, too.

I think Metapost could be the solution, because I need simple shapes
and sometimes complicated but well-regulated paths/arrows to go
between them; I'm just being a clueless newbie, too much in the
WYSIWYG vector graphics mode to really know what to do.


Mostly with the examples in the Metafun manual I've managed to get as
far as to my basic building block, two circles joined by a curve:


\startMPpage
path p, q, r ;

p := fullcircle scaled 8mm ;
q := p shifted (0cm,24mm) ;
r := center p .. (12mm,12mm) .. center q ;

pair pr, qr ;

pr := p intersectionpoint r ;
qr := q intersectionpoint r ;

r := r cutbefore pr cutafter qr ;
r := r cutends 0.2mm ;

draw r withpen pencircle scaled 0.2mm withcolor black ;
draw p withpen pencircle scaled 0.2mm withcolor black ; fill p withcolor white;
draw q withpen pencircle scaled 0.2mm withcolor black ; fill q withcolor black;
\stopMPpage



However, I don't seem to be able to find the answers to the next questions:

a) I need to be able to stack four of these on top of each other and
then four mirrored ones next to them (all-in-all a 2 x 4 grid/block),
and probably a 1-block space between the two columns. I realize I can
do that with shift, but should I make my single 'building block' a
group, a buffer or overlay or something else? Keeping in mind that I
will have to be able to draw a path/arrow on top, so I need to know
where they are.
(At some point I need to expand to more columns, but the number of
rows is still 4 as we have humans have just four aligned fingers per
hand - thumbs aren't counted - but one can add hands i.e. people to
work wider braids.)


b) The circles p and q can be filled with the same colour or two
different colours, and each of the blocks in a pattern can have
different fill colour (e.g. two totally black, two totally white, two
half-and-half with either black or white on top). The pen/outline
colour should stay as black, which means that I can't implement the
symbol example in the Metafun manual (the smiley that is totally
switched from black to red).
I don't mind having different blocks for monocoloured and bicoloured
versions, but it would be nice to be able to say something like
\usesloop[lh,blue] for 'take a single-coloured left-hand loop in blue'
instead of having to dig deeper into the MP code every time.

I assume the answer is use variables, but how?


something:

\startMPpage

def MyShape =
image (
path p, q, r ;

p := fullcircle scaled 8mm ;
q := p shifted (0cm,24mm) ;
r := center p .. (12mm,12mm) .. center q ;

pair pr, qr ;

pr := p intersectionpoint r ;
qr := q intersectionpoint r ;

r := r cutbefore pr cutafter qr ;
r := r cutends 0.2mm ;

draw r withpen pencircle scaled 0.2mm withcolor black ;
draw p withpen pencircle scaled 0.2mm withcolor black ; fill p 
withcolor white;
draw q withpen pencircle scaled 0.2mm withcolor black ; fill q 
withcolor black;

)
enddef ;

for i=0 step 2cm until 8cm :
for j=0 step 4cm until 12cm :
draw MyShape shifted (i,j) ;
endfor ;
endfor ;

\stopMPpage


there are picture variables, so

picture pp ; pp := image(...) ;

can be used


I used millimeters here because it just feels more natural to me,
that's what textile crafts does (when not based on inches like
quilting and scrapbooking...). The measurements won't be shown
anywhere - these are graphs or pictograms, not real pictures - so I
can still switch to using something else. Besides, if the building
block approach works, there isn't that much to be changed, get the
first block right and the rest can be calculated from there.


mm are okay, alternative use no dimension, just numbers and scale 
afterwards:


currentpicture := currentpicture xsized 10cm ;

or so.


PS. Today's craft related metaphor: I feel just like I was staring at
a messed up skein of yarn: I know  that I'm now holding one of the
ends, I thus can start to untangle the knot - and the more I pry
loose, the less there's left to sort out. However, in the beginning
the process tends to be very slow and awkward...


beware, metapost is addictive once you get better in it,

(btw, a talk about this will fit nicely in the upcoming eurotex theme)

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477

[NTG-context] metapost fonts

2012-03-17 Thread Matej Barič
Hello,
In a document I'm writing I'm using urw-garamond font successfully. However I 
also use metaUML library for metapost where I'd like to have helvetica (or 
nimbus, heros, etc.).

For latin modern sans, I can use this:

string metauml_defaultFont;
metauml_defaultFont:=ec-lmss10;

But this only works for latin modern sans (which I don't like combined with 
urwgaramond) but not helvetica. I've tried to use some of txfonts and tex-gyre 
fonts (which use helvetica/heros/nimbus for their sans-serif) by writing 
metauml_defaultFont:=txss and metauml_defaultFont:=ec-qhvcb but I get an 
error pdftex (file rtxss): Font rtxss at 600 not found.

I've installed the latest context standalone.

Is there any other way to use helvetica in metapost/metauml or how to 
troubleshoot this error?

Thanks,
matej

___
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] metapost fonts

2012-03-17 Thread Mojca Miklavec
On Fri, Mar 16, 2012 at 10:17, Matej Barič wrote:
 Hello,
 In a document I'm writing I'm using urw-garamond font successfully. However I 
 also use metaUML library for metapost where I'd like to have helvetica (or 
 nimbus, heros, etc.).

 For latin modern sans, I can use this:

 string metauml_defaultFont;
 metauml_defaultFont:=ec-lmss10;

 But this only works for latin modern sans (which I don't like combined with 
 urwgaramond) but not helvetica. I've tried to use some of txfonts and 
 tex-gyre fonts (which use helvetica/heros/nimbus for their sans-serif) by 
 writing metauml_defaultFont:=txss and metauml_defaultFont:=ec-qhvcb but I 
 get an error pdftex (file rtxss): Font rtxss at 600 not found.

 I've installed the latest context standalone.

 Is there any other way to use helvetica in metapost/metauml or how to 
 troubleshoot this error?

I'm almost sure that the reason are missing lines describing those
fonts in pdftex.map. It might be that your example would work fine
with TeX Live or MikTeX out of the box. I have never used metauml and
I'm not sure what it does. Another reason could be lack of fonts that
you desire to use (but txfonts are present).

Does including original-youngryu-tx.map with command fontmapfile (or
command fontmapline) help you to get rtxss working? If not, can you
please send a minimal example?

ConTeXt uses different mechanisms to get the fonts inside metapost
code working, but metauml is most certainly not aware of any of those,
so it cannot take any advantage of that.

Mojca
___
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] MetaFun: MetaPost example works with `mpost` but not embedded in ConTeXt: `! Redundant equation.`

2011-12-11 Thread Paul Menzel
Dear ConTeXt folks,


looking for graphics example and therefore searching the list I found
the answer from David Arnold in the ntg-context list thread »OT: looking
for metapost/fun examples« [1].

It is for plain MetaPost and works fine with `mpost` after making sure
to remove the line breaks inserted by the mail program.

I then copied it into `\{start,stop}useMPgraphic`, removed the `end ;`
and `{begin,end}fig` and replaced `{e,b}tex` by `textext()` but still
get the following error.

! terminal: ! Redundant equation.
to be read again 
   ;
* ...500; dt:=(tstop-tstart)/N; (b-a)*ux=1.75in;
   (d-c)*uy=1.75in; 
q=(a,c)-...

! Redundant equation.
to be read again 
   ;
* ...start)/N; (b-a)*ux=1.75in; (d-c)*uy=1.75in;
   
q=(a,c)--(b,c)--(b,d)--(a...


.

system   tex  error on line 39 in file arnold-2005.tex: 
terminal: ! Redundant equation.
to be read again 
   ;
* ...500; dt:=(tstop-tstart)/N; (b-a)*ux=1.75in;
   (d-c)*uy=1.75in; 
q=(a,c)-...

! Redundant equation.
to be read again 
   ;
* ...start)/N; (b-a)*ux=1.75in; (d-c)*uy=1.75in;
   
q=(a,c)--(b,c)--(b,d)--(a...

Does someone have an idea why this fails and how to fix it?


Thanks,

Paul


[1] http://www.ntg.nl/pipermail/ntg-context/2005/009928.html
%This file creates two figures associated with the
%system x'=f(x,y), y'=g(x,y)
%1. Plots the graphs of x(t) and y(t)
%2. Plots the graph of (x(t),y(t)) in the phase plane.

%verbatimtex
%\input mtplain
%etex

%Generate standard eps
prologues:=2;

beginfig(0);

%Place RHS of x'=f(t,x,y) here
  def fxy(expr t, x, y)=
   (0.4-0.01*y)*x
  enddef;

%Place RHS of y'=g(t,x,y) here
  def gxy(expr t, x, y)=
   (-0.3+0.005*x)*y
  enddef;

%Declare some variables
  path q, trajx, trajy;
  pair L, R, B, T, xt, yt;
  numeric sx[], sy[];

%Initialize clipping window
  a:=0; b:=40;   %left and right of viewing rectangle
  c:=0; d:=150;  %bottom and top of viewing rectangle

%Initialize timespan
  tstart:=a;
  tstop:=b;

%Initialize number of points to be plotted
  N:=500;

%Calculate time increment dt for Euler's method
  dt:=(tstop-tstart)/N;

%Scaling factors for horizontal and vertical axes. Note that this produces
%an image that is 2 inches by 2 inches.
  (b-a)*ux=1.75in;
  (d-c)*uy=1.75in;

%Clipping boundary
  q=(a,c)--(b,c)--(b,d)--(a,d)--cycle;

%Use Runge-Kutta4 to create path (t,x(t))

%Choose initial condition
  t:=tstart;
  x:=40;
  y:=20;
  trajx:=(t,x);
  forever:
   sx1:=fxy(t,x,y);
   sy1:=gxy(t,x,y);
   sx2:=fxy((t+dt/2),(x+dt*sx1/2),(y+dt*sy1/2));
   sy2:=gxy((t+dt/2),(x+dt*sx1/2),(y+dt*sy1/2));
   sx3:=fxy((t+dt/2),(x+dt*sx2/2),(y+dt*sy2/2));
   sy3:=gxy((t+dt/2),(x+dt*sx2/2),(y+dt*sy2/2));
   sx4:=fxy((t+dt),(x+dt*sx3),(y+dt*sy3));
   sy4:=gxy((t+dt),(x+dt*sx3),(y+dt*sy3));
   x:=x+dt*(sx1+2*sx2+2*sx3+sx4)/6;
   y:=y+dt*(sy1+2*sy2+2*sy3+sy4)/6;
   t:=t+dt;
   trajx:=trajx..(t,x);
   exitif ((ttstop) or (tb) or (xc) or (xd));
  endfor;

%Use Runge-Kutta4 to create path (t,y(t))

%Choose initial condition
  t:=tstart;
  x:=40;
  y:=20;
  trajy:=(t,y);
  forever:
   sx1:=fxy(t,x,y);
   sy1:=gxy(t,x,y);
   sx2:=fxy((t+dt/2),(x+dt*sx1/2),(y+dt*sy1/2));
   sy2:=gxy((t+dt/2),(x+dt*sx1/2),(y+dt*sy1/2));
   sx3:=fxy((t+dt/2),(x+dt*sx2/2),(y+dt*sy2/2));
   sy3:=gxy((t+dt/2),(x+dt*sx2/2),(y+dt*sy2/2));
   sx4:=fxy((t+dt),(x+dt*sx3),(y+dt*sy3));
   sy4:=gxy((t+dt),(x+dt*sx3),(y+dt*sy3));
   x:=x+dt*(sx1+2*sx2+2*sx3+sx4)/6;
   y:=y+dt*(sy1+2*sy2+2*sy3+sy4)/6;
   t:=t+dt;
   trajy:=trajy..(t,y);
   exitif ((ttstop) or (tb) or (yc) or (yd));
  endfor;

%Draw the paths x(t) and y(t) and clip them to bounding box
  draw trajx xscaled ux yscaled uy withcolor red;
  draw trajy xscaled ux yscaled uy withcolor red dashed evenly;
  clip currentpicture to (q xscaled ux yscaled uy);

%Label graph x(t) and initial condition
  len:= 0.65*(length trajx);
  xt:=point len of trajx;
  label.urt(btex $\scriptstyle x(t)$ etex, (xt xscaled ux yscaled uy));

%Label graph y(t) and initial condition
  len:= 0.5*(length trajy);
  yt:=point len of trajy;
  label.lrt(btex $\scriptstyle y(t)$ etex, (yt xscaled ux yscaled uy));


%Initialize left and right endpoints on time-axis
  L=(a*ux,0);R=(b*ux,0);

%Draw and label t-axis
  drawarrow L--R;
  label.rt(btex $\scriptstyle t$ etex,(b*ux,0));

%Initialize bottom and top endpoints on time-axis
  B=(0,c*uy);T=(0,d*uy);

%Draw and label vertical axis
  drawarrow B--T;
  label.lft(btex $\scriptstyle 0$ etex, B);
  label.lft(btex $\scriptstyle 150$ etex, T);

endfig;


beginfig(2);

%Make some variables local
  save ux, uy

Re: [NTG-context] MetaFun: MetaPost example works with `mpost` but not embedded in ConTeXt: `! Redundant equation.`

2011-12-11 Thread Marco
On 2011-12-11 Paul Menzel paulepan...@users.sourceforge.net wrote:

 […]

 I  then  copied   it  into  `\{start,stop}useMPgraphic`,
 removed the  `end ;`  and `{begin,end}fig`  and replaced
 `{e,b}tex` by  `textext()` but  still get  the following
 error.

I didn't  check you  code (try to  make a  minimal example
next time), but the problem seems to be the combination of
equations and labels. When labels are present, the file is
processed twice and the equations  are also read twice (in
MkIV). It hasn't been fixed  for ages, that probably means
it will stay.

One  workaround  is  to   substitute  the  equations  with
assignments or to “save” the values beforehand.

See also:
http://archive.contextgarden.net/message/20101205.035356.1b7bfb72.en.html

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
___

Re: [NTG-context] `\{start, stop}MPpage`: MetaPost figure does not fit canvas(?) in resulting PDF file

2011-12-09 Thread Hans Hagen

On 7-12-2011 20:36, Paul Menzel wrote:

Dear ConTeXt folks,


using the following example

 \starttext
 \startMPpage
 draw (0,0)--(10,10)--(15,5)--(20,10);
 draw (0,0)--(0,10)--(10,10)--(10,5)--(15,5)--(15,10)--(20,10) 
withcolor blue;
 \stopMPpage
 \stoptext

it looks like the bottom is not included in the resulting PDF file and
at the top there is too much room. (So it looks like the figure is moved
too far to the bottom.)

Using the examples from the Wiki [1] with circles works though.


it has to do with the size and topskip interference .. somewhat bigger 
images work ok (hopefully fixed in next beta)




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


[NTG-context] `\{start, stop}MPpage`: MetaPost figure does not fit canvas(?) in resulting PDF file

2011-12-07 Thread Paul Menzel
Dear ConTeXt folks,


using the following example

\starttext
\startMPpage
draw (0,0)--(10,10)--(15,5)--(20,10);
draw (0,0)--(0,10)--(10,10)--(10,5)--(15,5)--(15,10)--(20,10) withcolor 
blue;
\stopMPpage
\stoptext

it looks like the bottom is not included in the resulting PDF file and
at the top there is too much room. (So it looks like the figure is moved
too far to the bottom.)

Using the examples from the Wiki [1] with circles works though.

I am using ConTeXt Standalone.

ConTeXt  ver: 2011.11.25 21:29 MKIV  fmt: 2011.11.25  int: english/english


Thanks,

Paul


[1] http://wiki.contextgarden.net/Mpgraphic


test.pdf
Description: Adobe PDF document
\starttext
\startMPpage
draw (0,0)--(10,10)--(15,5)--(20,10);
draw (0,0)--(0,10)--(10,10)--(10,5)--(15,5)--(15,10)--(20,10) withcolor blue;
\stopMPpage

\startMPpage
 draw fullcircle scaled 2cm;
 dotlabel.bot(textext((0,0)),origin);
\stopMPpage

\startMPpage
 draw fullcircle scaled 2cm;
 drawarrow (0,0)--(1cm,0);
 label.bot(textext($r$),(5mm,0));
\stopMPpage
\stoptext


signature.asc
Description: This is a digitally signed message part
___
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] Escaping a special character in a MetaPost figure within a ConTeXt document fails

2011-12-01 Thread Raymond LeClair
Thanks for the reply!

Found I needed to use \letterbackslash\letterhash for this to work. Does that 
make sense?

On Nov 30, 2011, at 10:37 AM, Aditya Mahajan wrote:

 Try:
 
 using \letterhash instead of \#
 
 or
 
 \startasciimode
 \def \FrontMatterTitle {
 \startreusableMPgraphic{frontmattertitle:\overlaywidth:\overlayheight}
   matter_paper_width := 4.25in;
   matter_paper_height := 6.875in;
   front_left_margin := 0.3889in;
   top_margin := 0.3472in;
   draw (0, 0)--(matter_paper_width, matter_paper_height)
 withpen pencircle scaled 1bp withcolor white;
   picture titleText;
 
   %% == HERE IS THE SOURCE OF THE PROBLEM ==
 
   titleText := btex {\vbox{\hsize 2.7291667in \baselineskip 38.0pt
   \setupalign[flushleft,hyphenated,verytolerant]
   \TitleFont THE BEGINNINGS OF #BOOM}} etex;
 %% NOTE I changed \# to # and % to %%
   labeloffset := 0bp;
   label.lrt(titleText, (front_left_margin,
 matter_paper_height - top_margin));
 \stopreusableMPgraphic
 \reuseMPgraphic{frontmattertitle:\overlaywidth:\overlayheight}
 }
 
 \stopasciimode
 
 You can also use \framed[width=2.73in, 
 foregroundstyle={\TitleFont\setupinterlinespace[38pt],
 align={flushleft, }]{The } instead of explicit \vbox.
 
 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
 ___

___
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] metapost question

2011-12-01 Thread Hans van der Meer
In MetaPost: 
After putting something in a picture, one can draw its boundaries with draw 
boundingbox thepicture. Is it possible to obtain at that point the dimensions 
of this boudingbox in order to do some calculations with them?

Hans van der Meer



___
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] metapost question

2011-12-01 Thread Peter Rolf
Am 01.12.2011 23:25, schrieb Hans van der Meer:
 In MetaPost: 
 After putting something in a picture, one can draw its boundaries with draw 
 boundingbox thepicture. Is it possible to obtain at that point the 
 dimensions of this boudingbox in order to do some calculations with them?

urcorner boundingbox currentpicture

should hold the wanted values (untested); maybe you have to take
'llcorner' into account too.

Best wishes,  Peter

 Hans van der Meer
 
 
 
 ___
 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] Escaping a special character in a MetaPost figure within a ConTeXt document fails

2011-11-30 Thread Raymond LeClair
I have escaped the '#' character in the usual way, using a backslash, as '\#' 
in a btex...etex picture as part of a MetaPost figure created within a ConTeXt 
document, but the escaped character still causes the ConTeXt processing to fail.

Here is an example...

\pdfminorversion=5

\definepapersize[LG1][width=4.25in,height=6.875in]
\definepapersize[LP1][width=4.25in,height=6.875in]

\setuppapersize[LG1][LP1]

\definelayout[frontmatter]
 
[topspace=0.in,header=0.5556in,height=6.4305556in,footer=0.6944in,
  backspace=1.056in,width=2.861in,location=middle,
  
leftmargindistance=0.in,rightmargindistance=0.in,
  leftmargin=0.8333in,rightmargin=0.in]

\definefont[TitleFont][Serif sa 3.5]

\definecolor[TransparentWhite][b=1,t=0,a=1]

\def \FrontMatterTitle {
  \startreusableMPgraphic{frontmattertitle:\overlaywidth:\overlayheight}
matter_paper_width := 4.25in;
matter_paper_height := 6.875in;
front_left_margin := 0.3889in;
top_margin := 0.3472in;
draw (0, 0)--(matter_paper_width, matter_paper_height)
  withpen pencircle scaled 1bp withcolor white;
picture titleText;

% == HERE IS THE SOURCE OF THE PROBLEM ==

titleText := btex {\vbox{\hsize 2.7291667in \baselineskip 38.0pt
\setupalign[flushleft,hyphenated,verytolerant]
\TitleFont THE BEGINNINGS OF \#BOOM}} etex;
labeloffset := 0bp;
label.lrt(titleText, (front_left_margin,
  matter_paper_height - top_margin));
  \stopreusableMPgraphic
  \reuseMPgraphic{frontmattertitle:\overlaywidth:\overlayheight}
}

\defineoverlay[frontmattertitle][\FrontMatterTitle]

\starttext

\setuplayout[frontmatter]

{\TransparentWhite\title{...}}
\setupbackgrounds[page][background={{frontmattertitle}},state=repeat]
{\TransparentWhite\midaligned{...}}

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


Re: [NTG-context] Escaping a special character in a MetaPost figure within a ConTeXt document fails

2011-11-30 Thread Aditya Mahajan

Try:

using \letterhash instead of \#

or

\startasciimode

\def \FrontMatterTitle {
 \startreusableMPgraphic{frontmattertitle:\overlaywidth:\overlayheight}
   matter_paper_width := 4.25in;
   matter_paper_height := 6.875in;
   front_left_margin := 0.3889in;
   top_margin := 0.3472in;
   draw (0, 0)--(matter_paper_width, matter_paper_height)
 withpen pencircle scaled 1bp withcolor white;
   picture titleText;

   %% == HERE IS THE SOURCE OF THE PROBLEM ==

   titleText := btex {\vbox{\hsize 2.7291667in \baselineskip 38.0pt
   \setupalign[flushleft,hyphenated,verytolerant]
   \TitleFont THE BEGINNINGS OF #BOOM}} etex;

%% NOTE I changed \# to # and % to %%

   labeloffset := 0bp;
   label.lrt(titleText, (front_left_margin,
 matter_paper_height - top_margin));
 \stopreusableMPgraphic
 \reuseMPgraphic{frontmattertitle:\overlaywidth:\overlayheight}
}


\stopasciimode

You can also use \framed[width=2.73in, 
foregroundstyle={\TitleFont\setupinterlinespace[38pt],
align={flushleft, }]{The } instead of explicit \vbox.

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
___


[NTG-context] Math in metapost

2011-11-30 Thread Hans van der Meer
I would like to put some math in metapost pictures. For the moment I am using 
textext for the typesetting in my metapost macro: pic := 
textext(\setbox0=\hbox{\color[textcolor]labeltext}\dp0=0pt\box0);
picture pic will be placed in the metapost figure.

Simple math like $p=2$ works fine, but the system chokes on something like the 
following matrix:
$\pmatrix{p_{0|0}\cr}$ (it does fine in ConTeXt itself).

The error is: ! Only one # is allowed per tab.
system  tex  error on line 6 in file Info/kanaalmatrix.tex: Only one # is 
allowed per tab ...

Perhaps I am too optimistic about textext's possibilities. But how can I 
accomplish the placement of these and more elaborate formulae in metapost 
pictures using ConTeXt? It is of the essence for a series of Powerpoint slides 
I am preparing, wheein these formulae must be placed as individual pictures.

Hans van der Meer



___
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] Math in metapost

2011-11-30 Thread Otared Kavian
Hi,

I am not a specialist, but I use the « btex etex » commands, such as
dotlabel.bot (btex \switchtobodyfont[10pt] \strut $R$ etex, z1)

I just tested with the latest beta, and everything works fine, but not the 
\pmatrix construct (I tried also with ${k}\choose{n}$, which works fine too. 
I put my test file in which some maths is used in a MetaPost graphic here:
http://dl.dropbox.com/u/4316076/test-graphique.tex

http://dl.dropbox.com/u/4316076/test-graphique.pdf


Best regards: OK

On 30 nov. 2011, at 20:59, Hans van der Meer wrote:

 I would like to put some math in metapost pictures. For the moment I am using 
 textext for the typesetting in my metapost macro: pic := 
 textext(\setbox0=\hbox{\color[textcolor]labeltext}\dp0=0pt\box0);
 picture pic will be placed in the metapost figure.
 
 Simple math like $p=2$ works fine, but the system chokes on something like 
 the following matrix:
 $\pmatrix{p_{0|0}\cr}$ (it does fine in ConTeXt itself).
 
 The error is: ! Only one # is allowed per tab.
 system  tex  error on line 6 in file Info/kanaalmatrix.tex: Only one # is 
 allowed per tab ...
 
 Perhaps I am too optimistic about textext's possibilities. But how can I 
 accomplish the placement of these and more elaborate formulae in metapost 
 pictures using ConTeXt? It is of the essence for a series of Powerpoint 
 slides I am preparing, wheein these formulae must be placed as individual 
 pictures.
 
 Hans van der Meer
 
 
 
 ___
 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
 ___

%%
Otared Kavian
Département de Mathématiques
Université de Versailles Saint-Quentin
Bâtiment Fermat
45 avenue des Etats Unis
78035 Versailles cedex

Téléphone: +33 1 39 25 46 42
Secrétariat: +33 1 39 25 46 44 
Secrétariat: +33 1 39 25 46 46

e-mail: otared.kav...@math.uvsq.fr




___
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] Math in metapost

2011-11-30 Thread Hans Hagen

On 30-11-2011 20:59, Hans van der Meer wrote:

I would like to put some math in metapost pictures. For the moment I am using textext for the typesetting in my metapost 
macro: pic := 
textext(\setbox0=\hbox{\color[textcolor]labeltext}\dp0=0pt\box0);
picture pic will be placed in the metapost figure.

Simple math like $p=2$ works fine, but the system chokes on something like the 
following matrix:
$\pmatrix{p_{0|0}\cr}$ (it does fine in ConTeXt itself).

The error is: ! Only one # is allowed per tab.
system  tex  error on line 6 in file Info/kanaalmatrix.tex: Only one # is 
allowed per tab ...

Perhaps I am too optimistic about textext's possibilities. But how can I 
accomplish the placement of these and more elaborate formulae in metapost 
pictures using ConTeXt? It is of the essence for a series of Powerpoint slides 
I am preparing, wheein these formulae must be placed as individual pictures.


you can patch pmatrix:

\unexpanded\def\pmatrix#1%
  {\left(\matrix{#1}\right)}

(i'll make the lot unexpandable)

btw, for large chunks you can consider using setups

\startsetups lots-of-math

\stopsetups

... \textext(\setup[lots-of-math])




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


[NTG-context] Metapost graphics in separate file, help needed

2011-11-23 Thread Christian
Dear List,

I am experiencing a strange problem. I have a project, essentially with the 
following structure (desperate attempt to keep track of my stuff):

mainfile.mkiv:
% BOF
...lots of setups and settings...
\starttext
\input metapostgraphics.mkiv
\input chapter1.mkiv
\input chapter2.mkiv
\input chapter3.mkiv
\stoptext
% EOF

I generate the PDF with 'context mainfile.mkiv'
So far for the structure. Now my problem:
metapostgraphics.mkiv contains several (4) metapost graphics with 
\startuseMPgraphics{nameX} ... \stopuseMPgraphics.
In chapter2.mkiv I want to use them with \useMPgraphics{nameX}.
It worked well until today, when I added a fifth graphic. Then I suddenly get a 
frame with 'undefined' inside instead of the picture.
I tried everything, checked for typos, tried different names, double checked 
the MP-code etc. but to no avail.

It only works if I put the exact same MP-code between \startMPcode \stopMPcode 
directly in the chapter2.mkiv

What is wrong here? Am I missing something? Did I get the input mechanism all 
wrong?

___
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] Metapost graphics in separate file, help needed

2011-11-23 Thread Hans Hagen

On 23-11-2011 19:23, Christian wrote:

Dear List,

I am experiencing a strange problem. I have a project, essentially with the 
following structure (desperate attempt to keep track of my stuff):

mainfile.mkiv:
% BOF
lots of setups and settings...
\starttext
\input metapostgraphics.mkiv
\input chapter1.mkiv
\input chapter2.mkiv
\input chapter3.mkiv
\stoptext
% EOF

I generate the PDF with 'context mainfile.mkiv'
So far for the structure. Now my problem:
metapostgraphics.mkiv contains several (4) metapost graphics with 
\startuseMPgraphics{nameX} ... \stopuseMPgraphics.
In chapter2.mkiv I want to use them with \useMPgraphics{nameX}.
It worked well until today, when I added a fifth graphic. Then I suddenly get a 
frame with 'undefined' inside instead of the picture.
I tried everything, checked for typos, tried different names, double checked 
the MP-code etc. but to no avail.

It only works if I put the exact same MP-code between \startMPcode \stopMPcode 
directly in the chapter2.mkiv

What is wrong here? Am I missing something? Did I get the input mechanism all 
wrong?


What happens if you make a simple file with the 4 \useMPgraphics in it 
.. does that one process? Maybe there is a problem with the graphics in 
the sense that you cannto run them all in a row.


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] Metapost graphics in separate file, help needed

2011-11-23 Thread Aditya Mahajan
It only works if I put the exact same MP-code between \startMPcode 
\stopMPcode directly in the chapter2.mkiv


What is wrong here? Am I missing something? Did I get the input mechanism 
all wrong?


What happens if you make a simple file with the 4 \useMPgraphics in it .. 
does that one process? Maybe there is a problem with the graphics in the 
sense that you cannto run them all in a row.


You can also try adding

begingroup;

endgroup;

inside each MP figure. I always wished that this was the default 
behaviour.


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] Metapost graphics in separate file, help needed

2011-11-23 Thread Christian
Thanks for the suggestions so far. I' currently testing Hans' idea and it seems 
to be a problem with caching.

The simple file I made where I just use each graphic runs into an error, but 
the corresponding code (undefined control sequence '\sb') is definitely not in 
the current source file of the graphics.

How do I clear the cache to force recalculation of the MP-graphics?

 -Ursprüngliche Nachricht-
 Von: ntg-context-boun...@ntg.nl [mailto:ntg-context-boun...@ntg.nl] Im
 Auftrag von Aditya Mahajan
 Gesendet: Mittwoch, 23. November 2011 20:33
 An: mailing list for ConTeXt users
 Betreff: Re: [NTG-context] Metapost graphics in separate file, help needed
 
  It only works if I put the exact same MP-code between \startMPcode
  \stopMPcode directly in the chapter2.mkiv
 
  What is wrong here? Am I missing something? Did I get the input
  mechanism all wrong?
 
  What happens if you make a simple file with the 4 \useMPgraphics in it ..
  does that one process? Maybe there is a problem with the graphics in
  the sense that you cannto run them all in a row.
 
 You can also try adding
 
 begingroup;
 
 endgroup;
 
 inside each MP figure. I always wished that this was the default behaviour.
 
 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
 __
 _

___
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] Metapost graphics in separate file, help needed

2011-11-23 Thread Hans Hagen

On 23-11-2011 20:32, Aditya Mahajan wrote:

It only works if I put the exact same MP-code between \startMPcode
\stopMPcode directly in the chapter2.mkiv

What is wrong here? Am I missing something? Did I get the input
mechanism all wrong?


What happens if you make a simple file with the 4 \useMPgraphics in it
.. does that one process? Maybe there is a problem with the graphics
in the sense that you cannto run them all in a row.


You can also try adding

begingroup;
.
endgroup;

inside each MP figure. I always wished that this was the default behaviour.


Actually, last week I was tempted to do that but I cannot oversee the 
consequences. It is probably harmless. The interesting thing is that 
beginfig/endfig have grouping but somehow it does not work out well.


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] Metapost graphics in separate file, help needed

2011-11-23 Thread Christian
Oh boy. This is embarrassing!

Turns out the file that was open in notepad++ was not the one in the path of my 
project, but had the exact same name. 
And I was editing this sucker  instead of the real file. I guess I should 
reload my files during sessions.

insert double face-palm here
Problem solved, it's sitting right in front of the screen and is banging his 
head hard against the wall now.

I'm truly sorry that I have wasted your time.

 -Ursprüngliche Nachricht-
 Von: ntg-context-boun...@ntg.nl [mailto:ntg-context-boun...@ntg.nl] Im
 Auftrag von Hans Hagen
 Gesendet: Mittwoch, 23. November 2011 20:59
 An: mailing list for ConTeXt users
 Betreff: Re: [NTG-context] Metapost graphics in separate file, help needed
 
 On 23-11-2011 20:32, Aditya Mahajan wrote:
  It only works if I put the exact same MP-code between \startMPcode
  \stopMPcode directly in the chapter2.mkiv
 
  What is wrong here? Am I missing something? Did I get the input
  mechanism all wrong?
 
  What happens if you make a simple file with the 4 \useMPgraphics in
  it .. does that one process? Maybe there is a problem with the
  graphics in the sense that you cannto run them all in a row.
 
  You can also try adding
 
  begingroup;
  .
  endgroup;
 
  inside each MP figure. I always wished that this was the default behaviour.
 
 Actually, last week I was tempted to do that but I cannot oversee the
 consequences. It is probably harmless. The interesting thing is that
 beginfig/endfig have grouping but somehow it does not work out well.
 
 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
 __
 _

___
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] Metapost graphics in separate file, help needed

2011-11-23 Thread Hans Hagen

On 23-11-2011 20:50, Christian wrote:


How do I clear the cache to force recalculation of the MP-graphics?


fyi: There is no cache in mkiv as mp is run internally, which is why it 
is so fast (and in mkii caching is clever enough to determine a change).


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] Arrows and boxes in metapost.

2011-11-17 Thread Hans Hagen

On 14-11-2011 20:31, Christian wrote:

Hello,

I need a simple graphic that shows some boxes (frames) with text in it and has 
some arrows pointing to and from these boxes. (examples 267 and 268 on this 
page [1])
I was hoping to do this in MetaPost.

Earlier this year this question went un-answered on this list:
How to use boxit MetaPost macros with ConTeXt minimals?

So, is there a solution or do I have to use
label.rt(btex \framed[width=3cm,align=middle]{Text} etex, (1u,1.5u));


draw thetextext.rt(\framed[width=3cm,align=middle]{Text},(1u,1.5u))

I never used the boxit macros but if they are normal mp they should just 
work; otherwise post a mininimal example (more change of an answer).


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
___


[NTG-context] Arrows and boxes in metapost.

2011-11-14 Thread Christian
Hello,

I need a simple graphic that shows some boxes (frames) with text in it and has 
some arrows pointing to and from these boxes. (examples 267 and 268 on this 
page [1])
I was hoping to do this in MetaPost.

Earlier this year this question went un-answered on this list:
How to use boxit MetaPost macros with ConTeXt minimals?

So, is there a solution or do I have to use 
label.rt(btex \framed[width=3cm,align=middle]{Text} etex, (1u,1.5u));

Which really feels uncomfortable in this case.

Best regards
Christian

[1] http://tex.loria.fr/prod-graph/zoonekynd/metapost/metapost.html

___
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] macro string in metapost

2011-11-02 Thread Hans Hagen

On 1-11-2011 23:21, Meer, H. van der wrote:

The goal is to make the following string in metapost:
   string s; where s must become \MPcolor{Blue}.
and ultimately execute this at the right moment with: scantokens s;

The following makes s = MPcolor{Blue}:
   s := MPcolor  char oct134  char oct173  Blue  char oct134  char 
oct175;

But I seem unable to add a \ in front of it without expanding the string by 
TeX. Thus it does not work to put:
   s := char oct134  MPcolor  char oct134  char oct173  Blue  char 
oct134  char oct175;

Placing a \noexpand in front does not help.


\MPcolor is expanded when the code is passed to mp so delaying is not 
possible and once mp runs it already sees the colors


what you want is something

fill fullcircle scaled 10cm withcolor .5 * namedcolor(gray) ;
fill fullcircle scaled  5cm withcolor namedcolor(red) ;
fill fullcircle scaled  5cm withcolor namedcolor(green) ;
fill fullcircle scaled  5cm withcolor namedcolor(blue) ;

(I have that as experimental code but will move it to the regular code)

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
___


[NTG-context] macro string in metapost

2011-11-01 Thread Meer, H. van der
The goal is to make the following string in metapost:
  string s; where s must become \MPcolor{Blue}.
and ultimately execute this at the right moment with: scantokens s;

The following makes s = MPcolor{Blue}:
  s := MPcolor  char oct134  char oct173  Blue  char oct134  
char oct175;

But I seem unable to add a \ in front of it without expanding the string by 
TeX. Thus it does not work to put:
  s := char oct134  MPcolor  char oct134  char oct173  Blue  
char oct134  char oct175;

Placing a \noexpand in front does not help.

How to?

Hans van der Meer



___
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] MetaPost: Confusion with `function()` and `xyscaled`

2011-10-23 Thread Paul Menzel
Am Freitag, den 21.10.2011, 18:08 +0200 schrieb Peter Rolf:
 Am 21.10.2011 17:26, schrieb Paul Menzel:

  Am Freitag, den 21.10.2011, 17:02 +0200 schrieb Peter Rolf:
  
  I agree, this is confusing on the first sight. But scaling is not meant
  as 'scaling to' a dimension. In fact is is just a simple multiplication.
  The reason why it seems to work this way with
  'fullsquare' and such predefined paths is, that they have a 'neutral'
  size/scale (bounding box size of filled path is (1pt,1pt)).
  
  So how can I find out what the dimension of the path of a function is?
  Not scaling it, it also looked pretty small, so I am guessing (1pt,1pt).
 
 I guess in this case its size is (10,log(10)) + pen size when drawn.

That was it kind of. Probably the most of my confusion resulting from
the use of the inverse function.

So all in all the width is 1 – the x-coordinates seem to be scaled to
the width of 1 – and the height is 10, as ten is the highest value.
Therefore the width has to be multiplied with 10cm to get it to 10cm and
since the height it 10 already multiplying it with 2cm gets it to 20cm.

  Multiplying such a path with (x,y) gives an object with size (1*x,1*y).
  In general: if the bounding box of an object has the size (a,b) and you
  scale it with (x,y), the resulting object has a size of (ax,by). That's
  all the magic.
  
  but if you use numbers with a unit than it should not be multiplied but
  expanded to that value, should not it? Otherwise I am unsure how
  multiplication works with a unit.

 1pt is the base unit in MP (used if no dimension is given; probably
 stored as 65536sp (scaled point) units).

In the manual I only found bp for »big point«, which equal PostScript
points equaling 1/72 of an inch.

 Now if you use pure numerics for scale, such as 'xscaled 2', this is
 interpreted as '2pt' (or 2*65536sp). If you use any dimension, it is
 also converted into scaled points. All the same for MP.
 
 If I'm right this should all be the same (untested)
 
 xscaled 2
 xscaled 2pt

This gives the same result.

 xscaled (2*65536sp)

I could not test the above because the numbers got too big and MetaPost
complained.

 1 = 1pt = 65536sp

[…]


Thanks,

Paul


signature.asc
Description: This is a digitally signed message part
___
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] MetaPost: Confusion with `function()` and `xyscaled`

2011-10-23 Thread Peter Rolf
Am 23.10.2011 16:12, schrieb Paul Menzel:
 Am Freitag, den 21.10.2011, 18:08 +0200 schrieb Peter Rolf:
 Am 21.10.2011 17:26, schrieb Paul Menzel:
 
 Am Freitag, den 21.10.2011, 17:02 +0200 schrieb Peter Rolf:

 I agree, this is confusing on the first sight. But scaling is not meant
 as 'scaling to' a dimension. In fact is is just a simple multiplication.
 The reason why it seems to work this way with
 'fullsquare' and such predefined paths is, that they have a 'neutral'
 size/scale (bounding box size of filled path is (1pt,1pt)).

 So how can I find out what the dimension of the path of a function is?
 Not scaling it, it also looked pretty small, so I am guessing (1pt,1pt).

 I guess in this case its size is (10,log(10)) + pen size when drawn.
 
 That was it kind of. Probably the most of my confusion resulting from
 the use of the inverse function.
 
 So all in all the width is 1 – the x-coordinates seem to be scaled to
 the width of 1 – and the height is 10, as ten is the highest value.
 Therefore the width has to be multiplied with 10cm to get it to 10cm and
 since the height it 10 already multiplying it with 2cm gets it to 20cm.

I see. I must admit that I haven't looked deeper into function (never
used it).

If I want to test the bounding box of a graphic, I normally use a small
debugging macro (last code line of nearly all of my graphics). It simply
draws a small red frame at the bounding box borders. You can use the
'Measuring Tool' in Acrobat (also Reader?) or even better the 'Object
Inspector' to get the exact size.

minlinewidth:= .143pt;

def wirepen= pencircle scaled minlinewidth enddef ;

def drawbb =
drawoptions() ;
interim linejoin:= mitered;
draw (llcorner currentpicture) shifted ( .5minlinewidth,
.5minlinewidth)
--   (lrcorner currentpicture) shifted (-.5minlinewidth,
.5minlinewidth)
--   (urcorner currentpicture) shifted
(-.5minlinewidth,-.5minlinewidth)
--   (ulcorner currentpicture) shifted (
.5minlinewidth,-.5minlinewidth)
--   cycle
withpen wirepen withcolor red;
%  draw boundingbox currentpicture withpen wirepen withcolor red ; % was
not neutral!
enddef ;


 Multiplying such a path with (x,y) gives an object with size (1*x,1*y).
 In general: if the bounding box of an object has the size (a,b) and you
 scale it with (x,y), the resulting object has a size of (ax,by). That's
 all the magic.

 but if you use numbers with a unit than it should not be multiplied but
 expanded to that value, should not it? Otherwise I am unsure how
 multiplication works with a unit.

 1pt is the base unit in MP (used if no dimension is given; probably
 stored as 65536sp (scaled point) units).
 
 In the manual I only found bp for »big point«, which equal PostScript
 points equaling 1/72 of an inch.

It can't be helped, I always mix this up. :-D
It's 'bp' for MP and for Adobe products, and 'pt' for TeX. Ask me in a
few weeks and I can't give the correct answer.

 
 Now if you use pure numerics for scale, such as 'xscaled 2', this is
 interpreted as '2pt' (or 2*65536sp). If you use any dimension, it is
 also converted into scaled points. All the same for MP.

 If I'm right this should all be the same (untested)

 xscaled 2
 xscaled 2pt
 
 This gives the same result.
 
 xscaled (2*65536sp)
 
 I could not test the above because the numbers got too big and MetaPost
 complained.

My fault. In the meantime I have checked it and 'sp' is not a predefined
constant in MP (couldn't find it in the manual). Also never used it in MP.

 1 = 1pt = 65536sp
 
 […]
 
 
 Thanks,
 
 Paul
 
 
 
 ___
 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
___

Re: [NTG-context] MetaPost: Confusion with `function()` and `xyscaled`

2011-10-23 Thread Hans Hagen

On 23-10-2011 17:17, Peter Rolf wrote:

If I want to test the bounding box of a graphic, I normally use a small
debugging macro (last code line of nearly all of my graphics). It simply
draws a small red frame at the bounding box borders. You can use the
'Measuring Tool' in Acrobat (also Reader?) or even better the 'Object
Inspector' to get the exact size.

minlinewidth:= .143pt;

def wirepen= pencircle scaled minlinewidth enddef ;

def drawbb =
 drawoptions() ;
 interim linejoin:= mitered;
 draw (llcorner currentpicture) shifted ( .5minlinewidth,
.5minlinewidth)
 --   (lrcorner currentpicture) shifted (-.5minlinewidth,
.5minlinewidth)
 --   (urcorner currentpicture) shifted
(-.5minlinewidth,-.5minlinewidth)
 --   (ulcorner currentpicture) shifted (
.5minlinewidth,-.5minlinewidth

)

 --   cycle
 withpen wirepen withcolor red;
%  draw boundingbox currentpicture withpen wirepen withcolor red ; % was
not neutral!
enddef ;


draw boundingbox currentpicture enlarged -.5minlinewidth withpen wirepen 
withcolor red ;



My fault. In the meantime I have checked it and 'sp' is not a predefined
constant in MP (couldn't find it in the manual). Also never used it in MP.


1 = 1pt = 65536sp


sp's would overflow anyway

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
___


[NTG-context] metapost question

2011-10-21 Thread Hans van der Meer
I cannot find the answer to the following question in Knuth's Metafont book.
The following definition with a trailing text argument:

def mydef (expr a, b, c) text modifier =
if modifier = empty: 
else:
fi
enddef;

How can I do the switch on an empty or nonempty modifier argument? It is not a 
string because calling its length fails with an error.
I must do the switch, because fill modifier with an empty modifier gives 
horrible results.

Usage would be calls like:
  mydef(1,2,3) withcolor green; % with modifier text
  mydef(1,2,3); % without modifier text

Thanks in advance.
Hans van der Meer

___
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] metapost question

2011-10-21 Thread Peter Rolf
Am 21.10.2011 15:05, schrieb Hans van der Meer:
 I cannot find the answer to the following question in Knuth's Metafont book.
 The following definition with a trailing text argument:
 
 def mydef (expr a, b, c) text modifier =
   if modifier = empty: 

Have you already tried

if modifier =  :


   else:
   fi
 enddef;
 
 How can I do the switch on an empty or nonempty modifier argument? It is not 
 a string because calling its length fails with an error.
 I must do the switch, because fill modifier with an empty modifier gives 
 horrible results.
 
 Usage would be calls like:
   mydef(1,2,3) withcolor green; % with modifier text
   mydef(1,2,3); % without modifier text
 
 Thanks in advance.
 Hans van der Meer
 
 ___
 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
___


Re: [NTG-context] MetaPost: Confusion with `function()` and `xyscaled`

2011-10-21 Thread Paul Menzel
Dear Peter,


thank you for your answer.

Am Freitag, den 21.10.2011, 17:02 +0200 schrieb Peter Rolf:

 I agree, this is confusing on the first sight. But scaling is not meant
 as 'scaling to' a dimension. In fact is is just a simple multiplication.
 The reason why it seems to work this way with
 'fullsquare' and such predefined paths is, that they have a 'neutral'
 size/scale (bounding box size of filled path is (1pt,1pt)).

So how can I find out what the dimension of the path of a function is?
Not scaling it, it also looked pretty small, so I am guessing (1pt,1pt).

 Multiplying such a path with (x,y) gives an object with size (1*x,1*y).
 In general: if the bounding box of an object has the size (a,b) and you
 scale it with (x,y), the resulting object has a size of (ax,by). That's
 all the magic.

but if you use numbers with a unit than it should not be multiplied but
expanded to that value, should not it? Otherwise I am unsure how
multiplication works with a unit.

 I must admit that this wasn't clear to me before you came up with your
 question. So thanks for that. :-)

Thank you for your answer. As written above it is still not entirely
clear to me. I hope you can remedy my last confusion.


Thanks a lot,

Paul


signature.asc
Description: This is a digitally signed message part
___
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] metapost question

2011-10-21 Thread Meer, H. van der

On 21 okt. 2011, at 17:13, Peter Rolf wrote:

 Am 21.10.2011 15:05, schrieb Hans van der Meer:
 I cannot find the answer to the following question in Knuth's Metafont book.
 The following definition with a trailing text argument:
 
 def mydef (expr a, b, c) text modifier =
  if modifier = empty: 
 
 Have you already tried
 
if modifier =  :
 
 
  else:
  fi
 enddef;

I tried it now, but it doesn't work. Something like
if(TEXT4)
   =:;fi
in the error log. No, Metapost is not happy with this construct.

 
 How can I do the switch on an empty or nonempty modifier argument? It is not 
 a string because calling its length fails with an error.
 I must do the switch, because fill modifier with an empty modifier gives 
 horrible results.
 
 Usage would be calls like:
  mydef(1,2,3) withcolor green; % with modifier text
  mydef(1,2,3); % without modifier text

Thanks in advance.
Hans van der Meer


___
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] MetaPost: Confusion with `function()` and `xyscaled`

2011-10-21 Thread Peter Rolf
Am 21.10.2011 17:26, schrieb Paul Menzel:
 Dear Peter,
 
 
 thank you for your answer.
 
 Am Freitag, den 21.10.2011, 17:02 +0200 schrieb Peter Rolf:
 
 I agree, this is confusing on the first sight. But scaling is not meant
 as 'scaling to' a dimension. In fact is is just a simple multiplication.
 The reason why it seems to work this way with
 'fullsquare' and such predefined paths is, that they have a 'neutral'
 size/scale (bounding box size of filled path is (1pt,1pt)).
 
 So how can I find out what the dimension of the path of a function is?
 Not scaling it, it also looked pretty small, so I am guessing (1pt,1pt).

I guess in this case its size is (10,log(10)) + pen size when drawn.

 
 Multiplying such a path with (x,y) gives an object with size (1*x,1*y).
 In general: if the bounding box of an object has the size (a,b) and you
 scale it with (x,y), the resulting object has a size of (ax,by). That's
 all the magic.
 
 but if you use numbers with a unit than it should not be multiplied but
 expanded to that value, should not it? Otherwise I am unsure how
 multiplication works with a unit.

1pt is the base unit in MP (used if no dimension is given; probably
stored as 65536sp (scaled point) units).

Now if you use pure numerics for scale, such as 'xscaled 2', this is
interpreted as '2pt' (or 2*65536sp). If you use any dimension, it is
also converted into scaled points. All the same for MP.

If I'm right this should all be the same (untested)

xscaled 2
xscaled 2pt
xscaled (2*65536sp)

1 = 1pt = 65536sp


 I must admit that this wasn't clear to me before you came up with your
 question. So thanks for that. :-)
 
 Thank you for your answer. As written above it is still not entirely
 clear to me. I hope you can remedy my last confusion.
 
 
 Thanks a lot,
 
 Paul
 
 
 
 ___
 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
___


Re: [NTG-context] metapost question

2011-10-21 Thread Nicola
In article 0e2e620e-1148-41ad-9966-54a594fcc...@xs4all.nl,
 Hans van der Meer havdm...@xs4all.nl wrote:

 I cannot find the answer to the following question in Knuth's Metafont book.
 The following definition with a trailing text argument:
 
 def mydef (expr a, b, c) text modifier =
   if modifier = empty: 
   else:
   fi
 enddef;
 
 How can I do the switch on an empty or nonempty modifier argument? It is not 
 a string because calling its length fails with an error.

A text argument is a (more or less) arbitrary sequence of tokens—that is, 
loosely speaking, any “chunk” of MetaPost code.

 I must do the switch, because fill modifier with an empty modifier gives 
 horrible results.
 
 Usage would be calls like:
   mydef(1,2,3) withcolor green; % with modifier text
   mydef(1,2,3); % without modifier text

This is the best I could think of:

vardef emptytext?@# text t =
   (str @# = empty.sandwich)
enddef;

def mydef(expr a,b,c) text t =
   if begingroup emptytext? empty t sandwich endgroup:
  % t is empty
  draw unitsquare scaled 1cm;
   else:
  % t is not empty
  fill unitsquare scaled 1cm t ;
   fi;
enddef;

The key is the 'emptytext? empty t sandwich;' line: if t is empty, @# matches 
'empty.sandwich', otherwise it matches 'empty' possibly followed by something 
else (depending on what t actually is). The undelimited text parameter of 
emptytext? is needed to “swallow” whatever tokens are left (possibly none) 
after 
matching the implicit suffix parameter. Note that begingroup and endgroup are 
necessary in the if clause, otherwise emptytext?'s undelimited text parameter 
will match beyond the colon.

In practice, you should rename 'sandwich' to some token that you are pretty 
sure 
will never occur as the beginning of the text argument when you invoke mydef.

I'd be glad to hear about other solutions: this question has bugged me for some 
time…

Regards,
Nicola

___
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] metapost question

2011-10-21 Thread Meer, H. van der
Peter,

Thanks for trying to help. Because I solved the problem in another way you 
might be interested or even benefit from it.
The underlying problem was drawing a border around a picture of given 
dimensions. The border being either colored or left uncolored. The border color 
should come from a withcolor modifier, with the uncolored case done simply by 
leaving this out, for example:
borderinsideframe(u,v,2g);
and borderinsideframe(u,v,2g) withcolor red;

It turns out this can be done with an unfill. I learned that a bare unfill 
erases, but add a withcolor modifier and the effect is a coloring. Thus the 
trick is:

def bordercolorframe (expr w, h, off, clr) text modifier =
unfill (-off,-off)--(w+off,-off)--(w+off,h+off)--(-off,h+off)--cycle 
modifier;
fill (0,0)--(w,0)--(w,h)--(0,h)--cycle withcolor clr
enddef;

The omission of a semicolon after the last statement of the def allows one to 
add in a withcolor somecolor without triggering an error.

Hope this will be of use to someone.
Hans van der Meer

On 21 okt. 2011, at 17:13, Peter Rolf wrote:

 Am 21.10.2011 15:05, schrieb Hans van der Meer:
 I cannot find the answer to the following question in Knuth's Metafont book.
 The following definition with a trailing text argument:
 
 def mydef (expr a, b, c) text modifier =
  if modifier = empty: 
 
 Have you already tried
 
if modifier =  :
 
  else:
  fi
 enddef;
 
 How can I do the switch on an empty or nonempty modifier argument? It is not 
 a string because calling its length fails with an error.
 I must do the switch, because fill modifier with an empty modifier gives 
 horrible results.
 
 Usage would be calls like:
  mydef(1,2,3) withcolor green; % with modifier text
  mydef(1,2,3); % without modifier text
 
 Thanks in advance.
 Hans van der Meer


___
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] Metapost error

2011-10-19 Thread Lutz Haseloff
Hi Hans, Hi all,

with newest Context and luatex compiling following file:

\starttext
\startMPcode
draw externalfigure hacker.jpg xscaled 30mm yscaled 20mm ;
\stopMPcode
\stoptext

doesn't show the picture and gives an error message:


! Improper `addto'.
to be read again
   withpen
draw-...:also(EXPR0)else:doublepath(EXPR0)withpen
  .currentpen.fi._op_
to be read again
   ;
to be read again
   ;
* ...re hacker.jpg xscaled 30mm yscaled 20mm ;
   ;


metapost error: unknown, no error, terminal or log messages
metapost terminal: [1]


Thanks for any help

Lutz
___
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] Metapost error

2011-10-19 Thread luigi scarso
On Wed, Oct 19, 2011 at 1:34 PM, Lutz Haseloff
lutz.hasel...@googlemail.com wrote:
 Hi Hans, Hi all,

 with newest Context and luatex compiling following file:

 \starttext
 \startMPcode
 draw externalfigure hacker.jpg xscaled 30mm yscaled 20mm ;
 \stopMPcode
 \stoptext

 doesn't show the picture and gives an error message:


 ! Improper `addto'.
 to be read again
                   withpen
 draw-...:also(EXPR0)else:doublepath(EXPR0)withpen
                                                  .currentpen.fi._op_
 to be read again
                   ;
 to be read again
                   ;
 * ...re hacker.jpg xscaled 30mm yscaled 20mm ;
                                                   ;


 metapost         error: unknown, no error, terminal or log messages
 metapost         terminal: [1]


 Thanks for any help

 Lutz
hm, strange, it seems that
externalfigure is redefined
This is ok

\starttext
\startMPcode
def externalfigure primary filename =
if false :
rawtextext(\externalfigure[  filename  ])
else :
image (
addto currentpicture doublepath unitsquare
withprescript fg_name=  filename ;
)
% unitsquare
% withpen pencircle scaled 0
% withprescript fg_name=  filename
fi
enddef ;
draw externalfigure hacker.jpg xscaled 30mm yscaled 20mm ;
\stopMPcode
\stoptext

-- 
luigi
___
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] Metapost error

2011-10-19 Thread Lutz Haseloff
Works again with last nights beta, thanks.

2011/10/19 Lutz Haseloff lutz.hasel...@googlemail.com:
 Hi Hans, Hi all,

 with newest Context and luatex compiling following file:

 \starttext
 \startMPcode
 draw externalfigure hacker.jpg xscaled 30mm yscaled 20mm ;
 \stopMPcode
 \stoptext

 doesn't show the picture and gives an error message:


 ! Improper `addto'.
 to be read again
                   withpen
 draw-...:also(EXPR0)else:doublepath(EXPR0)withpen
                                                  .currentpen.fi._op_
 to be read again
                   ;
 to be read again
                   ;
 * ...re hacker.jpg xscaled 30mm yscaled 20mm ;
                                                   ;


 metapost         error: unknown, no error, terminal or log messages
 metapost         terminal: [1]


 Thanks for any help

 Lutz

___
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] Plotting a graph of a function f, like f(x) = e^x, with MetaPost

2011-10-13 Thread Hans Hagen

On 13-10-2011 02:30, Mojca Miklavec wrote:


Of course the user would have to make a conscious decision by enabling
this “beta” release.


And of course the user makes a conscious decision to either compile
from trunk if he wants the latest and greatest bugs and new features
or to wait patiently until Taco thinks the software is ready and
releases a beta.

I don't think that one extra week (or two or three or ... for that
matter) makes any difference.


Also, it's not a matter of enabling but more making a drastic move... 
there is a complete infrastructure for switching the underlying handling 
of numbers and if there are bugs in the common layer it will influence 
traditional mp methods too. As mplib is a core component of luatex/mkiv 
it is unlikely that there will be a beta that has not been tested by 
taco and me on a bunch of documents that we normally use for testing 
drastic changes.


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] Plotting a graph of a function f, like f(x) = e^x, with MetaPost

2011-10-13 Thread Alan Braslau
On Thu, Oct 13, 2011 at 02:30:07AM +0200, Mojca Miklavec wrote:
 
 MetaPost doesn't know erf and other obscure functions

Metapost could possibly be extended to provide all of the functions
in the standard math library. In fact, it would be nice if there be
some hook to `link' to additional functions, written in C or in Fortran,
for example. (I regularly use the complex error function.)
Maybe this could be possible in luatex, made available to metapost
through some communication pipe?

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] Plotting a graph of a function f, like f(x) = e^x, with MetaPost

2011-10-13 Thread luigi scarso
On Thu, Oct 13, 2011 at 9:59 AM, Alan Braslau alan.bras...@cea.fr wrote:

 On Thu, Oct 13, 2011 at 02:30:07AM +0200, Mojca Miklavec wrote:
 
  MetaPost doesn't know erf and other obscure functions

 Metapost could possibly be extended to provide all of the functions
 in the standard math library. In fact, it would be nice if there be
 some hook to `link' to additional functions, written in C or in Fortran,
 for example. (I regularly use the complex error function.)
 Maybe this could be possible in luatex, made available to metapost
 through some communication pipe?

 yes, just build a binding for the library (or use something else like
cinvoke)
http://www.gust.org.pl/bachotex/2011-en/presentations/Scarso_2_2011
pag 15 or so
If I recall correctly, I've built a binding for gsl too.

-- 
luigi
___
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] Setting style and color attributes of label in metapost

2011-10-13 Thread Wolfgang Schuster

Am 25.09.2011 um 02:43 schrieb Aditya Mahajan:

 I am writing a module which uses metapost in the background for drawing. I 
 wanted to create an interface for setting the style and color of metapost 
 labels but using \doset...attributes is not working.
 
 Here is an example:
 
 \definenamespace
  [test]
  [style=yes,
   name=test,
   command=yes,
   setup=yes]
 
 \definetest
  [blue]
  [color=blue, text=Blue]
 
 \definetest
  [two]
  [blue]
  [style=\bold, text=Two]
 
 \starttext
 \edef\currenttest{two}
 \startMPdrawing
  label.lft(\sometxt{\dosettestattributes{style}{color}
  \testparameter{text}}, (0,0)) ;

You can use the old \doattributes command which is expandable.

label.lft(\sometxt{\doattributes{\currenttesthash}{style}{color}{\testparameter{text}}},(0,0))
 ;

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] Plotting a graph of a function f, like f(x) = e^x, with MetaPost

2011-10-12 Thread luigi scarso
On Wed, Oct 12, 2011 at 12:45 AM, Paul Menzel
paulepan...@users.sourceforge.net wrote:
 Dear ConTeXt folks,


 I finally chose MetaPost/MetaFun [1] because of the native integration
 with ConTeXt and hopefully easy font handling. I want to use that
 throughout my document.

 Of course I hit the first problem. Wanting to draw a “simple” function f
 like f(x) = e^x, seems hard to accomplish. I guess I should stress that
 MetaPost does not have a high accuracy so it might not be the best
 solution [5].

 There seem to be quite a lot of solutions (mostly macros) on the Web for
 this problem so I am wondering if one of them is integrated in MetaFun.

 Here are some of my findings.

 1. Reading about the graph package by John D. Hobby [2] and which is
 also included in ConTeXt [3]. Especially I liked the automatic
 coordinate systems. The package seems to only be able to plot graphs
 with data points saved in files. So one solution would be to manually
 create data files with data points of the relevant function.

 2. There is an example in the Drexel Physics Wiki [4].

 3. Anthony Phan has also created some macros in his `mps` [5 (currently
 not accessible)].

 4. André Heck uses the macro packages `courbes` and `grille` from
 Jean-Michel Sarlat to show some nice examples in his tutorial »Learning
 Metapost by Doing« [6].


 So what do you suggest?
In MKIV   you can use Lua to make calculations in floating point, and
Metapost to draw the data.

-- 
luigi
___
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] Plotting a graph of a function f, like f(x) = e^x, with MetaPost

2011-10-12 Thread Paul Menzel
Dear Alan,


Am Mittwoch, den 12.10.2011, 07:36 +0200 schrieb Alan Braslau:

 Metapost can now perform calculations in double precision floating point.
 At this time, it is in the svn version and does not work yet as
 such integrated in ConTeXt (through mplib). Taco promises this for soon...

great to hear that. Just to clarify, with »now« you mean MetaPost v2, do
not you? Taco, I hope you get there without a lot of problems showing
up. If you need testers a good option would be to integrate that into
ConTeXt Standalone as an option.

 The graph package is pretty clever, and I am working on proposals on
 how to extend/rewrite this taking advantage of the new metapost
 handling of large and small numbers.

Perfect!

 To plot a function, you can create a path, as in
 path p ; p := 
   for i=0 upto 1000:
   hide (x := i/1000 ;) 
   if (i0) -- fi (x,exp(x))
   endfor ;
 gplot p ;

What module do I need for `gplot`?

Looking at the MetaFun manual [8] I found out MetaFun even provides a
macro `function` which probably does exactly what you do above with the
for loop.

draw function(2,x,x**(-0.5),1,10,1) xyscaled (2cm,2cm)
withpen pencircle scaled 5mm withcolor
transparent(1,.5,yellow) ;

 One proposal will be to make this even easier with new macros.

Another perfect!

One thing coming to my mind though that hopefully the wheel is not
reimplemented. I guess Gnuplot can do a lot already, but on the other
probably not as neat as Metapost when we want to color certain areas.


Thanks,

Paul


[8] http://www.pragma-ade.com/general/manuals/metafun-s.pdf


signature.asc
Description: This is a digitally signed message part
___
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] Plotting a graph of a function f, like f(x) = e^x, with MetaPost

2011-10-12 Thread Mojca Miklavec
On Thu, Oct 13, 2011 at 00:13, Paul Menzel wrote:
 Am Mittwoch, den 12.10.2011, 07:36 +0200 schrieb Alan Braslau:

 Metapost can now perform calculations in double precision floating point.
 At this time, it is in the svn version and does not work yet as
 such integrated in ConTeXt (through mplib). Taco promises this for soon...

 great to hear that. Just to clarify, with »now« you mean MetaPost v2, do
 not you?

No, 1.750. The version 2 is not quite ready yet, but the version 1.750
already deals with floating point numbers.

 Taco, I hope you get there without a lot of problems showing
 up. If you need testers a good option would be to integrate that into
 ConTeXt Standalone as an option.

It will become part of distribution as soon as it gets out, but Taco
was busy enough organizing conference and dozens of other things. Just
give him some time. I bet that he also wants to update documentation,
do final bugfixing etc. instead of just releasing a random snapshot.

 One thing coming to my mind though that hopefully the wheel is not
 reimplemented. I guess Gnuplot can do a lot already, but on the other
 probably not as neat as Metapost when we want to color certain areas.

Can you please specify your question more precisely?

Gnuplot terminal uses metapost output. Gnuplot has some support for
transparency, even though I'm not exactly sure if one can specify
transparent colors for lines, only for fills. But you can always
simply redefine line type colors to be transparent.

Gnuplot brings all kinds of other problems like dependency on external
tool. If you have enough time to create nice plots in metapost, it is
better to avoid external dependency as a general rule. But if you have
more questions about it, feel free to ask. I might be able to help
you. The ConTeXt terminal was almost included until developers
realized that they wanted me to throw away some code for handling
units and replace that code with something buggy (like size 10cm,10
- (10cm,10cm); size 10,10cm - (0.35cm,10cm) or (25.40cm,10.00cm)
depending on weather). Now I need to either rewrite part of my code or
rewrite part of core code or convince them why keeping the old code.

Mojca
___
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] Plotting a graph of a function f, like f(x) = e^x, with MetaPost

2011-10-12 Thread Paul Menzel
Am Donnerstag, den 13.10.2011, 00:28 +0200 schrieb Mojca Miklavec:
 On Thu, Oct 13, 2011 at 00:13, Paul Menzel wrote:
  Am Mittwoch, den 12.10.2011, 07:36 +0200 schrieb Alan Braslau:
 
  Metapost can now perform calculations in double precision floating point.
  At this time, it is in the svn version and does not work yet as
  such integrated in ConTeXt (through mplib). Taco promises this for soon...
 
  great to hear that. Just to clarify, with »now« you mean MetaPost v2, do
  not you?
 
 No, 1.750. The version 2 is not quite ready yet, but the version 1.750
 already deals with floating point numbers.

Thank you for the clarification/correction.

  Taco, I hope you get there without a lot of problems showing
  up. If you need testers a good option would be to integrate that into
  ConTeXt Standalone as an option.
 
 It will become part of distribution as soon as it gets out, but Taco
 was busy enough organizing conference and dozens of other things. Just
 give him some time. I bet that he also wants to update documentation,
 do final bugfixing etc. instead of just releasing a random snapshot.

Of course the user would have to make a conscious decision by enabling
this “beta” release. If people could test this and with the right
announcement I hope that some people would step up to test and
contribute by submitting bug reports or writing documentation.

  One thing coming to my mind though that hopefully the wheel is not
  reimplemented. I guess Gnuplot can do a lot already, but on the other
  probably not as neat as Metapost when we want to color certain areas.
 
 Can you please specify your question more precisely?

I meant coloring part of the area below a graph. For example if you look
at the graphic for Riemann sums on page 51 of the document »Learning
MetaPost by Doing« [6].

 Gnuplot terminal uses metapost output. Gnuplot has some support for
 transparency, even though I'm not exactly sure if one can specify
 transparent colors for lines, only for fills. But you can always
 simply redefine line type colors to be transparent.
 
 Gnuplot brings all kinds of other problems like dependency on external
 tool. If you have enough time to create nice plots in metapost, it is
 better to avoid external dependency as a general rule. But if you have
 more questions about it, feel free to ask. I might be able to help
 you.

Well my only question would be, why should someone use Gnuplot then? Is
it only for people already knowing Gnuplot? Or also because it is a
little less work to define the coordinate system and legends?

Otherwise MetaPost seems to include all functionality Gnuplot offers and
seems to offer more possibilities, does not it?

 The ConTeXt terminal was almost included until developers
 realized that they wanted me to throw away some code for handling
 units and replace that code with something buggy (like size 10cm,10
 - (10cm,10cm); size 10,10cm - (0.35cm,10cm) or (25.40cm,10.00cm)
 depending on weather). Now I need to either rewrite part of my code or
 rewrite part of core code or convince them why keeping the old code.

I remember a thread about that [9].


Thanks,

Paul


[6] http://staff.science.uva.nl/~heck/Courses/mptut.pdf
[9] http://www.ntg.nl/pipermail/ntg-context/2010/054196.html


signature.asc
Description: This is a digitally signed message part
___
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] Plotting a graph of a function f, like f(x) = e^x, with MetaPost

2011-10-12 Thread Mojca Miklavec
On Thu, Oct 13, 2011 at 01:19, Paul Menzel wrote:
 Am Donnerstag, den 13.10.2011, 00:28 +0200 schrieb Mojca Miklavec:
 On Thu, Oct 13, 2011 at 00:13, Paul Menzel wrote:
  Am Mittwoch, den 12.10.2011, 07:36 +0200 schrieb Alan Braslau:
 
  Metapost can now perform calculations in double precision floating point.
  At this time, it is in the svn version and does not work yet as
  such integrated in ConTeXt (through mplib). Taco promises this for soon...
 
  great to hear that. Just to clarify, with »now« you mean MetaPost v2, do
  not you?

 No, 1.750. The version 2 is not quite ready yet, but the version 1.750
 already deals with floating point numbers.

 Thank you for the clarification/correction.

  Taco, I hope you get there without a lot of problems showing
  up. If you need testers a good option would be to integrate that into
  ConTeXt Standalone as an option.

 It will become part of distribution as soon as it gets out, but Taco
 was busy enough organizing conference and dozens of other things. Just
 give him some time. I bet that he also wants to update documentation,
 do final bugfixing etc. instead of just releasing a random snapshot.

 Of course the user would have to make a conscious decision by enabling
 this “beta” release.

And of course the user makes a conscious decision to either compile
from trunk if he wants the latest and greatest bugs and new features
or to wait patiently until Taco thinks the software is ready and
releases a beta.

I don't think that one extra week (or two or three or ... for that
matter) makes any difference.

 If people could test this and with the right
 announcement I hope that some people would step up to test and
 contribute by submitting bug reports or writing documentation.

If people could test LaTeX 3 ... they would most certainly send bug
reports and write docs.

There will be more than enough time for testing before version 2 is
out. Those who want to help writing documentation are already free to
do so. The code already works.

  One thing coming to my mind though that hopefully the wheel is not
  reimplemented. I guess Gnuplot can do a lot already, but on the other
  probably not as neat as Metapost when we want to color certain areas.

 Can you please specify your question more precisely?

 I meant coloring part of the area below a graph. For example if you look
 at the graphic for Riemann sums on page 51 of the document »Learning
 MetaPost by Doing« [6].

I'm not sure how to draw discrete function, but you can try out the following:

set style fill solid border -1
f(x)=(x-5)*sin(x)-cos(x)+2

plot [1:7] f(x) w filledcurve y1=0,\
'-' using 1:(f($1)) w boxes lt 0, f(x) lt -1 lw 3
1.5
2.5
3.5
4.5
5.5
6.5
e

(But of course you need to draw everything else as well.)

 Gnuplot terminal uses metapost output. Gnuplot has some support for
 transparency, even though I'm not exactly sure if one can specify
 transparent colors for lines, only for fills. But you can always
 simply redefine line type colors to be transparent.

 Gnuplot brings all kinds of other problems like dependency on external
 tool. If you have enough time to create nice plots in metapost, it is
 better to avoid external dependency as a general rule. But if you have
 more questions about it, feel free to ask. I might be able to help
 you.

 Well my only question would be, why should someone use Gnuplot then? Is
 it only for people already knowing Gnuplot? Or also because it is a
 little less work to define the coordinate system and legends?

It is much less work to define and draw coordinate system, choose the
right units, draw logarithmic plots, parse input data, (past tense: do
arithmetics with numbers above 4000), ...

 Otherwise MetaPost seems to include all functionality Gnuplot offers and
 seems to offer more possibilities, does not it?

MetaPost doesn't know erf and other obscure functions, it wasn't able
to calculate with big numbers and it is very inconvenient to parse
input data. With gnuplot you get fast plotting, data parsing, range
guessing, function calculations ... all for free, but you have
slightly less flexibility in drawing. For me the most important part
is that I have to use gnuplot for inspecting the data anyway (I would
never use metapost to quickly inspect whether my measurement went fine
or not) and then I just copy-paste the function call. The trade-off is
still in favour of gnuplot, in particular since the quality is
acceptable and I don't have any special needs and extra time to do
fancy stuff with plots. What I really miss in Gnuplot is 3D support,
but that one is not covered in MetaPost either.

 I remember a thread about that [9].

That was not the same. The last context-terminal-was-almost-included
was something recent (less than a month ago).

Mojca
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http

[NTG-context] Plotting a graph of a function f, like f(x) = e^x, with MetaPost

2011-10-11 Thread Paul Menzel
Dear ConTeXt folks,


I finally chose MetaPost/MetaFun [1] because of the native integration
with ConTeXt and hopefully easy font handling. I want to use that
throughout my document.

Of course I hit the first problem. Wanting to draw a “simple” function f
like f(x) = e^x, seems hard to accomplish. I guess I should stress that
MetaPost does not have a high accuracy so it might not be the best
solution [5].

There seem to be quite a lot of solutions (mostly macros) on the Web for
this problem so I am wondering if one of them is integrated in MetaFun.

Here are some of my findings.

1. Reading about the graph package by John D. Hobby [2] and which is
also included in ConTeXt [3]. Especially I liked the automatic
coordinate systems. The package seems to only be able to plot graphs
with data points saved in files. So one solution would be to manually
create data files with data points of the relevant function.

2. There is an example in the Drexel Physics Wiki [4].

3. Anthony Phan has also created some macros in his `mps` [5 (currently
not accessible)].

4. André Heck uses the macro packages `courbes` and `grille` from
Jean-Michel Sarlat to show some nice examples in his tutorial »Learning
Metapost by Doing« [6].


So what do you suggest?


Thanks,

Paul


[1] http://www.ntg.nl/pipermail/ntg-context/2011/058527.html
[2] http://tug.org/docs/metapost/mpgraph.pdf
[3] http://wiki.contextgarden.net/Metapost
[4] http://einstein.drexel.edu/liki/index.php/Metapost#Graphing_Functions
[5] http://www-math.univ-poitiers.fr/~phan/downloads/metapost/statsman.pdf
[6] http://staff.science.uva.nl/~heck/Courses/mptut.pdf


signature.asc
Description: This is a digitally signed message part
___
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] Plotting a graph of a function f, like f(x) = e^x, with MetaPost

2011-10-11 Thread Paul Menzel
Dear ConTeXt folks,


Am Mittwoch, den 12.10.2011, 00:45 +0200 schrieb Paul Menzel:
 Dear ConTeXt folks,
 
 
 I finally chose MetaPost/MetaFun [1] because of the native integration
 with ConTeXt and hopefully easy font handling. I want to use that
 throughout my document.
 
 Of course I hit the first problem. Wanting to draw a “simple” function f
 like f(x) = e^x, seems hard to accomplish. I guess I should stress that
 MetaPost does not have a high accuracy so it might not be the best
 solution [5].
 
 There seem to be quite a lot of solutions (mostly macros) on the Web for
 this problem so I am wondering if one of them is integrated in MetaFun.
 
 Here are some of my findings.

I just want to add that there seems to be work going on in ConTeXt to
solve these issues as the talk at this years ConTeXt User Meeting of
Alan Braslau suggests [7].

 1. Reading about the graph package by John D. Hobby [2] and which is
 also included in ConTeXt [3]. Especially I liked the automatic
 coordinate systems. The package seems to only be able to plot graphs
 with data points saved in files. So one solution would be to manually
 create data files with data points of the relevant function.
 
 2. There is an example in the Drexel Physics Wiki [4].
 
 3. Anthony Phan has also created some macros in his `mps` [5 (currently
 not accessible)].
 
 4. André Heck uses the macro packages `courbes` and `grille` from
 Jean-Michel Sarlat to show some nice examples in his tutorial »Learning
 Metapost by Doing« [6].
 
 
 So what do you suggest?


Thanks,

Paul


 [1] http://www.ntg.nl/pipermail/ntg-context/2011/058527.html
 [2] http://tug.org/docs/metapost/mpgraph.pdf
 [3] http://wiki.contextgarden.net/Metapost
 [4] http://einstein.drexel.edu/liki/index.php/Metapost#Graphing_Functions
 [5] http://www-math.univ-poitiers.fr/~phan/downloads/metapost/statsman.pdf
 [6] http://staff.science.uva.nl/~heck/Courses/mptut.pdf
[7] 
http://meeting.contextgarden.net/2011/talks/day1_06_alan_plotting/BassangeBraslau.pdf


signature.asc
Description: This is a digitally signed message part
___
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] Plotting a graph of a function f, like f(x) = e^x, with MetaPost

2011-10-11 Thread Mojca Miklavec
On Wed, Oct 12, 2011 at 00:45, Paul Menzel wrote:
 Dear ConTeXt folks,

 I finally chose MetaPost/MetaFun [1] because of the native integration
 with ConTeXt and hopefully easy font handling. I want to use that
 throughout my document.

 Of course I hit the first problem. Wanting to draw a “simple” function f
 like f(x) = e^x, seems hard to accomplish. I guess I should stress that
 MetaPost does not have a high accuracy so it might not be the best
 solution [5].

 So what do you suggest?

To wait for next metapost beta (or compile the version in trunk by
yourself; however you might also need to change ConTeXt a bit, so that
it will call metapost with the right parameters).

http://meeting.contextgarden.net/2011/talks/day1_09_taco_metapost/mp2talk.pdf

Mojca
___
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] Plotting a graph of a function f, like f(x) = e^x, with MetaPost

2011-10-11 Thread Alan Braslau
Paul,

Metapost can now perform calculations in double precision floating point.
At this time, it is in the svn version and does not work yet as
such integrated in ConTeXt (through mplib). Taco promises this for soon...

The graph package is pretty clever, and I am working on proposals on
how to extend/rewrite this taking advantage of the new metapost
handling of large and small numbers.

To plot a function, you can create a path, as in
path p ; p := 
for i=0 upto 1000:
hide (x := i/1000 ;) 
if (i0) -- fi (x,exp(x))
endfor ;
gplot p ;

One proposal will be to make this even easier with new macros.

Alan

On Wed, Oct 12, 2011 at 12:45:12AM +0200, Paul Menzel wrote:
 Dear ConTeXt folks,
 
 
 I finally chose MetaPost/MetaFun [1] because of the native integration
 with ConTeXt and hopefully easy font handling. I want to use that
 throughout my document.
 
 Of course I hit the first problem. Wanting to draw a “simple” function f
 like f(x) = e^x, seems hard to accomplish. I guess I should stress that
 MetaPost does not have a high accuracy so it might not be the best
 solution [5].
 
 There seem to be quite a lot of solutions (mostly macros) on the Web for
 this problem so I am wondering if one of them is integrated in MetaFun.
 
 Here are some of my findings.
 
 1. Reading about the graph package by John D. Hobby [2] and which is
 also included in ConTeXt [3]. Especially I liked the automatic
 coordinate systems. The package seems to only be able to plot graphs
 with data points saved in files. So one solution would be to manually
 create data files with data points of the relevant function.
 
 2. There is an example in the Drexel Physics Wiki [4].
 
 3. Anthony Phan has also created some macros in his `mps` [5 (currently
 not accessible)].
 
 4. André Heck uses the macro packages `courbes` and `grille` from
 Jean-Michel Sarlat to show some nice examples in his tutorial »Learning
 Metapost by Doing« [6].
 
 
 So what do you suggest?
 
 
 Thanks,
 
 Paul
 
 
 [1] http://www.ntg.nl/pipermail/ntg-context/2011/058527.html
 [2] http://tug.org/docs/metapost/mpgraph.pdf
 [3] http://wiki.contextgarden.net/Metapost
 [4] http://einstein.drexel.edu/liki/index.php/Metapost#Graphing_Functions
 [5] http://www-math.univ-poitiers.fr/~phan/downloads/metapost/statsman.pdf
 [6] http://staff.science.uva.nl/~heck/Courses/mptut.pdf



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


-- 
Alan Braslau
CEA DSM-IRAMIS-SPEC
CNRS URA 2464
Orme des Merisiers
91191 Gif-sur-Yvette cedex FRANCE
tel: +33 1 69 08 73 15
fax: +33 1 69 08 87 86
mailto:alan.bras...@cea.fr
___
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] metapost not adding picture

2011-10-09 Thread Meer, H. van der
I have this question on the implementation of metapost.
The following program ends in an error:

\startMPpage
picture v;
draw origin--(1cm,1cm);
v = currentpicture;
clearit;
draw (1cm,0)--(0,1cm);
currentpicture := currentpicture + v;
\stopMPpage

The error is: ! Not implemented: (picture)+(picture).
Yet Knuth's metafont book in Chapter 13 tells me, quote: Pictures can be added 
or subtracted;
Is the current metafont implementation lacking this feature? Will it be 
implemented in the near future?

Hans van der Meer

___
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] metapost not adding picture

2011-10-09 Thread Peter Rolf
Am 09.10.2011 22:01, schrieb Meer, H. van der:
 I have this question on the implementation of metapost.
 The following program ends in an error:
 
 \startMPpage
 picture v;
 draw origin--(1cm,1cm);
 v = currentpicture;
 clearit;
 draw (1cm,0)--(0,1cm);
 currentpicture := currentpicture + v;

use

addto currentpicture also v;

 \stopMPpage
 
 The error is: ! Not implemented: (picture)+(picture).
 Yet Knuth's metafont book in Chapter 13 tells me, quote: Pictures can be 
 added or subtracted;
 Is the current metafont implementation lacking this feature? Will it be 
 implemented in the near future?

Just another notation, that's all.

Best wishes, 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
___


[NTG-context] nocolor in MetaPost

2011-10-05 Thread Hans van der Meer
Is there a value that can be given to a color variable in MetaPost that might 
function as some sort of no color. Thus something like NULL in the 
programming language C.

Hans van der Meer

___
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] nocolor in MetaPost

2011-10-05 Thread Hans Hagen

On 5-10-2011 19:56, Hans van der Meer wrote:

Is there a value that can be given to a color variable in MetaPost that might function as 
some sort of no color. Thus something like NULL in the programming language C.


not that I know of


-
  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] nocolor in MetaPost

2011-10-05 Thread Alan Braslau
On Wed, Oct 05, 2011 at 08:46:22PM +0200, Hans Hagen wrote:
 On 5-10-2011 19:56, Hans van der Meer wrote:
  Is there a value that can be given to a color variable in MetaPost that 
  might function as some sort of no color. Thus something like NULL in the 
  programming language C.
 
 not that I know of

What exactly do you want to do?
Can
if known mycolor : fi
be of any help?
___
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] metapost to pdf on the fly

2011-10-03 Thread Meer, H. van der
I am afraid I don't completely understand this. Doing:
\startbuffer[fig-1]
\startMPcode
draw origin-(20,0) .. origin+(0,20) .. origin+(20,0) .. origin+(0,-20) .. cycle 
withcolor darkgreen;
label(textext(Test),origin);
\stopMPcode
\stopbuffer
\starttext
\processMPbuffer[fig-1]
\stoptext

I get the error:
! Argument of \dostartMPpositiongraphic has an extra }.

system   tex  error on line 8 in file onfly.tex: Argument of  ...

 1 \startbuffer[fig-1]
 2 \startMPcode
 3 draw origin-(20,0) .. origin+(0,20) .. origin+(20,0) .. origin+(0,-20) 
.. cycle withcolor darkgreen;
 4 label(textext(Test),origin);
 5 \stopMPcode
 6 \stopbuffer
 7 \starttext
 8   \processMPbuffer[fig-1]
..

inserted text 
\par 
to be read again 
   }
\processMPgraphic ...le ;\!!es , \MPaskedfigure )}
  }\egroup \placeMPgraphic \...
\doprocessMPbuffer ...(\currentMPgraphicname )}}
  \endMPgraphicgroup 
l.8 \processMPbuffer[fig-1]


Hans van der Meer


On 29 sep. 2011, at 21:21, Aditya Mahajan wrote:

 On Thu, 29 Sep 2011, Meer, H. van der wrote:
 
 I would like to generate metapost figures in separate pdf-files (in some 
 convenient directory, they are reused elsewhere). This as part of a project 
 structure. I know that on a separate run such a pdf can be generated with:
 context figurefile running on input
 \input some-metapost-inclusions
 \starttext
 \startMPpage
 ..
 \stopMPpage
 \stoptext
 
 But the idea is to do it on the fly while typesetting a project (using 
 mode=*first to prevent further iterations):
 ..
 \component figurefile
 ..
 And in the figurefile
 \startcomponent figurefile
 \environment some-metapost-inclusions
 \starttext
 .. BUT THEN WHAT?
 
 As such it is not sufficient for the goal proposed. Can this be done at all?
 
 What I usually do is have all the figures in separate buffers:
 
 \startenvironment figures
 
 \startbuffer[fig-1]
 ...
 \stopbuffer
 
 \stopenvironment
 
 and in the main file
 
 \environment figures
 
 \starttext
 
 \processMPbuffer[fig-1]
 
 \stoptext
 
 This way you can also combine multiple figures using
 
 \processMPbuffer[fig-common,fig-1]
 
 etc.
 
 The metapost processing is fast enough that there is no noticable speed 
 difference.
 
 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
 ___

___
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] metapost to pdf on the fly

2011-10-03 Thread Wolfgang Schuster

Am 03.10.2011 um 09:05 schrieb Meer, H. van der:

 I am afraid I don't completely understand this. Doing:
 \startbuffer[fig-1]
 \startMPcode
 draw origin-(20,0) .. origin+(0,20) .. origin+(20,0) .. origin+(0,-20) .. 
 cycle withcolor darkgreen;
 label(textext(Test),origin);
 \stopMPcode
 \stopbuffer
 \starttext
 \processMPbuffer[fig-1]
 \stoptext

This works:

\startbuffer[fig-1]
draw (-20,0) .. (0,20) .. (20,0) .. (0,-20) .. cycle withcolor 
\MPcolor{darkgreen};
label(textext(Test),origin);
\stopbuffer

\starttext
\processMPbuffer[fig-1]
\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
___


Re: [NTG-context] metapost to pdf on the fly

2011-10-03 Thread Meer, H. van der
Thanks, this works indeed. But I hoped to be able to produce in this manner at 
one stroke a series of separate figures, each in its own pdf file. Or is this 
an impossible action?

Hans van der Meer

On 3 okt. 2011, at 09:09, Wolfgang Schuster wrote:

 
 Am 03.10.2011 um 09:05 schrieb Meer, H. van der:
 
 I am afraid I don't completely understand this. Doing:
 \startbuffer[fig-1]
 \startMPcode
 draw origin-(20,0) .. origin+(0,20) .. origin+(20,0) .. origin+(0,-20) .. 
 cycle withcolor darkgreen;
 label(textext(Test),origin);
 \stopMPcode
 \stopbuffer
 \starttext
 \processMPbuffer[fig-1]
 \stoptext
 
 This works:
 
 \startbuffer[fig-1]
 draw (-20,0) .. (0,20) .. (20,0) .. (0,-20) .. cycle withcolor 
 \MPcolor{darkgreen};
 label(textext(Test),origin);
 \stopbuffer
 
 \starttext
 \processMPbuffer[fig-1]
 \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
 ___

___
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] metapost to pdf on the fly

2011-10-03 Thread Mojca Miklavec
On Mon, Oct 3, 2011 at 10:12, Meer, H. van der wrote:
 Thanks, this works indeed. But I hoped to be able to produce in this manner 
 at one stroke a series of separate figures, each in its own pdf file. Or is 
 this an impossible action?

Then create file.mp with

beginfig(1);
... metapost code ...
endfig;
beginfig(2);
... metapost code ...
endfig;
beginfig(3);
... metapost code ...
endfig;
end.

and process it with mptopdf file.mp

Mojca
___
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] metapost to pdf on the fly

2011-09-29 Thread Meer, H. van der
I would like to generate metapost figures in separate pdf-files (in some 
convenient directory, they are reused elsewhere). This as part of a project 
structure. I know that on a separate run such a pdf can be generated with:
context figurefile running on input
  \input some-metapost-inclusions
  \starttext
  \startMPpage
  ..
  \stopMPpage
  \stoptext

But the idea is to do it on the fly while typesetting a project (using 
mode=*first to prevent further iterations):
..
\component figurefile
..
And in the figurefile
  \startcomponent figurefile
  \environment some-metapost-inclusions
  \starttext
  .. BUT THEN WHAT?

As such it is not sufficient for the goal proposed. Can this be done at all?

Hans van der Meer

___
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] metapost to pdf on the fly

2011-09-29 Thread Aditya Mahajan

On Thu, 29 Sep 2011, Meer, H. van der wrote:


I would like to generate metapost figures in separate pdf-files (in some 
convenient directory, they are reused elsewhere). This as part of a project 
structure. I know that on a separate run such a pdf can be generated with:
context figurefile running on input
 \input some-metapost-inclusions
 \starttext
 \startMPpage
 ..
 \stopMPpage
 \stoptext

But the idea is to do it on the fly while typesetting a project (using 
mode=*first to prevent further iterations):
..
\component figurefile
..
And in the figurefile
 \startcomponent figurefile
 \environment some-metapost-inclusions
 \starttext
 .. BUT THEN WHAT?

As such it is not sufficient for the goal proposed. Can this be done at all?


What I usually do is have all the figures in separate buffers:

\startenvironment figures

\startbuffer[fig-1]
...
\stopbuffer

\stopenvironment

and in the main file

\environment figures

\starttext

\processMPbuffer[fig-1]

\stoptext

This way you can also combine multiple figures using

\processMPbuffer[fig-common,fig-1]

etc.

The metapost processing is fast enough that there is no noticable speed 
difference.


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
___


[NTG-context] Setting style and color attributes of label in metapost

2011-09-24 Thread Aditya Mahajan
I am writing a module which uses metapost in the background for drawing. I 
wanted to create an interface for setting the style and color of metapost 
labels but using \doset...attributes is not working.


Here is an example:

\definenamespace
  [test]
  [style=yes,
   name=test,
   command=yes,
   setup=yes]

\definetest
  [blue]
  [color=blue, text=Blue]

\definetest
  [two]
  [blue]
  [style=\bold, text=Two]

\starttext
\edef\currenttest{two}
\startMPdrawing
  label.lft(\sometxt{\dosettestattributes{style}{color}
  \testparameter{text}}, (0,0)) ;
\stopMPdrawing

\edef\currenttest{blue}
\startMPdrawing
  label.lft(\sometxt{\dosettestattributes{color}{style}
  \testparameter{text}}, (2cm,0)) ;
\stopMPdrawing
\MPdrawingdonetrue\getMPdrawing
\stoptext

Notice that the first label has the same style as the last label. This is 
happening because \doset..attributes is defined as an unexpandable macro. 
I can get around this by setting the value of \currenttest inside the 
\sometxt{...} argument. Something like:


\def\dosometxt#1#2%
{\normaldosometxt{#1}%
  {\def\noexpand\letterbackslash currenttest{\currenttest #2}}}


Surely, there should be a more direct way of achieving this?

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
___


[NTG-context] MetaPost visibly drawing at 0pt

2011-09-19 Thread Meer, H. van der
I used to put an invisible frame around figures in MetaPost by setting a pen 
scaled at 0pt. That left no trace, but defined the area.
However I (now) see a thin line drawn by code:

pickup pencircle scaled 0pt;
draw origin--(w,h);

Did I always mis this or has something changed? For example a roundoff away 
from zero in MetaPost?
By the way I am typesetting through ConTeXT with \startMPpage … \stopMPpage.

Hans van der Meer

___
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] MetaPost visibly drawing at 0pt

2011-09-19 Thread Peter Rolf
Am 19.09.2011 14:31, schrieb Meer, H. van der:
 I used to put an invisible frame around figures in MetaPost by setting a pen 
 scaled at 0pt. That left no trace, but defined the area.
 However I (now) see a thin line drawn by code:
   
   pickup pencircle scaled 0pt;
   draw origin--(w,h);
 
 Did I always mis this or has something changed? For example a roundoff away 
 from zero in MetaPost?
 By the way I am typesetting through ConTeXT with \startMPpage … \stopMPpage.

Donno (as I never used this method). Better use

'setbounds currentpicture to' ..
.. 'unitsquare xyscaled(w,h);'
.. 'OverlayBox;'
.. whatever is squared;

at the end of your graphic. This simply sets the bounding box of you
graphic and has no unwanted side effects.

 Hans van der Meer
 
 ___
 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
___

Re: [NTG-context] metapost question (bug?)

2011-07-22 Thread Peter Rolf
Am 21.07.2011 23:21, schrieb Alan Braslau:
 On Thu, Jul 21, 2011 at 05:39:48PM +0200, Peter Rolf wrote:
 use

 p2 := p0  p1;

 the reason for the 'unexpected' output is, that point 1 and 2 of the
 path p2 are equal. keep in mind that drawing with an asymmetrical pen
 has its own (complex) rules.
 
 Thank you -- I forgot about the path operator 

same here (i had to browse the metapost manual for the operator) :-)

 (Funny thing, though, that the problem shows up with point 0. I would also 
 think that having two consecutive identical points, although poor style, 
 should not cause problems as it does.)

i guess it has to do with the fact, that 'drawing' with non circular
pens always results in a *filled* path. metapost is calculating new
points for the shape, instead of just storing the given path points and
the pen size (like in a normal pencircle draw). and if a filled path is
intersecting with itself, funny things can happen. well, most times not
that funny (because unwanted).

probably not the best example (not drawn, no special pen), but it gives
a first impression of what is going on.

\startTEXpage
\startMPcode
path p[];
p0 := unitcircle scaled 10cm;
p1 := p0 scaled .5;

p2 := p0 -- reverse(p1) -- cycle;
fill p2;
\stopMPcode
\stopTEXpage

depending on their direction (clockwise or counter clockwise) and
location (intersection or not) such path 'cycles' are cleared or filled.
with this trick you are able to produce punches as in the glyphs of O
or e.

if you like and have the time you can debug your example (simply add a
loop that draws all points and labels them). you will then see the
difference between a drawn (pencircle) and a 'drawn' (non circular pen)
path. ;-)

 And yes, the use of an asymmetrical pen is indeed the whole point of this 
 figure -- I am using metapost to achieve very easily an effect, conceptually 
 very simple, that a colleague has not been able to produce using Adobe 
 Illustrator.
 
 Thank you again for helping out.

my pleasure.

Peter

 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
 ___
 

___
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] metapost question (bug?)

2011-07-21 Thread Alan Braslau
Hello,

I have a question for metapost specialists:

I am looking for some sort of effect, built upon a zig-zag line.
The first graphic in the minimal example below is as I would expect.
The second graphic seems to be drawn without the point at (0,0).
(Ignore the asymmetry at the end of the path in the 2nd, this
is to be expected in this minimal example.)

Is the result correct or is this a bug?

Alan



\starttext

\startTEXpage
\startMPcode
u := 1mm ;

path p[] ;
p0 := ((0,0)--(1,0)) rotated 45 scaled 20u ;
pickup pensquare scaled 10u rotated 45 ;
draw p0 withcolor blue ;
pickup pensquare yscaled 2u xscaled 5u rotated 45 ;
draw p0 withcolor yellow ;
pickup pencircle scaled .1u ;
draw p0 ;
\stopMPcode
\stopTEXpage

\startTEXpage
\startMPcode
p1 := ((0,0)--(sqrt(2),0)) rotated -30 scaled 20u
shifted point infinity of p0 ;
p2 := p0--p1 ;

pickup pensquare scaled 10u rotated 45 ;
draw p2 withcolor blue ;
pickup pensquare yscaled 2u xscaled 5u rotated 45 ;
draw p2 withcolor yellow ;
pickup pencircle scaled .1u ;
draw p2 ;
\stopMPcode
\stopTEXpage

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


Re: [NTG-context] metapost question (bug?)

2011-07-21 Thread luigi scarso
On Thu, Jul 21, 2011 at 4:39 PM, Alan Braslau alan.bras...@cea.fr wrote:
 Hello,

 I have a question for metapost specialists:

 I am looking for some sort of effect, built upon a zig-zag line.
 The first graphic in the minimal example below is as I would expect.
 The second graphic seems to be drawn without the point at (0,0).
 (Ignore the asymmetry at the end of the path in the 2nd, this
 is to be expected in this minimal example.)

 Is the result correct or is this a bug?

 Alan



 \starttext

 \startTEXpage
 \startMPcode
        u := 1mm ;

        path p[] ;
        p0 := ((0,0)--(1,0)) rotated 45 scaled 20u ;
        pickup pensquare scaled 10u rotated 45 ;
        draw p0 withcolor blue ;
        pickup pensquare yscaled 2u xscaled 5u rotated 45 ;
        draw p0 withcolor yellow ;
        pickup pencircle scaled .1u ;
        draw p0 ;
 \stopMPcode
 \stopTEXpage

 \startTEXpage
 \startMPcode
        p1 := ((0,0)--(sqrt(2),0)) rotated -30 scaled 20u
                shifted point infinity of p0 ;
        p2 := p0--p1 ;

        pickup pensquare scaled 10u rotated 45 ;
        draw p2 withcolor blue ;
        pickup pensquare yscaled 2u xscaled 5u rotated 45 ;
        draw p2 withcolor yellow ;
        pickup pencircle scaled .1u ;
        draw p2 ;
 \stopMPcode
 \stopTEXpage

 \stoptext
You are shifting by a certain amount : what is the net effect of
shifted point infinity of p0 ?

-- 
luigi
___
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] metapost question (bug?)

2011-07-21 Thread Peter Rolf
Am 21.07.2011 16:53, schrieb luigi scarso:
 On Thu, Jul 21, 2011 at 4:39 PM, Alan Braslau alan.bras...@cea.fr wrote:
 Hello,

 I have a question for metapost specialists:

 I am looking for some sort of effect, built upon a zig-zag line.
 The first graphic in the minimal example below is as I would expect.
 The second graphic seems to be drawn without the point at (0,0).
 (Ignore the asymmetry at the end of the path in the 2nd, this
 is to be expected in this minimal example.)

 Is the result correct or is this a bug?

 Alan



 \starttext

 \startTEXpage
 \startMPcode
u := 1mm ;

path p[] ;
p0 := ((0,0)--(1,0)) rotated 45 scaled 20u ;
pickup pensquare scaled 10u rotated 45 ;
draw p0 withcolor blue ;
pickup pensquare yscaled 2u xscaled 5u rotated 45 ;
draw p0 withcolor yellow ;
pickup pencircle scaled .1u ;
draw p0 ;
 \stopMPcode
 \stopTEXpage

 \startTEXpage
 \startMPcode
p1 := ((0,0)--(sqrt(2),0)) rotated -30 scaled 20u
shifted point infinity of p0 ;
p2 := p0--p1 ;

use

p2 := p0  p1;

the reason for the 'unexpected' output is, that point 1 and 2 of the
path p2 are equal. keep in mind that drawing with an asymmetrical pen
has its own (complex) rules.


pickup pensquare scaled 10u rotated 45 ;
draw p2 withcolor blue ;
pickup pensquare yscaled 2u xscaled 5u rotated 45 ;
draw p2 withcolor yellow ;
pickup pencircle scaled .1u ;
draw p2 ;
 \stopMPcode
 \stopTEXpage

 \stoptext
 You are shifting by a certain amount : what is the net effect of
 shifted point infinity of p0 ?
 
afaik simply the last point of p0.
___
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] metapost question (bug?)

2011-07-21 Thread Alan Braslau
On Thu, Jul 21, 2011 at 05:39:48PM +0200, Peter Rolf wrote:
 use
 
 p2 := p0  p1;
 
 the reason for the 'unexpected' output is, that point 1 and 2 of the
 path p2 are equal. keep in mind that drawing with an asymmetrical pen
 has its own (complex) rules.

Thank you -- I forgot about the path operator 

(Funny thing, though, that the problem shows up with point 0. I would also 
think that having two consecutive identical points, although poor style, should 
not cause problems as it does.)

And yes, the use of an asymmetrical pen is indeed the whole point of this 
figure -- I am using metapost to achieve very easily an effect, conceptually 
very simple, that a colleague has not been able to produce using Adobe 
Illustrator.

Thank you again for helping out.

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] Trouble making basic MetaPost graphics using ConTeXt Minimals

2011-07-15 Thread Mojca Miklavec
I'm not able to reproduce the problem, but there is one weird thing
(unrelated to your problem):

The original file test.mp is copied to test.mp.keep and a new file
test.mp is created with a newer timestamp and two additional blank
lines at the end.

So repeating the compilation hundred times leads me to a file with 200
blank lines at the end and I cannot recover the original file back (in
each run the .keep file is overwritten).

Hans - would it be possible to fix that please?

Mojca
___
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] Trouble making basic MetaPost graphics using ConTeXt Minimals

2011-07-15 Thread Hans Hagen

On 15-7-2011 9:13, Mojca Miklavec wrote:

I'm not able to reproduce the problem, but there is one weird thing
(unrelated to your problem):

The original file test.mp is copied to test.mp.keep and a new file
test.mp is created with a newer timestamp and two additional blank
lines at the end.

So repeating the compilation hundred times leads me to a file with 200
blank lines at the end and I cannot recover the original file back (in
each run the .keep file is overwritten).

Hans - would it be possible to fix that please?


hm, I though that it was fixed, was a catch for older mp's

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] Trouble making basic MetaPost graphics using ConTeXt Minimals

2011-07-15 Thread Hans Hagen

On 15-7-2011 3:04, luigi scarso wrote:


Building the file using texexec --mptex test.mp all three graphics


how about context --mp test.mp ?

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] Trouble making basic MetaPost graphics using ConTeXt Minimals

2011-07-15 Thread Mojca Miklavec
On Fri, Jul 15, 2011 at 09:44, Hans Hagen pra...@wxs.nl wrote:
 On 15-7-2011 3:04, luigi scarso wrote:

 Building the file using texexec --mptex test.mp all three graphics

 how about context --mp test.mp ?

 context --mp test

metapost| loading 'metafun.mp' (experimental metapost version
two)Error in mp.find_file:
...text/tex/texmf-context/tex/context/base/mlib-run.lua:75: attempt to
call field 'checktexts' (a nil value)

metapost| processing 'test.mp'Error in mp.find_file:
...text/tex/texmf-context/tex/context/base/mlib-run.lua:75: attempt to
call field 'checktexts' (a nil value)
Error in mp.find_file:
...text/tex/texmf-context/tex/context/base/mlib-run.lua:75: attempt to
call field 'checktexts' (a nil value)

metapost| error: Warning: cannot open font map file pdftex.map
Warning: cannot open font map file lm-math.map

(Please type a command or say `end')

[1]
(Please type a command or say `end')

[2]
(Please type a command or say `end')

! You can only use `btex' or `verbatimtex' in a file.
*   label.lrt(btex
 $\sqrt x$ etex, (3,sqrt 3)*u);
! Missing `,' has been inserted.
to be read again
   sqrt
*   label.lrt(btex $\sqrt
x$ etex, (3,sqrt 3)*u);
___
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] Trouble making basic MetaPost graphics using ConTeXt Minimals

2011-07-15 Thread luigi scarso
On Fri, Jul 15, 2011 at 9:47 AM, Mojca Miklavec
mojca.miklavec.li...@gmail.com wrote:
 On Fri, Jul 15, 2011 at 09:44, Hans Hagen pra...@wxs.nl wrote:
 On 15-7-2011 3:04, luigi scarso wrote:

 Building the file using texexec --mptex test.mp all three graphics

 how about context --mp test.mp ?

 context --mp test

 metapost        | loading 'metafun.mp' (experimental metapost version
 two)Error in mp.find_file:
 ...text/tex/texmf-context/tex/context/base/mlib-run.lua:75: attempt to
 call field 'checktexts' (a nil value)

 metapost        | processing 'test.mp'Error in mp.find_file:
 ...text/tex/texmf-context/tex/context/base/mlib-run.lua:75: attempt to
 call field 'checktexts' (a nil value)
 Error in mp.find_file:
 ...text/tex/texmf-context/tex/context/base/mlib-run.lua:75: attempt to
 call field 'checktexts' (a nil value)

 metapost        | error: Warning: cannot open font map file pdftex.map
 Warning: cannot open font map file lm-math.map

 (Please type a command or say `end')

 [1]
 (Please type a command or say `end')

 [2]
 (Please type a command or say `end')

 ! You can only use `btex' or `verbatimtex' in a file.
 *   label.lrt(btex
                     $\sqrt x$ etex, (3,sqrt 3)*u);
 ! Missing `,' has been inserted.
 to be read again
                   sqrt
 *   label.lrt(btex $\sqrt
                            x$ etex, (3,sqrt 3)*u);

Even with mkiv metapost depends to pdftex ora some files from pdftex.
That's way  \startMPpage..\stopMPpage is better.

-- 
luigi
___
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] Trouble making basic MetaPost graphics using ConTeXt Minimals

2011-07-15 Thread Hans Hagen

On 15-7-2011 9:47, Mojca Miklavec wrote:

On Fri, Jul 15, 2011 at 09:44, Hans Hagenpra...@wxs.nl  wrote:

On 15-7-2011 3:04, luigi scarso wrote:


Building the file using texexec --mptex test.mp all three graphics


how about context --mp test.mp ?



context --mp test


metapost| loading 'metafun.mp' (experimental metapost version
two)Error in mp.find_file:
text/tex/texmf-context/tex/context/base/mlib-run.lua:75: attempt to
call field 'checktexts' (a nil value)


hm, i'll look into it later

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] Trouble making basic MetaPost graphics using ConTeXt Minimals

2011-07-15 Thread Kevin D. Robbins
On Thu, Jul 14, 2011 at 7:04 PM, luigi scarso luigi.sca...@gmail.com wrote:
 This is one of the preferrred way to deal with metapost in mkiv
 \starttext
 \startMPpage
 numeric u;
  u = 1cm;
  draw (0,2u)--(0,0)--(4u,0);
  pickup pencircle scaled 1pt;
  draw (0,0){up}
   for i=1 upto 8: ..(i/2,sqrt(i/2))*u endfor;
  label.lrt(btex $\sqrt x$ etex, (3,sqrt 3)*u);
  label.bot(btex $x$ etex, (2u,0));
  label.lft(btex $y$ etex, (0,u));
 \stopMPpage
 \stoptext

 It's ok with latest minimals

Thanks, Luigi. This works on my system, too.

Kevin
___
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] Trouble making basic MetaPost graphics using ConTeXt Minimals

2011-07-15 Thread Kevin D. Robbins
On Fri, Jul 15, 2011 at 1:13 AM, Mojca Miklavec
mojca.miklavec.li...@gmail.com wrote:
 The original file test.mp is copied to test.mp.keep and a new file
 test.mp is created with a newer timestamp and two additional blank
 lines at the end.


I hadn't noticed this yesterday, but I see the same behavior, but only
when building with texexec --mptex test.mp.

Kevin
___
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] Trouble making basic MetaPost graphics using ConTeXt Minimals

2011-07-14 Thread Kevin D. Robbins
Using a fresh install of ConTeXt Minimals today (ConTeXt version
2011.07.14 16:09, luatex version beta-0.70.1-2011051918) I am trying
to build the following MetaPost graphics:

---8--- file: test.mp
fontmapfile =lm-math.map ;

beginfig(1)
  draw fullcircle scaled 3cm ;
endfig ;

beginfig(2) ;
  fill fullcircle scaled 5cm withcolor red ;
endfig ;

beginfig(3);
  numeric u;
  u = 1cm;
  draw (0,2u)--(0,0)--(4u,0);
  pickup pencircle scaled 1pt;
  draw (0,0){up}
for i=1 upto 8: ..(i/2,sqrt(i/2))*u endfor;
  label.lrt(btex $\sqrt x$ etex, (3,sqrt 3)*u);
  label.bot(btex $x$ etex, (2u,0));
  label.lft(btex $y$ etex, (0,u));
endfig;

end .
---8---

Building the file using mpost test.mp I get the following:

This is MetaPost, version 1.504 (kpathsea version 6.0.0)
(mpost.mp (/opt/tools/ConTeXt/beta/tex/texmf/metapost/base/plain.mp
Preloading the plain mem file, version 1.004))
(./test.mp{pdftex.map}{lm-math.map} [1]
[2]/opt/tools/ConTeXt/beta/tex/texmf-context/scripts/context/ruby/base/switch.rb:570:in
`locateseries': undefined method `each' for tex:String
(NoMethodError)
from 
/opt/tools/ConTeXt/beta/tex/texmf-context/scripts/context/ruby/base/switch.rb:397:in
`block in expand'
from 
/opt/tools/ConTeXt/beta/tex/texmf-context/scripts/context/ruby/base/switch.rb:392:in
`each'
from 
/opt/tools/ConTeXt/beta/tex/texmf-context/scripts/context/ruby/base/switch.rb:392:in
`expand'
from 
/opt/tools/ConTeXt/beta/tex/texmf-context/scripts/context/ruby/texexec.rb:789:in
`main'


 test.mp
 test.mpx
! Unable to make mpx file.
l.18   label.lrt(btex
  $\sqrt x$ etex, (3,sqrt 3)*u);
2 output files written: test.1 .. test.2

The first two graphics are produced correctly, but there is no output
for the third graphic with the labels.

Building the file using texexec --mptex test.mp all three graphics
are produced, but the label $\sqrt x$ does not produce the square root
symbol.

Am I doing something obviously wrong? Can anyone reproduce this?

Thanks,

Kevin
___
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] Trouble making basic MetaPost graphics using ConTeXt Minimals

2011-07-14 Thread luigi scarso
On Fri, Jul 15, 2011 at 2:59 AM, Kevin D. Robbins
krobb...@alumni.princeton.edu wrote:
 Using a fresh install of ConTeXt Minimals today (ConTeXt version
 2011.07.14 16:09, luatex version beta-0.70.1-2011051918) I am trying
 to build the following MetaPost graphics:

 ---8--- file: test.mp
 fontmapfile =lm-math.map ;

 beginfig(1)
  draw fullcircle scaled 3cm ;
 endfig ;

 beginfig(2) ;
  fill fullcircle scaled 5cm withcolor red ;
 endfig ;

 beginfig(3);
  numeric u;
  u = 1cm;
  draw (0,2u)--(0,0)--(4u,0);
  pickup pencircle scaled 1pt;
  draw (0,0){up}
    for i=1 upto 8: ..(i/2,sqrt(i/2))*u endfor;
  label.lrt(btex $\sqrt x$ etex, (3,sqrt 3)*u);
  label.bot(btex $x$ etex, (2u,0));
  label.lft(btex $y$ etex, (0,u));
 endfig;

 end .
 ---8---

 Building the file using mpost test.mp I get the following:

 This is MetaPost, version 1.504 (kpathsea version 6.0.0)
 (mpost.mp (/opt/tools/ConTeXt/beta/tex/texmf/metapost/base/plain.mp
 Preloading the plain mem file, version 1.004))
 (./test.mp{pdftex.map}{lm-math.map} [1]
 [2]/opt/tools/ConTeXt/beta/tex/texmf-context/scripts/context/ruby/base/switch.rb:570:in
 `locateseries': undefined method `each' for tex:String
 (NoMethodError)
        from 
 /opt/tools/ConTeXt/beta/tex/texmf-context/scripts/context/ruby/base/switch.rb:397:in
 `block in expand'
        from 
 /opt/tools/ConTeXt/beta/tex/texmf-context/scripts/context/ruby/base/switch.rb:392:in
 `each'
        from 
 /opt/tools/ConTeXt/beta/tex/texmf-context/scripts/context/ruby/base/switch.rb:392:in
 `expand'
        from 
 /opt/tools/ConTeXt/beta/tex/texmf-context/scripts/context/ruby/texexec.rb:789:in
 `main'


 test.mp
 test.mpx
 ! Unable to make mpx file.
 l.18   label.lrt(btex
                      $\sqrt x$ etex, (3,sqrt 3)*u);
 2 output files written: test.1 .. test.2

 The first two graphics are produced correctly, but there is no output
 for the third graphic with the labels.

 Building the file using texexec --mptex test.mp all three graphics
 are produced, but the label $\sqrt x$ does not produce the square root
 symbol.

 Am I doing something obviously wrong? Can anyone reproduce this?

 Thanks,

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

This is one of the preferrred way to deal with metapost in mkiv
\starttext
\startMPpage
numeric u;
 u = 1cm;
 draw (0,2u)--(0,0)--(4u,0);
 pickup pencircle scaled 1pt;
 draw (0,0){up}
   for i=1 upto 8: ..(i/2,sqrt(i/2))*u endfor;
 label.lrt(btex $\sqrt x$ etex, (3,sqrt 3)*u);
 label.bot(btex $x$ etex, (2u,0));
 label.lft(btex $y$ etex, (0,u));
\stopMPpage
\stoptext

It's ok with latest minimals
-- 
luigi
___
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] cmyk in metapost

2011-06-26 Thread Hans van der Meer
I must be doing something wrong. But what?

Relevant part of Metapost code:

numeric Cb, Cr, Y, T, temp, graycolors;
Cb := 0; Cr := 1; Y = 2; T := 3; graycolors := 15;
numeric colors[][];for i = 0 upto graycolors:
temp := (graycolors - i) / graycolors;
colors[i][Cb] := temp; colors[i][Cr] := temp; colors[i][Y]  := temp; 
colors[i][T]  := 0;
endfor
def colorvalue(expr v) =
cmyk(colors[v][Cb], colors[v][Cr], colors[v][Y], colors[v][T])
enddef;
for i = 0 upto 15:
mycmyk[i] := colorvalue(i);
endfor
Used with drawdot... withcolor mycymk[index];

The error from metapost is in the generation of the cmyk colors:
! terminal:  (redpart mycmyk0,greenpart mycmyk0,bluepart mycmyk0)
 (1,1,1,0)
! Equation cannot be performed (color=cmykcolor).
to be read again 
   ;
for(0) mycmyk[(EXPR0)]:=colorvalue((EXPR0));
   ENDFOR
startsubtitle-...:mycmyk[i]:=colorvalue(i);endfor
 
Strangely the following does work without problems:
drawdot... withcolor colorvalue(index);

I got the code from the Metafun manual. Beta from ConTeXt  ver: 2011.03.28 
01:03 MKIV download.
Something obvious I am overlooking?

Hans van der Meer
___
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] cmyk in metapost

2011-06-26 Thread Hans Hagen

On 26-6-2011 1:51, Hans van der Meer wrote:

I must be doing something wrong. But what?

Relevant part of Metapost code:

I got the code from the Metafun manual. Beta from ConTeXt  ver: 2011.03.28 
01:03 MKIV download.
Something obvious I am overlooking?


cmykcolor is another datatype in mp than color


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


[NTG-context] mtxrun --script metapost and fonts?

2011-05-10 Thread Michal Kvasnička
Hallo.

I've got a problem with metapost - pdf translation. Since mptopdf is still
broken in the last ConTeXt beta in the minimal distribution, I use mtxrun
--script metapost --split. It works well, only it ignores font setting. My
code is like this:


verbatimtex
  \definetypeface [times] [rm] [serif] [times] [default] [encoding=ec]
  \definetypeface [times] [mm] [math] [times] [default]  [encoding=ec]
  \setupbodyfont [times,10pt]
etex;

beginfig(1);
  label(btex A $a_i$ etex,origin);
endfig;

end.


I believe that the code in the verbatimtex ... etex environment should
switch the major font to Times (it works with texexec --mptex). However,
it is ignored by the mtxrun --script metapost --split script---Computer
Modern in 12pt is used instead of Times in 10pt. Is there any way around
this problem? Many thanks for your help.

Best wishes,
Michal Kvasnicka
___
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] mtxrun --script metapost and fonts?

2011-05-10 Thread Hans Hagen

On 10-5-2011 3:29, Michal Kvasnička wrote:

Hallo.

I've got a problem with metapost -  pdf translation. Since mptopdf is still
broken in the last ConTeXt beta in the minimal distribution, I use mtxrun
--script metapost --split. It works well, only it ignores font setting. My
code is like this:


verbatimtex
   \definetypeface [times] [rm] [serif] [times] [default] [encoding=ec]
   \definetypeface [times] [mm] [math] [times] [default]  [encoding=ec]
   \setupbodyfont [times,10pt]
etex;

beginfig(1);
   label(btex A $a_i$ etex,origin);
endfig;

end.


just do:

\definetypeface [times] [rm] [serif] [times] [default] [encoding=ec]
\definetypeface [times] [mm] [math] [times] [default]  [encoding=ec]
\setupbodyfont [times,10pt]

\startMPpage
   label(btex A $a_i$ etex,origin);
\stopMPpage


I believe that the code in the verbatimtex ... etex environment should
switch the major font to Times (it works with texexec --mptex). However,
it is ignored by the mtxrun --script metapost --split script---Computer
Modern in 12pt is used instead of Times in 10pt. Is there any way around
this problem? Many thanks for your help.


in mkiv verbatimtex is not supported (useless)

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
___

[NTG-context] Context and metapost: using \frac

2011-04-26 Thread mat

Hi

I am using context to run a metapost graph. I am however unable to 
insert a label with \frac, since this is not pure Tex but Latex. This 
seems to be a known problem for metapost:
-Seems for metapost only,  one should add %latex 
(http://ryanmlayer.wordpress.com/tag/metapost/).
-I saw also one post where it was mentione done should add 
//\setupMPpage[offset=1pt] 
//(http://www.tug.org/pipermail/pdftex/2001-March/000429.html). I tried, 
but did not work however...


Any idea how I should do? Find below minimal example, that does not work 
on my computer when compiling with context...


Thanks!!

Matthieu

\starttext

\setupMPpage[offset=1pt]

\switchtobodyfont[10pt]

% Beginning MetaPost graphic
\startMPpage

label.top(btex 1.4 etex scaled   1.00, (10, 10));

label.top(btex $\sigma_t$ etex scaled   1.00, (0, 10));

label.top(btex $\displaystyle \frac{\sigma_t}{a}$ etex scaled   1.00, 
(1, 1));


\stopMPpage

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

Re: [NTG-context] Context and metapost: using \frac

2011-04-26 Thread Hans Hagen

On 25-4-2011 8:33, mat wrote:


Any idea how I should do? Find below minimal example, that does not work
on my computer when compiling with context...


best use textext ...

label.top(textext(1.4)scaled 1.00, 
(10, 10));
label.top(textext($\sigma_t$) scaled 1.00, (0, 
10));
label.top(textext($\displaystyle \frac{\sigma_t}{a}$) scaled 1.00, (1, 
1));


works ok (only tested mkiv); also \frac is available in context

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] Context and metapost: using \frac

2011-04-26 Thread Matthieu Stigler

Dear Hans

Thanks for your quick answer! I was however not able to produce the 
graph with the textext code... Should I actually then use another 
compiler? I tried with context and texexec (I thought texexec is the 
compiler for mkiv, right? I'm on linux ubuntu).


I saw also that, as you mention, context has a \frac: 
http://wiki.contextgarden.net/Math_with_newmat


I tried then to simply add \usemodule[newmat] and compile with context, 
but did not work... Code below, error message below below...


Thanks a  lot

Matthieu

Code:

\usemodule[newmat]

\starttext

\setupMPpage[offset=1pt]

\switchtobodyfont[10pt]

% Beginning MetaPost graphic

\startMPpage

label.top(btex 1.4 etex scaled   1.00, (10, 10));

label.top(btex $\sigma_t$ etex scaled   1.00, (0, 10));

label.top(btex $\displaystyle \frac{\sigma_t}{a}$ etex scaled   1.00, (0, 10));

\stopMPpage

\stoptext





Error:

! Math error: parameter \Umathfraction_del_size\displaystyle is not set.
l.3 ...t{411}{$\displaystyle \frac {\sigma _t}{a}$
  }
inserted text ...ore.mp ; fi ; ;;;]===], false)}

\processMPgraphic ...s ;\!!es , \MPaskedfigure )}}
  \egroup \global 
\MPinstanc...

\dostartMPpage ...??mg ][#1]\processMPgraphic {#3}
  \dostopfittingpage
l.26 \stopMPpage




Le 26/04/2011 10:37, Hans Hagen a écrit :

On 25-4-2011 8:33, mat wrote:


Any idea how I should do? Find below minimal example, that does not work
on my computer when compiling with context...


best use textext ...

label.top(textext(1.4)scaled 1.00, 
(10, 10));
label.top(textext($\sigma_t$) scaled 1.00, 
(0, 10));
label.top(textext($\displaystyle \frac{\sigma_t}{a}$) scaled 1.00, 
(1, 1));


works ok (only tested mkiv); also \frac is available in context

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] Context and metapost: using \frac

2011-04-26 Thread Hans Hagen

On 26-4-2011 12:02, Matthieu Stigler wrote:

Dear Hans

Thanks for your quick answer! I was however not able to produce the
graph with the textext code... Should I actually then use another
compiler? I tried with context and texexec (I thought texexec is the
compiler for mkiv, right? I'm on linux ubuntu).


no, use the 'context' command as texexec is for mkii


I saw also that, as you mention, context has a \frac:
http://wiki.contextgarden.net/Math_with_newmat


indeed, \frac is already there for a long time (ams compatible command)

btw, in mkiv there is no m-newmath


I tried then to simply add \usemodule[newmat] and compile with context,
but did not work... Code below, error message below below...
! Math error: parameter \Umathfraction_del_size\displaystyle is not set.
l.3 ...t{411}{$\displaystyle \frac {\sigma _t}{a}$
}
inserted text ...ore.mp ; fi ; ;;;]===], false)}


make sure that a font is loaded that has math before \starttext is seen

(try with \setupbodyfont[palatino] at the top of your file)

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
___


<    3   4   5   6   7   8   9   10   11   12   >