Re: [NTG-context] colors in pgf within context

2008-02-18 Thread Jesse Alama
Hi Aditya,

Thanks for the help -- I think I now see why there is such trouble with
colors in pgf and context.  It looks like one can systematically
transform LaTeX-like PGF examples of \color into ConTeXt examples.

The reason why this came up is that I'm trying to go through Till
Tantau's Example for Karl's Students tutorial in the PGF/TikZ manual.
Has anyone managed to ConTeXt-ify that example?  The closest that I've come is

  \usemodule[tikz]
  \setupcolors[state=start]
  \starttext
  \starttikzpicture
[scale=3,
 line cap=thin,
 %Styles
 axes/.style=, 
 important line/.style={very thick}, 
 information text/.style={rounded corners,fill=red!10,inner sep=1ex}] 
  % Local definitions 
  \def\costhirty{0.8660256} 
  % The graphic 
  \draw[help lines,step=0.5cm] (-1.4,-1.4) grid (1.4,1.4); 
  \draw (0,0) circle (1cm); 
  \startscope[axes] 
  \draw[-] (-1.5,0) -- (1.5,0) node[right] {$x$} coordinate(x axis); 
  \draw[-] (0,-1.5) -- (0,1.5) node[above] {$y$} coordinate(y axis); 
  \foreach \x/\xtext in {-1, -.5/-\frac{1}{2}, 1} 
  \draw[xshift=\x cm] (0pt,1pt) -- (0pt,-1pt) node[below,fill=white] 
{$\xtext$}; 
  \foreach \y/\ytext in {-1, -.5/-\frac{1}{2}, .5/\frac{1}{2}, 1} 
  \draw[yshift=\y cm] (1pt,0pt) -- (-1pt,0pt) node[left,fill=white] {$\ytext$}; 
  \stopscope
  \filldraw[fill=green!20,draw=green!50!black] (0,0) -- (3mm,0pt) 
arc(0:30:3mm); 
  \draw (15:2mm) node[green!50!black] {$\alpha$}; 
  \draw[important line,red] 
  (30:1cm) -- node[left=1pt,fill=white] {$\sin \alpha$} (30:1cm |- x axis); 
  
  \draw[important line,orange!80!black] (1,0) -- node[right=1pt,fill=white] { 
  $\displaystyle \tan \alpha \color[black]{=}
  \frac{\color[red]{\sin \alpha}}{\color[blue]{\cos \alpha}}$} 
  (intersection of 0,0--30:1cm and 1,0--1,1) coordinate (t); 
  \draw (0,0) -- (t); 
  \draw[xshift=1.85cm] 
  node[right,text width=6cm,information text] 
  { 
  The \color[green!50!black]{angle $\alpha$} is $30^\circ$ in the 
  example ($\pi/6$ in radians). The \color[red]{sine of 
  $\alpha$}, which is the height of the red line, is 
  \startformula
  \color[red]{\sin \alpha} = 1/2.
  \stopformula
  By the Theorem of Pythagoras ... 
  }; 
  \stoptikzpicture
  \stoptext

The example features some \definecolor's which I just did away with
(sadly) by simply substituting their defining values for their
occurences.  (This is unfortunate, but perhaps necessary until some
other mechanism is produced.)  The problem is that the text box to the
right of the picture is supposed to be colored, and with rounded
corners.  But the box is missing.  Look at p. 20 of

  http://altermundus.com/downloads/pgfmanual_cvs.pdf
  
to see what I mean.  Also, the phrase angle $\alpha$ is supposed to be
in a kind of green, but that's not working either.  What might be
happening?

Thanks,

Jesse

Aditya Mahajan [EMAIL PROTECTED] writes:

 I am CCing to the context list also.

 On Mon, 18 Feb 2008, Jesse Alama wrote:

 Hi Aditya,

 I recently came across a thread on the PGF users mailing list in which
 you mention some problems with ConTeXt, PGF and colors.  For example:

  http://article.gmane.org/gmane.comp.tex.pgf.user/38

 Have these issues beein resolved for your?  I just downloaded PFG 1.18
 from the modules part of the contextgarden, installed it, and, when
 trying to compile the following example PGF code

  \starttikzpicture[scale=3]
\clip (-2,-0.2) rectangle (2,0.8);
\draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4);
\filldraw[fill=green!20,draw=green!50!black] (0,0) -- (3mm,0mm) arc
(0:30:3mm) -- cycle;
\draw[-] (-1.5,0) -- (1.5,0) coordinate (x axis);
\draw[-] (0,-1.5) -- (0,1.5) coordinate (y axis);
\draw (0,0) circle (1cm);

\draw[very thick,red]
  (30:1cm) -- node[left=1pt,fill=white] {$\sin \alpha$} (30:1cm |- x 
 axis);
\draw[very thick,blue]
  (30:1cm |- x axis) -- node[below=2pt,fill=white] {$\cos \alpha$} (0,0);
\draw[very thick,orange]  (1,0) -- node [right=1pt,fill=white]
  {$\displaystyle \tan \alpha \color{black}=
\frac{{\color[red]\sin \alpha}}{{\color[blue]\cos \alpha}}$}
  (intersection of 0,0--30:1cm and 1,0--1,1) coordinate (t);

\draw (0,0) -- (t);
\foreach \x/\xtext in {-1, -0.5/-\frac{1}{2}, 1}
\draw (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north,fill=white] 
 {$\xtext$};
\foreach \y/\ytext in {-1, -0.5/-\frac{1}{2}, 0.5/\frac{1}{2}, 1}
\draw (1pt,\y cm) -- (-1pt,\y cm) node[anchor=east,fill=white] {$\ytext$};
  \stoptikzpicture

 (which is taken from the PGF manual), I get

  ! Use of \color doesn't match its definition.
  [EMAIL PROTECTED] ...{$\displaystyle \tan \alpha \color {
black}= \frac {{\color 
 {re...

  [EMAIL PROTECTED]@[EMAIL PROTECTED] ...mmand [EMAIL PROTECTED]
[EMAIL PROTECTED] [EMAIL 
 PROTECTED]@[EMAIL PROTECTED]@...

  [EMAIL PROTECTED]@[EMAIL PROTECTED] [EMAIL PROTECTED]@onpath

Re: [NTG-context] ConTeXt-ifying Kile

2008-01-02 Thread Matija Šuklje
OK, it's been a fun day's work, but here's the current working version of 
the context.cwl file.

What it does include:
* all the commands with all the fields mentioned on texshow.contextgarden.net
* the rest of the commands that I used from the list Idris sent me are 
currently commented out, until I find out they're valid (although not on 
texshow)
* all the fields have short descriptions
* all the \start* commands end with appropriate \stop* commands
* some of the fields (where it was simple to do it) use a '|' character as a 
separator inside fields

What it does not include:
* a syntax completely as Kile's README.cwl would want to have (especially 
because of my misuse of \start* \stop* in the same command and Mojca's 
separator suggestion)
* a completely coherent and Kile-valid syntax is still missing, although as 
it is, the file is usable
* some commands are commented out, as mentioned above

Installation:
copy or link the file to /usr/share/apps/kile/complete/tex/ (or the 
appropriate kile/complete/tex/ directory) and add context.cwl in Kile's 
settings under Kile-Complete-TeX/LaTeX

I hope anyone finds it useful and that I manage to get it working 
perfectly/validly soon.


Cheers,
Matija

-- 
gsm: +386 41 849 552
e-mail: [EMAIL PROTECTED]
www: http://matija.suklje.name

aim: hookofsilver
icq: 110183360
jabber/g-talk: [EMAIL PROTECTED]
msn: [EMAIL PROTECTED]
yahoo: matija_suklje
# ConTeXt commands
# Matija silverhook Šuklje, 02. Jan. 2008 — [EMAIL PROTECTED]
# URL: todo

\about{text}[reference]
\adaptlayout[number][dimensions]
\adding[size]
# \aftersplitstring
# \and
\appendix[references]{text}
# \appendtoks
# \AR
\arg{text}
\at{text}{text}[reference]
\atpage[reference]
\background
# \bbox
# \beforesplitstring
# \begstrut
\blackrule[settings]
\blackrules[settings]
\blank[size]
# \blockquote
\bookmark[name]{text}
# \bTABLE
# \bTABLEbody
# \bTABLEfoot
# \bTABLEhead
# \bTABLEnext
# \bTD
# \bTH
# \bTR
\but[reference]
\button[settings]{text}[references]
\bypassblocks[names][names]
\CAP{text}
\Cap{text}
\cap{text}
\Caps{text}
\chapter[references]{text}
\Character{text}
\character{text}
\Characters{text}
\characters{text}
\chem{text}{text}{text}
\clip[settings]{text}
\clonefield[name][names][name][names]
\color[text{text}
\column
# \commalistelement
\comment[name][settings]{text}
\comparecolorgroup[name]
\comparepalet[name]
\completecombinedlist[name][settings]
\completelistoffloats
\completelistofsorts
\completelistofsynonyms
\completeregister[settings]
# \component
# \ConTeXt
# \Context
# \convertargument
# \convertcommand
\convertnumber{text}{text}
\copyfield[name][names]
\correctwhitespace{text}
# \countXMLchildren
\coupledocument[name][file][name]
\coupledregister[text]{text}
\couplemarking[name][name]
\couplepage[names][options]
\couplepaper[name]
\coupleregister[name]
\crlf
\currentdate[syntax]
\currentheadnumber
\date[date][syntax]
\decouplemarking[name]
# \decrement
\define[number]\command{text}
\defineblank[name][settings]
\defineblock[name]
\definebodyfont[font size][type][files]
\definebodyfontenvironment[font size][dimensions]
\definebuffer[name]
# \definecollector
\definecolor[name]{colour values}
\definecolorgroup[name][colour model][colour values]
\definecombinedlist[name][list][settings]
\defineconversion[name][command]
\definedescription[name][settings]
# \definedfont
\defineenumeration[names][name][settings]
# \defineexternalfigure
\definefield[reference][widget type][setup name][names][initial content]
\definefieldstack[name][names][settings]
\definefiguresymbol[name][text][settings]
\definefloat[singular][plural]
\definefont[name][file]
# \definefontsynonym
\defineframed[name][settings]
# \defineframedcontent
\defineframedtext[name][settings]
\definehead[name][section]
# \definehspace
\defineindenting[name][settings]
\defineinteractionmenu[position|names][options and settings]
\defineinteractionmenu[position|name][position|name][settings]
\definelabel[name][text and options]
# \definelayer
# \definelayerpreset
# \definelayout
\definelist[name][name][settings]
\definelogo[name][position][position][command][state]
# \definemainfield
\definemakeup[name][settings]
\definemarking[name][name]
# \definemeasure
# \defineoutput[name][specials]
\defineoverlay[names][command]
# \definepagebreak
\definepalet[name][name]
\definepapersize[name][dimenstions]
\defineparagraphs[name][options and settings]
\defineprofile[names][names]
\defineprogram[name][text][text]
# \definepushbutton
# \definepushsymbol
\definerawfont[name][file][settings]
\definereference[name][references]
\definereferenceformat[name][options]
\definereferencelist[name][settings]
\defineregister[singular][plural]
\definerule[name][settings]
\definesection[name]
\definesectionblock[name][settings]
\definesorting[singular][plural][command]
\definestartstop[name][commands]
\definesubfield[name][name][names]
\definesymbol[name][text]
\definesynonyms[singular][plural][command][command]
\definetabletemplate[name][text][text][text

Re: [NTG-context] Images centered on page

2007-11-24 Thread Wolfgang Schuster
On Fri, 23 Nov 2007 22:32:46 -0700
Idris Samawi Hamid [EMAIL PROTECTED] wrote:

 On Fri, 23 Nov 2007 12:30:48 -0700, Wolfgang Schuster  
 [EMAIL PROTECTED] wrote:
 
  \unprotect
 
  \def\fullpagebox
{\bgroup
 \dowithnextbox
   {\!!widtha\dimexpr\paperwidth/\nextboxwd\relax
\!!widthb\dimexpr\paperheight/\nextboxht\relax
\ifdim\!!widtha\!!widthb
  
  \setbox\nextbox\vbox\!!to\paperheight{\vss\expanded{\scale[\c!width=\paperwidth]{\flushnextbox}}\vss}%
\else
  
  \setbox\nextbox\hbox\!!to\paperwidth{\hss\expanded{\scale[\c!height=\paperheight]{\flushnextbox}}\hss}%
\fi  
  \setbox\nextbox\hbox{\clip[\c!width=\paperwidth,\c!height=\paperheight]{\flushnextbox}}%
\startTEXpage
\flushnextbox
\stopTEXpage
\egroup}
 \hbox}
 
  \protect
 
  \starttext
 
  \fullpagebox{\externalfigure[image]}
 
  \stoptext
 
 Now THAT's the 1st-class gangster we know and love so much ;-)
 
 Question: How can we, if desired, fit the image to the page dimensions?  
 See what happens with
 
 \starttext
 
 \fullpagebox{\externalfigure[cow][scale=fit]}
 
 \stoptext

Can you try \pagefigure, my solution was to scale a image to the
papersize and remove parts. \pagefigure includes a figure within a
TEXpage and you scale now the figure to the size of the document.

\starttext

\pagefigure[cow][width=\paperwidth,height=\paperheight]

\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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Images centered on page

2007-11-23 Thread Wolfgang Schuster
2007/11/23, Vyatcheslav Yatskovsky [EMAIL PROTECTED]:
 Hello,

 How can I center the image on a page? I want images to cover the page 
 completely, and since they have proper size (roughly A4), I only need them to 
 be centered. Now they are stuck to the top, leaving a gap on bottom (and same 
 for left-right).

 I have the following script (note my Lua trick to process images in a batch). 
 Image names are Image1.png and so on.


 %engine=luatex
 \setuplayout
   [footer=0mm, header=0mm,
   topspace=0mm, backspace=0mm,
   leftmargin=0mm, rightmargin=0mm,
   location=middle,
   height=fit, width=fit]

 \starttext

 \startluacode
   for n = 1, 9 do
 tex.print(string.format(\\externalfigure[Image%05d.png], n));
   end
 \stopluacode

 \stoptext

your mail remind me to something I wanted a long time ago but I was now
motivated enough to write it. Below is solution to fit a given image to
a page with the normal width and height but remove parts at the top and
bottom or left and right if the width height relation is different from
the one of the document.

I think Hans would be ablo to write a better solution but this all I
can do by myself at the moment.

\unprotect

\def\fullpagebox
  {\bgroup
   \dowithnextbox
 {\!!widtha\dimexpr\paperwidth/\nextboxwd\relax
  \!!widthb\dimexpr\paperheight/\nextboxht\relax
  \ifdim\!!widtha\!!widthb

\setbox\nextbox\vbox\!!to\paperheight{\vss\expanded{\scale[\c!width=\paperwidth]{\flushnextbox}}\vss}%
  \else

\setbox\nextbox\hbox\!!to\paperwidth{\hss\expanded{\scale[\c!height=\paperheight]{\flushnextbox}}\hss}%
  \fi 
\setbox\nextbox\hbox{\clip[\c!width=\paperwidth,\c!height=\paperheight]{\flushnextbox}}%
  \startTEXpage
  \flushnextbox
  \stopTEXpage
  \egroup}
   \hbox}

\protect

\starttext

\fullpagebox{\externalfigure[image]}

\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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Images centered on page

2007-11-23 Thread Idris Samawi Hamid
On Fri, 23 Nov 2007 12:30:48 -0700, Wolfgang Schuster  
[EMAIL PROTECTED] wrote:

 \unprotect

 \def\fullpagebox
   {\bgroup
\dowithnextbox
  {\!!widtha\dimexpr\paperwidth/\nextboxwd\relax
   \!!widthb\dimexpr\paperheight/\nextboxht\relax
   \ifdim\!!widtha\!!widthb
 
 \setbox\nextbox\vbox\!!to\paperheight{\vss\expanded{\scale[\c!width=\paperwidth]{\flushnextbox}}\vss}%
   \else
 
 \setbox\nextbox\hbox\!!to\paperwidth{\hss\expanded{\scale[\c!height=\paperheight]{\flushnextbox}}\hss}%
   \fi  
 \setbox\nextbox\hbox{\clip[\c!width=\paperwidth,\c!height=\paperheight]{\flushnextbox}}%
   \startTEXpage
   \flushnextbox
   \stopTEXpage
   \egroup}
\hbox}

 \protect

 \starttext

 \fullpagebox{\externalfigure[image]}

 \stoptext

Now THAT's the 1st-class gangster we know and love so much ;-)

Question: How can we, if desired, fit the image to the page dimensions?  
See what happens with

\starttext

\fullpagebox{\externalfigure[cow][scale=fit]}

\stoptext

Idris

-- 
Professor Idris Samawi Hamid, Editor-in-Chief
International Journal of Shi`i Studies
Department of Philosophy
Colorado State University
Fort Collins, CO 80523

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
___
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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Feature request for backgrounds

2007-10-11 Thread Wolfgang Schuster
2007/10/11, Hans Hagen [EMAIL PROTECTED]:
 Wolfgang Schuster wrote:
  Hi Hans,
 
  can you provide a backgroundimage key for localframed (ot use it in
framed)
  and fastlocalframed (to use it in \setupbackgrounds) to create something
like:
 
  \setupexternalfigures[location=global]
  \setupcolors[state=start]
 
  \starttext
 
  \defineoverlay
[Wallpaper]
[\backgroundimage{1}{\paperwidth}{\paperheight}{\externalfigure[cow]}]
 
  \setupbackgrounds
[page]
[background={color,Wallpaper},
 backgroundcolor=orange]
 
  \startstandardmakeup
  \stopstandardmakeup
 
  \stoptext
 
  I want to write the above example in the following way,
 
  \setupbackgrounds
[page]
[background={color,image},
 backgroundcolor=orange,
 backgroundimage=cow]
 
  The same mechanism should be also possible for \framed.
 
  It should be possible to enable a image and a backgroundcolor at the
same
  time to have a fallback mechanism for the case there is no image
available
  or I want a colored background behind the image.

 - you can use background anc backgroundcolor at the same time
 - you can have multiple backgrounds

I know and I used a backgroundcolor and a background simultaneously
in my posted example but what I want is a interface in localframed without
the overlay solution, the background should also repeated horizontal and
vertical and not streched in both directions.

 \defineoverlay[one][\overlayfigure{name}]
 \defineoverlay[two][abcdef]

 \setupbackgrounds[page][background={one,two}]

 \setupbackgrounds[page][background={one,foreground,two}]


 etc

  I have also a few wishes for \backgroundimage command in core-box,
  is it possible let the graphics start in the left top corner and crop it
only
  at the ride side and at the bottom like the default bahaviour in html.

 i think that there is some code in the x-fo file for that

  Shouldn't the \scratchbox in the \nextboxwd test be a \nextbox.

 where?

I meant in the \backgroundimage definition defined in core-box, bottom of
the file).

\def\backgroundimage#1#2#3% repeat hsize vsize
  {\bgroup
   \dowithnextbox
 {\ifcase#1\relax
% just one
  \else

\scratchdimen#2\divide\scratchdimen\nextboxwd\count0\scratchdimen\advance\count0\plusone

\scratchdimen#3\divide\scratchdimen\nextboxht\count2\scratchdimen\advance\count2\plusone
% to be considered, probably methods
\ifcase#1\or % x and y
  \setbox\nextbox\hbox{\dorecurse{\count0}{\copy\nextbox}}%
  \setbox\nextbox\vbox{\dorecurse{\count2}{\copy\nextbox\endgraf}}%
\or % x
  \setbox\nextbox\hbox{\dorecurse{\count0}{\copy\nextbox}}%
\or % y
  \setbox\nextbox\vbox{\dorecurse{\count2}{\copy\nextbox\endgraf}}%
\fi
  \fi
  \ifdim\nextboxwd#2\relax
\setbox\nextbox\hbox to #2{\hss\flushnextbox\hss}%

\setbox\scratchbox\hbox{\expanded{\clip[\c!width=#2,\c!height=\the\nextboxht]{\box\scratchbox}}}%

^^^
^^^
  \fi
  \ifdim\nextboxht#3\relax
\setbox\nextbox\vbox to #3{\vss\flushnextbox\vss}%

\setbox\nextbox\hbox{\expanded{\clip[\c!width=\the\nextboxwd,\c!height=#3]{\flushnextbox}}}%
  \fi
  \flushnextbox
  \egroup}%
   \hbox}

I want to use this to provide the user in the second version of the go
module a command to use graphics as board backgrounds where he
can use at the moment only colors. I know I could wrap this myself
into a macro but I hoped I can this without own code and pass only the
figure name and the backgroundcolor to the setup command for page
backgrounds or the frame background.

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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Margins around figures

2007-09-08 Thread Mojca Miklavec
On 9/7/07, Kumar Appaiah wrote:
 On Fri, Sep 07, 2007 at 09:18:30AM +0200, Oliver Buerschaper wrote:
  Perhaps
 
  setbounds currentpicture to boundingbox currentpicture enlarged 5mm;
 
  at the end of your MetaPost drawing might do what you want?

 That's probably in the right direction, but the MetaPost newbie I am,
 I am unable to figure out the error:

 mpost seminar.mp
 This is MetaPost, Version 0.993 (Web2C 7.5.6)
 (seminar.mp (/usr/share/texmf-texlive/metapost/base/TEX.mp)
 (/usr/share/texmf-texlive/metapost/base/boxes.mp)
  boundingbox.currentpicture.enlarged1cm
 ! Improper `clip'.
 to be read again
;
 l.26 ...o boundingbox currentpicture enlarged 1cm;

 ?

 What error could this be? The line I added is:
  setbounds currentpicture to boundingbox currentpicture enlarged 1cm;

Since plain metapost doesn't know about ConTeXt (metafun) extentions,
you need to:
- either add a line input metafun ; at the top of your metapost files
- or run mptopdf seminar.mp which will run metapost+create PDF
instead of running mpost/mp seminar.mp first and convert to PDF
later

When including a picture in ConTeXt, one options could also be to use:
\framed[frame=off,offset=1cm,strut=no,background=color,backgroundcolor=white]%
{\externalfigure[...]}
But that's slightly long and tedious, unless you write your own macro
wrapper around it.

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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Margins around figures

2007-09-07 Thread Wolfgang Schuster
2007/9/7, Oliver Buerschaper [EMAIL PROTECTED]:
  mpost seminar.mp
  This is MetaPost, Version 0.993 (Web2C 7.5.6)
  (seminar.mp (/usr/share/texmf-texlive/metapost/base/TEX.mp)
  (/usr/share/texmf-texlive/metapost/base/boxes.mp)
  boundingbox.currentpicture.enlarged1cm
  ! Improper `clip'.
  to be read again
 ;
  l.26 ...o boundingbox currentpicture enlarged 1cm;
 
  ?

 Oh, seems like I forgot that you wanted to run MetaPost externally.
 The command enlarged isn't contained in standard MetaPost but only
 in the extension MetaFun (i.e. MetaPost plus quite a number of
 predefined MetaPost macros) that comes with ConTeXt. Therefore the
 error is thrown ...

 Why not try this (in ConTeXt):

 ---

 \starttext

 \startuseMPgraphic{yourPicture}
 % put your MetaPost code here (without beginfig(); and endfig;)
 setbounds currentpicture to boundingbox currentpicture enlarged 1cm;
 \stopuseMPgraphic

 \useMPgraphic{yourPicture}

 \stoptext

He can set the offset in ConTeXt and not in MetaPost, e.g.

\offset[leftoffset=...]{\externalfigure[fugurename]}

The \offset command is described in the details manual, he can also
look at the definition in core-box.

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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Margins around figures

2007-09-07 Thread Oliver Buerschaper
 mpost seminar.mp
 This is MetaPost, Version 0.993 (Web2C 7.5.6)
 (seminar.mp (/usr/share/texmf-texlive/metapost/base/TEX.mp)
 (/usr/share/texmf-texlive/metapost/base/boxes.mp)
 boundingbox.currentpicture.enlarged1cm
 ! Improper `clip'.
 to be read again
;
 l.26 ...o boundingbox currentpicture enlarged 1cm;

 ?

Oh, seems like I forgot that you wanted to run MetaPost externally.  
The command enlarged isn't contained in standard MetaPost but only  
in the extension MetaFun (i.e. MetaPost plus quite a number of  
predefined MetaPost macros) that comes with ConTeXt. Therefore the  
error is thrown ...

Why not try this (in ConTeXt):

---

\starttext

\startuseMPgraphic{yourPicture}
% put your MetaPost code here (without beginfig(); and endfig;)
setbounds currentpicture to boundingbox currentpicture enlarged 1cm;
\stopuseMPgraphic

\useMPgraphic{yourPicture}

\stoptext

---

Best,
Oliver
___
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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Margins around figures

2007-09-07 Thread Kumar Appaiah
On Fri, Sep 07, 2007 at 09:18:30AM +0200, Oliver Buerschaper wrote:
 Perhaps
 
 setbounds currentpicture to boundingbox currentpicture enlarged 5mm;
 
 at the end of your MetaPost drawing might do what you want?

That's probably in the right direction, but the MetaPost newbie I am,
I am unable to figure out the error:

mpost seminar.mp
This is MetaPost, Version 0.993 (Web2C 7.5.6)
(seminar.mp (/usr/share/texmf-texlive/metapost/base/TEX.mp)
(/usr/share/texmf-texlive/metapost/base/boxes.mp)
 boundingbox.currentpicture.enlarged1cm
! Improper `clip'.
to be read again 
   ;
l.26 ...o boundingbox currentpicture enlarged 1cm;
  
?

What error could this be? The line I added is:
 setbounds currentpicture to boundingbox currentpicture enlarged 1cm;

Thanks!

Kumar
-- 
Kumar Appaiah,
458, Jamuna Hostel,
Indian Institute of Technology Madras,
Chennai - 600 036
___
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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Mysterious clipping for shaded MetaFun page background

2007-08-20 Thread Hans Hagen
Peter Rolf wrote:
 Oliver Buerschaper schrieb:
 Dear folks,

 can anyone reproduce this? (Live ConTeXt on the garden seems to run  
 into this \faststartcolor thing ... with pdfTeX.)

it may help to increase

\def\objectoffset{1cm}

(by default reused objects clip and this creates a virtual bbox)


-
   Hans Hagen | PRAGMA ADE
   Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: 038 477 53 69 | fax: 038 477 53 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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] placefigure

2007-07-25 Thread Liesbeth van der Plas

In GhostScript: Options àEPS Clip

File à Convert à pdfwrite, Variable Page

File à Convert à pdfwrite, Fixed Page Size

File à Convert à pdfwrite, Shrink to fit Page Size


I do get the picture now, but it is inbedded in a (small) 'page'; the frame
is too big.

Liesbeth



2007/7/24, Martin Schröder [EMAIL PROTECTED]:


2007/7/24, Roelof Langman [EMAIL PROTECTED]:
 This is a simple case of rtfm. From chapter 7 of the pdftex manual:

 pdfTEX supports inclusion of pictures in png, jpeg, tiff and pdf
format.

Please update. tiff is long gone...

Best
  Martin

___
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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net

___





--
[EMAIL PROTECTED]
www.wiskunde-interactief.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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] problem with mp clip

2007-07-23 Thread Peter Rolf
Patrick Gundlach schrieb:
   Is there a way to add the test pictures (cont-img.zip) to 'live context'?
 
 They are already installed, but not in a local path. I have changed
 'live context' so now the sample figures are in the search path. 
 
 Patrick


Thanks Patrick! This makes life easier :)

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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] problem with mp clip

2007-07-23 Thread Peter Rolf
Hans Hagen schrieb:
 Peter Rolf wrote:
 Hi,

 it seems, that clipping with a MetaPost path is broken (at least on my
 machine). I couldn't test it on Contextgarden, as the standard example
 pictures are not installed (or the !!path is not searched).

 Anyhow, if someone can test this please.

 
 
 has to do with the changed mp output ... in supp-mps.tex change this ...
 
 \bgroup
 \catcode`\%=\@@active
 \catcode`\/=\@@comment
 \gdef\dograbMPclippath/
{\setbox\scratchbox=\hbox\bgroup/
 \catcode`\%=\@@active
 \obeylines\let\obeyedline\space
 \def\do##1q n##2p W##3\od/
   {\xdef\MPclippath{##2}\endinput}/
 \def%##1%%EOF/
   {\do##1q np W\od\endinput}/
 \readfile{\MPgraphicfile.\the\currentMPgraphic}{}{}/
 \ifx\MPclippath\empty
   \def\do##1newpath##2closepath##3\od/
 {\xdef\MPclippath{##2}\endinput}/
   \def%##1%%EOF/
 {\do##1newpathclosepath\od\endinput}/
   \readfile{\MPgraphicfile.\the\currentMPgraphic}{}{}/
 \fi
 \deallocateMPslot\currentMPgraphic / new
 \egroup}
 \egroup
 
 keep in mind that it's still a dirty trick


Many thanks Hans. Works like a charm (dirty trick, but clean cut).

Peter

 
 I work with the latest minimal distribution (XP), ConTeXt beta from
 03.07.2007, pdftex 1.40.4 and mpost 1.0.

 Thanks in advance, Peter


 @Patrick:
   Is there a way to add the test pictures (cont-img.zip) to 'live context'?



 

 ___
 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  : https://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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] problem with mp clip

2007-07-22 Thread Peter Rolf
Hi,

it seems, that clipping with a MetaPost path is broken (at least on my
machine). I couldn't test it on Contextgarden, as the standard example
pictures are not installed (or the !!path is not searched).

Anyhow, if someone can test this please.

I work with the latest minimal distribution (XP), ConTeXt beta from
03.07.2007, pdftex 1.40.4 and mpost 1.0.

Thanks in advance, Peter


@Patrick:
  Is there a way to add the test pictures (cont-img.zip) to 'live context'?

\setupcolors[state=start]
\setuppagenumber[state=stop]

\startMPclip{ClipTest}
  clip currentpicture to
  unitcircle scaled 3cm;
\stopMPclip

\starttext

\clip[width=3cm,height=3cm,mp=ClipTest]{\externalfigure[mill.png]}

\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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] problem with mp clip

2007-07-22 Thread Patrick Gundlach

   Is there a way to add the test pictures (cont-img.zip) to 'live context'?

They are already installed, but not in a local path. I have changed
'live context' so now the sample figures are in the search path. 

Patrick
___
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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] problem with mp clip

2007-07-22 Thread Hans Hagen
Peter Rolf wrote:
 Hi,
 
 it seems, that clipping with a MetaPost path is broken (at least on my
 machine). I couldn't test it on Contextgarden, as the standard example
 pictures are not installed (or the !!path is not searched).
 
 Anyhow, if someone can test this please.



has to do with the changed mp output ... in supp-mps.tex change this ...

\bgroup
\catcode`\%=\@@active
\catcode`\/=\@@comment
\gdef\dograbMPclippath/
   {\setbox\scratchbox=\hbox\bgroup/
\catcode`\%=\@@active
\obeylines\let\obeyedline\space
\def\do##1q n##2p W##3\od/
  {\xdef\MPclippath{##2}\endinput}/
\def%##1%%EOF/
  {\do##1q np W\od\endinput}/
\readfile{\MPgraphicfile.\the\currentMPgraphic}{}{}/
\ifx\MPclippath\empty
  \def\do##1newpath##2closepath##3\od/
{\xdef\MPclippath{##2}\endinput}/
  \def%##1%%EOF/
{\do##1newpathclosepath\od\endinput}/
  \readfile{\MPgraphicfile.\the\currentMPgraphic}{}{}/
\fi
\deallocateMPslot\currentMPgraphic / new
\egroup}
\egroup

keep in mind that it's still a dirty trick


 I work with the latest minimal distribution (XP), ConTeXt beta from
 03.07.2007, pdftex 1.40.4 and mpost 1.0.
 
 Thanks in advance, Peter
 
 
 @Patrick:
   Is there a way to add the test pictures (cont-img.zip) to 'live context'?
 
 
 
 
 
 ___
 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  : https://foundry.supelec.fr/projects/contextrev/
 wiki : http://contextgarden.net
 ___


-- 

-
   Hans Hagen | PRAGMA ADE
   Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: 038 477 53 69 | fax: 038 477 53 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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] \overleftrightarrow

2007-07-19 Thread Aditya Mahajan

On Sat, 30 Jun 2007, Mojca Miklavec wrote:


On 6/29/07, Aditya Mahajan wrote:

Actually just adding overleftrightarrow is easy, but better will be an
interface to easily define such commands. So 

 If not, what can I do so that I can use it?

ConTeXt uses overleftarrow and overrightarrow as defined in plain
tex. This does not work in subscripts.

$\overleftarrow{A}$ $\overleftarrow{ABC}$
$a_{\overleftarrow{A}}$ $b_{\overleftarrow{ABC}}$

Here is a solution. First we patch math-ext so that arrowfills take a
style.

There are also underarrows, which will not be too hard to do. I will
patch math-ext with both overarrows and underarrows. I think that
there needs to be some italic correction for the arrow. It is
centered on the math box, but the math box is tilted to the right. Any
way to determine the correct horizontal skip that should be added.


I am attaching an updated math-ext.tex that defines over and under 
arrows. To use it, copy it to your current directory and add \input 
math-ext somewhere in your environment file.


Hans, this file also contains some minor typo corrections in the 
earlier documentation. I have also changed the text width for comments 
to 70, as 80 characters do not look nice on contextgarden.




Mojca, I remember that you had some trouble with overharpoons. Does
this take care of that?


\vec is not good for two reasons:

a) often stretchable arrows are needed (vectors both over single
letters and things like {AB} are mixed, and \vec looks really weird in
cases where letters are longer, or when we have combinations of them)

b) vectors should be harpoons (not arrows) according to our conventions.


My old \overrightharpoonup definitions had two other problems:

c) scalability/interfering with style change: you solved exactly that
one in a really nice way - thanks a lot (I did patch it, but it looked
like really ugly code)

d) glyphs themselves and their size (probably only the Polish guys can
help here) - and that's the real problem at the moment


Long ago, for some other problem, Taco had suggested that it will be 
nice to have just the arrow heads. Then we could stack them the way we 
want. IIRC, this is what the cow font does. If nothing else works, you 
can try the cow font for writing math. I think that it matches nicely 
with iwona-heavy :)



Consider
\def\myvec#1{\overrightharpoonup{#1}}
$(\myvec{\imath},\myvec{\jmath},\myvec{k})$ or $\myvec{\nabla}$,
$\myvec{\sigma}$, $\myvec{r}$, ...
The base size on top of i, j, k, ... is just too long and the harpoon
is also slightly too big.


A realy realy ugly solution (if you do not want extensible arrows).

\def\definemathshortarrow
  {\dotripleargument\dodefinemathshortarrow}

\def\dodefinemathshortarrow[#1][#2][#3]%
  {\ifthirdargument
  \setvalue{#1}{\dohandlemathshortarrow[#2][#3]}%
\else
  \setvalue{#1}{\dohandlemathshortarrow[\zeropoint][#2]}%
\fi}

\def\dohandlemathshortarrow[#1][#2]%
  {\mathpalette{\dodohandlemathshortarrow{#1}{#2}}}

\def\dodohandlemathshortarrow#1#2#3#4%
  [EMAIL PROTECTED]
   \vbox{\ialign{##\crcr
   [EMAIL PROTECTED]
   \noalign{\kern#1\nointerlineskip}%
   [EMAIL PROTECTED]

\definemathshortarrow  [shortoverrightharpoonup]
   [\rightharpoonup]


\let\myvec\shortoverrightharpoonup


I do not like mirror-clip-mirror but I could not find how to clip 
from the left rather than the right.


I guess now is the time to update the myway on math arrows :)

Aditya

math-ext.tex
Description: Binary data
___
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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] overleftrightarrow

2007-07-19 Thread Aditya Mahajan
Quoting Aditya Mahajan [EMAIL PROTECTED]:

 On Sat, 30 Jun 2007, Mojca Miklavec wrote:

 Consider
 \def\myvec#1{\overrightharpoonup{#1}}
 $(\myvec{\imath},\myvec{\jmath},\myvec{k})$ or $\myvec{\nabla}$,
 $\myvec{\sigma}$, $\myvec{r}$, ...
 The base size on top of i, j, k, ... is just too long and the harpoon
 is also slightly too big.

 A realy realy ugly solution (if you do not want extensible arrows).

Here is a slightly better solution; I have tested it only for harpoons, 
and there are no configuration options for other accents. But it 
works for both short and long objects.

\def\definemathfancyarrow
  {\dotripleargument\dodefinemathfancyarrow}

\def\dodefinemathfancyarrow[#1][#2][#3]% arrow short long
  {\setvalue{#1}{\dohandlemathfancyarrow[#2][#3]}}

\def\dohandlemathfancyarrow[#1][#2]%
  {\mathpalette{\dodohandlemathfancyarrow{#1}{#2}}}

%TODO: The clip operation should be configurable, whether you want to clip
%right or clip left.

\unexpanded\def\dodohandlemathfancyarrow#1#2#3#4% short long style text
  [EMAIL PROTECTED]
   [EMAIL PROTECTED]
   \vbox{\ialign{##\crcr
   \ifdim\wd0\wd2
 [EMAIL PROTECTED]
   \else
 #2#3%
   \fi\crcr
   \noalign{\kern-\onepoint\nointerlineskip}%
   [EMAIL PROTECTED]

\definemathfancyarrow  [fancyoverrightharpoonup]
   [\rightharpoonup]
   [\rightharpoonupfill]


\let\myvec\fancyoverrightharpoonup

\starttext
$\myvec{\imath} \myvec{\jmath} \myvec{ABCD}$
\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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Context and CD labels

2006-10-20 Thread Renaud AUBIN
Maurí­cio a écrit :

   It's working now, I've just downloaded that file. I belive that paper 
is letter, although A4 is usually a lot more common here.
   Sections are not that important, as long as I can have different 
formats for some lines of text, and I'm sure that's not a problem. For 
sure, an example would be great!
  


I'll let you do the job for positionning. You'll find as attached an
example... Since it's not obvious to me to make a shapetext with a holed
shape (I have tried some tricks but failed), I reserved 2 text areas:
1. (test 1) song list for example
2. (test 2|framedtext) Author  title

This example assumes that :
- the first label is centered on x=.5\paperwidth y=.75\paperwidth
- the second is centered on x=.5\paperwidth y=.25\paperheight

You can even put a background image if you want, using overlay and clip...

Renaud
\setuppapersize[A4][A4]
\setuppagenumbering[state=stop]
\setupcolors[state=start]

\useMPlibrary[txt]

\startuseMPgraphic{test 1}
path p;
numeric orad, irad; orad := 6cm; irad := 2cm;
path outercircle; outercircle := fullcircle scaled 2orad;
path innercircle; innercircle := fullcircle scaled 2irad;
path outershape; 
outershape := outercircle cutbefore((0,irad)--(orad,irad))
cutafter((0,-irad)--(orad,-irad));
path innershape;
innershape := reverse (innercircle cutbefore((0,irad)--(irad,irad))
cutafter((0,-irad)--(irad,-irad)));
p:= outershape--innershape--cycle;
build_parshape(p,6pt,0,0,\baselinedistance,\strutheight,\strutdepth,\strutheight) ;
%draw p withpen pencircle scaled 1pt ;
\stopuseMPgraphic

\startuseMPgraphic{test 2}
path p;
numeric orad, irad; orad := 6cm; irad := 2cm;
path outercircle; outercircle := fullcircle scaled 2orad;
path innercircle; innercircle := fullcircle scaled 2irad;
path outershape; 
outershape := outercircle rotated 90
cutbefore((0,-irad)--(orad,-irad))
cutafter((0,irad)--(orad,irad));
path innershape;
innershape := reverse (innercircle rotated 90
cutbefore((0,-irad)--(irad,-irad))
cutafter((0,irad)--(irad,irad)));
p:= outershape--innershape--cycle;
build_parshape(p,6pt,0,0,\baselinedistance,\strutheight,\strutdepth,\strutheight) ;
%draw p withpen pencircle scaled 1pt ;
\stopuseMPgraphic

\defineoverlay[test 1][\useMPgraphic{test 1}]
\defineoverlay[test 2][\useMPgraphic{test 2}]

\startuseMPgraphic{CDShape}
draw fullcircle scaled 12cm;
draw fullcircle scaled 4cm;
\stopuseMPgraphic

\starttext

\setupframed[offset=overlay,align=normal,frame=off,width=\parwidth,height=\parheight]

\startproperty[hidden]
I need some text to get the page... but also need to hide this text !
\stopproperty

\definelayer[PageLayer][position=yes]
\setupbackgrounds[page][background=PageLayer]
\setuplayer[PageLayer][position=no,corner=bottom,height=\paperheight]

%% check-up shape
\setlayer[PageLayer][x=.5\paperwidth,y=.75\paperheight,location=c]{\useMPgraphic{CDShape}}

%% text
\startshapetext[test 1]
\input tufte
\stopshapetext
% x = .5\paperwidth (210mm) - orad
\setlayer[PageLayer][x=45mm,y=.75\paperheight,location=r]{\framed[background=test 1]{\getshapetext}}

\startshapetext[test 2]
\input knuth
\stopshapetext
% x = .5\paperwidth (210mm) + orad
%\setlayer[PageLayer][x=165mm,y=.75\paperheight,location=l]{\framed[background=test 2]{\getshapetext}}

\setlayer[PageLayer][x=145mm,y=.75\paperheight,location=c]{\framedtext[width=4cm,align=middle,frame=off]{Author \ Title\crlf and more if you want}}

%% check-up shape
\setlayer[PageLayer][x=.5\paperwidth,y=.25\paperheight,location=c]{\useMPgraphic{CDShape}}

% text
\startshapetext[test 1]
\input zapf
\stopshapetext
% x = .5\paperwidth (210mm) - orad
\setlayer[PageLayer][x=45mm,y=.25\paperheight,location=r]{\framed[background=test 1]{\getshapetext}}

\startshapetext[test 2]
\input knuth
\stopshapetext
% x = .5\paperwidth (210mm) + orad
\setlayer[PageLayer][x=165mm,y=.25\paperheight,location=l]{\framed[background=test 2]{\getshapetext}}


\stoptext
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Context and CD labels

2006-10-20 Thread Maurício

 (...)
 
 I'll let you do the job for positionning. You'll find as attached an
 example... Since it's not obvious to me to make a shapetext with a holed
 shape (I have tried some tricks but failed), I reserved 2 text areas:
 1. (test 1) song list for example
 2. (test 2|framedtext) Author  title
 
 This example assumes that :
 - the first label is centered on x=.5\paperwidth y=.75\paperwidth
 - the second is centered on x=.5\paperwidth y=.25\paperheight
 
 You can even put a background image if you want, using overlay and clip...
 
 Renaud
 (...)

   Thanks! That's exactly what I need.

   Best,
   M.

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Context and CD labels

2006-10-18 Thread Renaud AUBIN
Maurício a écrit :

Has anyone ever tried to use Context to create music CD labels? Any 
tips on what should I do, pages I can read or results I can expect?
  

Hi Mauricio,

I have never tried to create CD labels but from my experience you should
use overlay... Could you describe the geometry of the labels you use (if
you use some) ?
I can make an example without it but it can help to provide a full one...
I need:
- width and height of the page (if non-standard)
- number of label per page and position of each label's center
relatively to a corner of the page...

A 2 min experiment gives:

\setuppapersize[A4][A4]
\setuppagenumbering[state=stop]
\setupcolors[state=start]

\startuseMPgraphic{CDShape}
draw fullcircle scaled 12cm;
draw fullcircle scaled 4cm;
\stopuseMPgraphic

\starttext
\startproperty[hidden]
I need some text to get the page... but also need to hide this text !
\stopproperty

\definelayer[PageLayer][position=yes]
\setupbackgrounds[page][background=PageLayer]
\setuplayer[PageLayer][position=no,corner=bottom,height=\paperheight]

% sample geometry
\setlayer[PageLayer][x=.5\paperwidth,y=.25\paperheight,location=c]{\useMPgraphic{CDShape}}
\setlayer[PageLayer][x=.5\paperwidth,y=.75\paperheight,location=c]{\useMPgraphic{CDShape}}

\page
\startproperty[hidden]
I need some text to get the page... but also need to hide this text !
\stopproperty
% another sample geometry
\setlayer[PageLayer][x=.35\paperwidth,y=.30\paperheight,location=c]{\useMPgraphic{CDShape}}
\setlayer[PageLayer][x=.65\paperwidth,y=.70\paperheight,location=c]{\useMPgraphic{CDShape}}

\stoptext

You can draw, clip, write whatever you want and where you want... The
circular shape are just to demonstrate positionning and can help to check...

You could use Metafun to do some advanced text manipulation (like shaped
texts or followtoken texts...)

No more to say...


Renaud


___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Context and CD labels

2006-10-18 Thread Maurí­cio
 Has anyone ever tried to use Context to create music CD labels? Any 
 tips on what should I do, pages I can read or results I can expect?
  
 I have never tried to create CD labels but from my experience you should
 use overlay... Could you describe the geometry of the labels you use (if
 you use some) ?

   I don't have the exact dimenstions. You can check it here (Open 
Office document):

www.pimaco.com.br/files/gabaritos/Gabarito_CDpply_CARTA.sxw

 I can make an example without it but it can help to provide a full one...
 I need:
 - width and height of the page (if non-standard)
 - number of label per page and position of each label's center
 relatively to a corner of the page...
 
 (...)
 
 You can draw, clip, write whatever you want and where you want... The
 circular shape are just to demonstrate positionning and can help to check...
 
 You could use Metafun to do some advanced text manipulation (like shaped
 texts or followtoken texts...)
 

   I will learn Metafun right now. Do you think I can get Context to 
write a music list in a way that the text fits automatically into the 
label? I would like to create a standard template for labels so that I 
could change only the music list and title. That list could be as small 
as 3 songs or as big as 30 songs organized into sections.

   Maurício

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] absolute positioning of figures

2006-10-13 Thread Peter Rolf
andrea valle wrote:
 Example:
 
 \definelayer[layer2a][width=.15\paperwidth]
 
 \setlayer   [layer2a]
  [x=.15\paperwidth, y=.5\paperheight]
  {\externalfigure[layTest][width=.75\paperwidth]}

extend your example with

\clip[width=.15\paperwidth,height=define
one,hoffset=0pt,voffset=0pt]{\externalfigure..}

and you can see the difference.. (no picture in the smaller layer).

As I already mentioned, the size is (only?) significant, if you change
the default positioning (reference point). For example, you want to
place something with an offset of 2cm to the right bottom corner of the
layer. Therefore you need the exact width and height of the layer.
All default positioning (relative to top left corner of the layer)
doesn't care about the size, as there is no difference (no calculation
is needed).

I hope I have made myself clear.

Greetings, Peter

 
 I was expecting to have the layTest figure cut after its width exceeds 
 the layer's width. It seems that this is unrelevant, i.e.
 
 If I have instead of this:
 
 \definelayer[layer2a][width=.15\paperwidth]
 
 this:
 \definelayer[layer2a][width=.75\paperwidth]
 
 It's the same.
 
 So, I cannot understand what width means for layers, as changing it has 
 no consequences (in my example).
 
 Best
 
 -a-
 
 
 
 
 
 
 On 13 Oct 2006, at 18:31, Hans Hagen wrote:
 \definelayer[blabla][width=20cm,height30cm]

 etc etc

 -- 

 -
   Hans Hagen | PRAGMA ADE
   Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
  | www.pragma-pod.nl
 -

 ___
 ntg-context mailing list
 ntg-context@ntg.nl
 http://www.ntg.nl/mailman/listinfo/ntg-context


 Andrea Valle
 DAMS - Facoltà di Scienze della Formazione
 Università degli Studi di Torino
 http://www.semiotiche.it/andrea
 [EMAIL PROTECTED]
 
 ___
 ntg-context mailing list
 ntg-context@ntg.nl
 http://www.ntg.nl/mailman/listinfo/ntg-context
 
 

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] ConTeXt and cmyk

2006-07-21 Thread Renaud AUBIN




Hi all,

I have reproduced a logo http://www.uvsq.fr/guide/charte/index.html
(see attachment for the resulting metapost code).
What's the best method to define colors according to this web page ?
My understanding is:
- for printing, the use of
\setupcolors[cmyk=yes,mpcmyk=no,conversion=no] is the best,
- for display rendering, the use of
\setupcolors[cmyk=yes,mpcmyk=yes,conversion=yes] is the best.

Am I right ?

Renaud





%D
%D   file=logouvsq_mp,
%Dversion=2006.07.20,
%D  title=UVSQ logo,
%D author=Renaud Aubin,
%D  copyright=Public Domain
%C
%C Donated to the public domain.

\setupcolors[state=start]

\setupcolors[cmyk=yes,mpcmyk=no,conversion=no]  %% printer
%\setupcolors[cmyk=yes,mpcmyk=no,conversion=yes] %% printer
%\setupcolors[cmyk=yes,mpcmyk=yes,conversion=no] %% display
%\setupcolors[cmyk=yes,mpcmyk=yes,conversion=yes] %% display

% cmyk definitions
\definecolor[uvsqdarkgreen][c=.1,m=.0,y=.45,k=.4]
\definecolor[uvsqgreen][c=.76,m=.0,y=.91,k=.0]
\definecolor[uvsqblue][c=.87,m=.18,y=.0,k=.0]

\starttext

\startbuffer[uvsqlogo]
numeric u; u:= 1mm;

% width  height
numeric w; w:=85.8u;
numeric h; h:=51.2u;

% explicit ? ;)
path mainframe; mainframe:= (-.5w,-.5h)--(.5w,-.5h)--(.5w,.5h)--(-.5w,.5h)--cycle;

% blue line properties
numeric bluew; bluew:=.075h;

% green curve properties
numeric greenw; greenw:=.072h;

pair pts[];
pts[0] := (-.2625w,-.342h);
pts[1] := (-.305w,-.085h);
pts[2] := (-.13w,-.085h);
pts[3] := (-.025w,.2h);
pts[4] := (.01w,-.12h);
pts[5] := (.08w,-.11h);
pts[6] := (.123w,-.188h);
pts[7] := (.2625w,-.085h);
pts[8] := (.2625w,-.342h);

% sun properties
pair suncenter; suncenter := (-.184w,.125h);
pair raycenter; raycenter := (-.184w,.13h);
numeric sunradius; sunradius := 19.5u;
numeric sunw; sunw:=.7u;

% the blue bottom line
interim linecap:=squared;
drawoptions(withpen pencircle scaled bluew withcolor \MPcolor{uvsqblue});
draw (-.5w+.0375h,-.4625h)--(.5w-.0375h,-.4625h);

% sunrays
drawoptions(withpen pencircle scaled sunw withcolor \MPcolor{uvsqdarkgreen});
for i=-5 upto 12:
draw ((origin--(0,2h)) rotated (11.25i)) shifted raycenter;
endfor;
draw ((origin--(0,2h)) rotated (-65)) shifted raycenter;
draw ((origin--(0,2h)) rotated (-72)) shifted raycenter;
draw ((origin--(0,2h)) rotated (-80)) shifted raycenter;
draw ((origin--(0,2h)) rotated (-87)) shifted raycenter;
draw ((origin--(0,2h)) rotated (-95)) shifted raycenter;
draw ((origin--(0,2h)) rotated (-102)) shifted raycenter;

% white circle
drawoptions(withpen pencircle scaled 0u withcolor white);
fill fullcircle scaled sunradius shifted suncenter;

% sun
drawoptions(withpen pencircle scaled sunw withcolor \MPcolor{uvsqdarkgreen});
draw fullcircle scaled sunradius shifted suncenter;

% white circle
drawoptions(withpen pencircle scaled 0u withcolor white);
fill fullcircle scaled 30 shifted (-.05w,.03h);

% white curves ? ;)
interim linecap:=squared;
drawoptions(withpen pencircle scaled 2.5greenw withcolor white);
draw (-.5w+.036h,-.332h)--(xpart pts[0]-.036h, -.332h);
draw (.5w-.036h,-.332h)--(xpart pts[8]+.036h, -.332h);
interim linecap:=butt;
for i=0 upto 3:
draw pts[2i]..pts[2i+1]..pts[2i+2];
endfor;

% the green curve
interim linecap:=squared;
drawoptions(withpen pencircle scaled greenw withcolor \MPcolor{uvsqgreen});
draw (-.5w+.036h,-.342h)--(xpart pts[0]-.036h, ypart pts[0]);
draw (.5w-.036h,-.342h)--(xpart pts[8]+.036h, ypart pts[8]);
interim linecap:=rounded;
for i=0 upto 3:
draw pts[2i]..pts[2i+1]..pts[2i+2];
endfor;

setbounds currentpicture to mainframe;
clip currentpicture to mainframe;

\stopbuffer %% end of buffer[uvsqlogo]

\placefigure[here]{none}{\processMPbuffer[uvsqlogo]}

\stoptext
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] clipping problem

2006-07-10 Thread Hans Hagen
Peter Rolf wrote:
 Just as a reminder for an unsolved problem :)

 I also tested this on contextgarden, with faulty result. Same with

 \clip[hoffset=64bp,voffset=64bp,width=64bp,height=64bp]{\reuseMPgraphic{cliptest}}

 So it doesn't look like a rounding problem.
   
this clips ok here (only one color-clips) so maybe a viewer problem?
 Peter Rolf wrote:
   
 Hi,

 I have some png-graphics, where several (equal sized) icons are arranged
 in array form. When I cut out an icon, I get the icon gfx plus a very
 small part from the surronding icon(s). The attached file shows, that
 the same problem occurs when using a vector based graphic.

 Normally I use imagemagic to seperate such files into single gfx, so
 this is not a serious problem for me. But if this is a bug, it should be
 fixed (or if I have missed something, let me know).

 Greetings, Peter


 

 % interface=en output=pdftex
 % Time-stamp: Montag, 03 Juli 2006 21:04:46; cliptest.tex
 %

 \setupcolors[state=start]

 \startreusableMPgraphic{cliptest}
   path p ;
   u:= 64bp ;
   p:= unitsquare xyscaled(u,u) ;

   fill p withcolor green ;
   fill p xshifted u  withcolor blue ;
   fill p xshifted 2u withcolor green ;

   fill p yshifted u withcolor blue ;
   fill p shifted (u,u)  withcolor red ;
   fill p shifted (2u,u) withcolor blue ;

   fill p shifted (0,2u)  withcolor green ;
   fill p shifted (u,2u)  withcolor blue ;
   fill p shifted (2u,2u) withcolor green ;
 \stopreusableMPgraphic


 \starttext

 \reuseMPgraphic{cliptest}
 \blank

 \setupclipping[nx=3,ny=3]

 \clip[x=1,y=1]{\reuseMPgraphic{cliptest}}
 \blank

 \clip[x=2,y=2]{\reuseMPgraphic{cliptest}}
 \blank

 \clip[x=2,y=3]{\reuseMPgraphic{cliptest}}



 \stoptext

 %%% Local Variables:
 %%% mode: context
 %%% TeX-master: 
 %%% End:


 

 ___
 ntg-context mailing list
 ntg-context@ntg.nl
 http://www.ntg.nl/mailman/listinfo/ntg-context
 

 ___
 ntg-context mailing list
 ntg-context@ntg.nl
 http://www.ntg.nl/mailman/listinfo/ntg-context
   


-- 

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] clipping problem

2006-07-10 Thread Peter Rolf
Hans Hagen wrote:
 Peter Rolf wrote:
 Just as a reminder for an unsolved problem :)

 I also tested this on contextgarden, with faulty result. Same with

 \clip[hoffset=64bp,voffset=64bp,width=64bp,height=64bp]{\reuseMPgraphic{cliptest}}

 So it doesn't look like a rounding problem.
   
 this clips ok here (only one color-clips) so maybe a viewer problem?

I attached the final pdf and a screenshot out of acrobat viewer (v7.08,
Win XP) at 300%. If you zoom the screenshot at the top/right edges of
the clipped boxes, you can clearly see that there is something wrong.
Maybe a viewer problem, as 'foxit reader' shows the same glitches at
lower zoomlevel, but not at higher zoomlevel. Acrobat Viewer shows them
even at 6400%. Mhh, I will test this on another computer.

Thanks anyway,

Peter


 Peter Rolf wrote:

 Hi,

 I have some png-graphics, where several (equal sized) icons are arranged
 in array form. When I cut out an icon, I get the icon gfx plus a very
 small part from the surronding icon(s). The attached file shows, that
 the same problem occurs when using a vector based graphic.

 Normally I use imagemagic to seperate such files into single gfx, so
 this is not a serious problem for me. But if this is a bug, it should be
 fixed (or if I have missed something, let me know).

 Greetings, Peter


 

 % interface=en output=pdftex
 % Time-stamp: Montag, 03 Juli 2006 21:04:46; cliptest.tex
 %

 \setupcolors[state=start]

 \startreusableMPgraphic{cliptest}
   path p ;
   u:= 64bp ;
   p:= unitsquare xyscaled(u,u) ;

   fill p withcolor green ;
   fill p xshifted u  withcolor blue ;
   fill p xshifted 2u withcolor green ;

   fill p yshifted u withcolor blue ;
   fill p shifted (u,u)  withcolor red ;
   fill p shifted (2u,u) withcolor blue ;

   fill p shifted (0,2u)  withcolor green ;
   fill p shifted (u,2u)  withcolor blue ;
   fill p shifted (2u,2u) withcolor green ;
 \stopreusableMPgraphic


 \starttext

 \reuseMPgraphic{cliptest}
 \blank

 \setupclipping[nx=3,ny=3]

 \clip[x=1,y=1]{\reuseMPgraphic{cliptest}}
 \blank

 \clip[x=2,y=2]{\reuseMPgraphic{cliptest}}
 \blank

 \clip[x=2,y=3]{\reuseMPgraphic{cliptest}}



 \stoptext

 %%% Local Variables:
 %%% mode: context
 %%% TeX-master: 
 %%% End:


 

 ___
 ntg-context mailing list
 ntg-context@ntg.nl
 http://www.ntg.nl/mailman/listinfo/ntg-context
 
 ___
 ntg-context mailing list
 ntg-context@ntg.nl
 http://www.ntg.nl/mailman/listinfo/ntg-context
   
 
 



cliptest.7z
Description: Binary data
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] clipping problem

2006-07-06 Thread Peter Rolf
Just as a reminder for an unsolved problem :)

I also tested this on contextgarden, with faulty result. Same with

\clip[hoffset=64bp,voffset=64bp,width=64bp,height=64bp]{\reuseMPgraphic{cliptest}}

So it doesn't look like a rounding problem.

Peter Rolf wrote:
 Hi,
 
 I have some png-graphics, where several (equal sized) icons are arranged
 in array form. When I cut out an icon, I get the icon gfx plus a very
 small part from the surronding icon(s). The attached file shows, that
 the same problem occurs when using a vector based graphic.
 
 Normally I use imagemagic to seperate such files into single gfx, so
 this is not a serious problem for me. But if this is a bug, it should be
 fixed (or if I have missed something, let me know).
 
 Greetings, Peter
 
 
 
 
 % interface=en output=pdftex
 % Time-stamp: Montag, 03 Juli 2006 21:04:46; cliptest.tex
 %
 
 \setupcolors[state=start]
 
 \startreusableMPgraphic{cliptest}
   path p ;
   u:= 64bp ;
   p:= unitsquare xyscaled(u,u) ;
 
   fill p withcolor green ;
   fill p xshifted u  withcolor blue ;
   fill p xshifted 2u withcolor green ;
 
   fill p yshifted u withcolor blue ;
   fill p shifted (u,u)  withcolor red ;
   fill p shifted (2u,u) withcolor blue ;
 
   fill p shifted (0,2u)  withcolor green ;
   fill p shifted (u,2u)  withcolor blue ;
   fill p shifted (2u,2u) withcolor green ;
 \stopreusableMPgraphic
 
 
 \starttext
 
 \reuseMPgraphic{cliptest}
 \blank
 
 \setupclipping[nx=3,ny=3]
 
 \clip[x=1,y=1]{\reuseMPgraphic{cliptest}}
 \blank
 
 \clip[x=2,y=2]{\reuseMPgraphic{cliptest}}
 \blank
 
 \clip[x=2,y=3]{\reuseMPgraphic{cliptest}}
 
 
 
 \stoptext
 
 %%% Local Variables:
 %%% mode: context
 %%% TeX-master: 
 %%% End:
 
 
 
 
 ___
 ntg-context mailing list
 ntg-context@ntg.nl
 http://www.ntg.nl/mailman/listinfo/ntg-context

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] clipping problem

2006-07-03 Thread Peter Rolf
Hi,

I have some png-graphics, where several (equal sized) icons are arranged
in array form. When I cut out an icon, I get the icon gfx plus a very
small part from the surronding icon(s). The attached file shows, that
the same problem occurs when using a vector based graphic.

Normally I use imagemagic to seperate such files into single gfx, so
this is not a serious problem for me. But if this is a bug, it should be
fixed (or if I have missed something, let me know).

Greetings, Peter
% interface=en output=pdftex
% Time-stamp: Montag, 03 Juli 2006 21:04:46; cliptest.tex
%

\setupcolors[state=start]

\startreusableMPgraphic{cliptest}
  path p ;
  u:= 64bp ;
  p:= unitsquare xyscaled(u,u) ;

  fill p withcolor green ;
  fill p xshifted u  withcolor blue ;
  fill p xshifted 2u withcolor green ;

  fill p yshifted u withcolor blue ;
  fill p shifted (u,u)  withcolor red ;
  fill p shifted (2u,u) withcolor blue ;

  fill p shifted (0,2u)  withcolor green ;
  fill p shifted (u,2u)  withcolor blue ;
  fill p shifted (2u,2u) withcolor green ;
\stopreusableMPgraphic


\starttext

\reuseMPgraphic{cliptest}
\blank

\setupclipping[nx=3,ny=3]

\clip[x=1,y=1]{\reuseMPgraphic{cliptest}}
\blank

\clip[x=2,y=2]{\reuseMPgraphic{cliptest}}
\blank

\clip[x=2,y=3]{\reuseMPgraphic{cliptest}}



\stoptext

%%% Local Variables:
%%% mode: context
%%% TeX-master: 
%%% End:
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] Clipping again

2006-06-25 Thread David Arnold
Hi,

I confess I got some earlier advice on this issue, but I've never  
been able to apply it to find a resolution. In the buffer that  
follows, I define a clipping box:

% clipping path
path cpath;
cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle;
cpath:=cpath scaled 1u;

A function is created and scaled:

% scale and draw graph
P:=P scaled u;
draw P withcolor blue;

The picture is clipped and saved:

% clip and save current picture
picture pic;
clip currentpicture to cpath;
pic:=currentpicture;

Then it is redrawn later.

% redraw line
draw pic;

Unfortunately, even though this works, mathematicians really want  
arrows at each end of the graph. Easy enough to do with drawdblarrow  
P withcolor blue, but the arrows then get clipped. What I really need  
is to adapt the code below so that my function is clipped to the  
boundary box, but then redrawn with arrows at each end of it. If  
anyone can adjust my code to do that, it would be much appreciated,  
and it would break down a barrier I've faced for years with metapost  
coding.

Note that I've tried some stuff with cutbefore and cutafter with some  
success. But I should remark that the code below is generated by a  
perl script and some special coding we've set up to generate these  
graphics on the fly for student quizzes. This is not a situation  
where I can tweak an individual plot or two. Rather, our script might  
generate 100 sets of the code below, all with different parameters.  
So this magnifies the problem.

Again, any ideas would be greatly appreciated.





\startbuffer
numeric w,h;
w=4cm;h=4cm;
% inititialize numerator and denominator of the slope of f
numeric a;
a=2;

% initialize choice of function
numeric choice;
choice=1;

% initialize type of reflection
numeric reflect;
reflect=2;

% define linear function f
vardef f(expr x)=
a*x*x
enddef;

% define linear function g
vardef g(expr x)=
a*abs(x)
enddef;

% define linear function h
vardef h(expr x)=
a*x*(x-2)*(x+2)/2
enddef;

% define paths for functions f, g, and h, respectively
path P, F, G, H;

F:=(-5,f(-5));
for x=-5 step .1 until 5:
F:=F--(x,f(x));
endfor;

G:=(-5,g(-5));
for x=-5 step .1 until 5:
G:=G--(x,g(x));
endfor;

H:=(-5,h(-5));
for x=-5 step .1 until 5:
H:=H--(x,h(x));
endfor;

% choose the function to use, f, g, or h
if (choice=1):
P:=F;
elseif (choice=2):
P:=G;
else:
P:=H;
fi;

% choose the type of reflection
if (reflect=1):
P:=P;
elseif (reflect=2):
P:=P reflectedabout((0,0),(1,1));
elseif (reflect=3):
P:=P reflectedabout((0,0),(1,-1));
else:
P:=P reflectedabout((-1,0),(1,0));
fi;

% initialize scale
numeric u; 10u=w;

% scale and draw graph
P:=P scaled u;
draw P withcolor blue;

% clipping path
path cpath;
cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle;
cpath:=cpath scaled 1u;

% clip and save current picture
picture pic;
clip currentpicture to cpath;
pic:=currentpicture;

% erase currentpicture
currentpicture:=nullpicture;

% draw grid
for k=-5u step 1u until 5u:
draw (-5u,k)--(5u,k) withcolor mygridcolor;
draw (k,-5u)--(k,5u) withcolor mygridcolor;
endfor;

% draw axes
drawarrow (-5u,0)--(5u,0);
drawarrow (0,-5u)--(0,5u);

% label axes
label.rt(btex $x$ etex, (5.2u,0));
label.top(btex $y$ etex, (0,5.2.u));
label.bot(btex $5$ etex, (5u,0));
label.lft(btex $5$ etex, (0,5u));

% redraw line
draw pic;

% draw vertical line test
numeric xvert;
if (reflect=3):
xvert:=-1;
else:
xvert:=1;
fi;

% vertical line
path vert;
vert:=(xvert,-5)--(xvert,5);
vert:=vert scaled u;

pickup pencircle scaled 2pt;
drawdblarrow vert withcolor red;
pickup defaultpen;

\stopbuffer
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Clipping again

2006-06-25 Thread David Arnold
Mojca,

Good question of course.

However, I am using this for intermediate algebra students so the  
graphs will be lines, absolute value, quadratics, polynomials,  
rational functions, radical functions, exponential and logarithmic  
functions.

In each case, I would adjust the window to see all important behavior  
of the function, extrema, etc. So, for example, if I needed to draw  
y=12-x^2, I would not clip this to the boundary (-10,-10)--(10,-10)-- 
(10,10)--(-10,10)--cycle, because that would chop off the top of the  
parabola, and if I added arrows, it would look like I had two  
branches. Rather, I might clip y=12-x^2 to the boundary (-10,-20)-- 
(10,-20)--(10,20)--(-10,20)--cycle in order to see the turning  
point of the parabola.

That is, I would choose a boundary that would present arrow heads at  
each end of the curve. In the case of rational functions, I would  
clip each branch separately.

I hope this answers the question.

Thanks.

On Jun 25, 2006, at 12:37 PM, Mojca Miklavec wrote:

 On 6/25/06, David Arnold wrote:
 Unfortunately, even though this works, mathematicians really want
 arrows at each end of the graph. Easy enough to do with drawdblarrow
 P withcolor blue, but the arrows then get clipped. What I really need
 is to adapt the code below so that my function is clipped to the
 boundary box, but then redrawn with arrows at each end of it. If
 anyone can adjust my code to do that, it would be much appreciated,
 and it would break down a barrier I've faced for years with metapost
 coding.

 Just for clarification: What would you do with a mexican hat
 (x^4-4*x^2+4, y between 0 and 3) it if would cut the boundary 4 times?
 Use 4 arrows or just the two at the end?

 Mojca
 ___
 ntg-context mailing list
 ntg-context@ntg.nl
 http://www.ntg.nl/mailman/listinfo/ntg-context

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Clipping again

2006-06-25 Thread Mojca Miklavec
On 6/25/06, David Arnold wrote:
 That is, I would choose a boundary that would present arrow heads at
 each end of the curve. In the case of rational functions, I would
 clip each branch separately.

 I hope this answers the question.

So that necessary means an arrowhead each time when a function crosses
the boundary if I understand correctly (i.e. 1/x would have 4
arrowheads)?

Mojca
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Clipping again

2006-06-25 Thread Hans Hagen
David Arnold wrote:
 Hi,

 I confess I got some earlier advice on this issue, but I've never  
 been able to apply it to find a resolution. In the buffer that  
 follows, I define a clipping box:

 % clipping path
 path cpath;
 cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle;
 cpath:=cpath scaled 1u;

 A function is created and scaled:

 % scale and draw graph
 P:=P scaled u;
 draw P withcolor blue;

 The picture is clipped and saved:

 % clip and save current picture
 picture pic;
 clip currentpicture to cpath;
 pic:=currentpicture;

 Then it is redrawn later.

 % redraw line
 draw pic;

 Unfortunately, even though this works, mathematicians really want  
 arrows at each end of the graph. Easy enough to do with drawdblarrow  
 P withcolor blue, but the arrows then get clipped. What I really need  
 is to adapt the code below so that my function is clipped to the  
 boundary box, but then redrawn with arrows at each end of it. If  
 anyone can adjust my code to do that, it would be much appreciated,  
 and it would break down a barrier I've faced for years with metapost  
 coding.

 Note that I've tried some stuff with cutbefore and cutafter with some  
 success. But I should remark that the code below is generated by a  
 perl script and some special coding we've set up to generate these  
 graphics on the fly for student quizzes. This is not a situation  
 where I can tweak an individual plot or two. Rather, our script might  
 generate 100 sets of the code below, all with different parameters.  
 So this magnifies the problem.
   
as you sat, the basics are in: 

P := (P cutbefore cpath) ;
P := (P cutafter cpath) ;
drawdblarrow P withcolor green;

it should not be too hard for a mathematician to make sure that this works ok; 
i think that as long as one makes sure that the directions are  right (do a 
reverse P if needed) 

Hans 

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Clipping again

2006-06-25 Thread David Arnold
Not necessary. Let me add comments to my code in places where I need  
help. My comments are marked with [DA 6/25].

\startbuffer
numeric w,h;
w=4cm;h=4cm;
% inititialize numerator and denominator of the slope of f
numeric a;
a=1.5;

% initialize choice of function
numeric choice;
choice=2; %=[DA 6/25]Test to see if code  
works for 1, 2, or 3.

% initialize type of reflection
numeric reflect;
reflect=3;   %==[DA 6/25]Test to see if code  
works for 1, 2, 3, or 4

% define linear function f
vardef f(expr x)=
a*x*x
enddef;

% define linear function g
vardef g(expr x)=
a*abs(x)
enddef;

% define linear function h
vardef h(expr x)=
a*x*(x-2)*(x+2)/2
enddef;

% define paths for functions f, g, and h, respectively
path P, F, G, H;

F:=(-5,f(-5));
for x=-5 step .1 until 5:
F:=F--(x,f(x));
endfor;

G:=(-5,g(-5));
for x=-5 step .1 until 5:
G:=G--(x,g(x));
endfor;

H:=(-5,h(-5));
for x=-5 step .1 until 5:
H:=H--(x,h(x));
endfor;

% choose the function to use, f, g, or h
if (choice=1):
P:=F;
elseif (choice=2):
P:=G;
else:
P:=H;
fi;

% choose the type of reflection
if (reflect=1):
P:=P;
elseif (reflect=2):
P:=P reflectedabout((0,0),(1,1));
elseif (reflect=3):
P:=P reflectedabout((0,0),(1,-1));
else:
P:=P reflectedabout((-1,0),(1,0));
fi;

% initialize scale
numeric u; 10u=w;

% scale and draw graph
P:=P scaled u;
draw P withcolor blue;

% clipping path
path cpath;
cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle;
cpath:=cpath scaled 1u;


%[DA 6/25]Replace this code from here to next mark with new  
clipping routine
% clip and save current picture
picture pic;
clip currentpicture to cpath;
pic:=currentpicture;

% erase currentpicture
currentpicture:=nullpicture;
%[DA 6/25]End of code to replace with new clipping routine

%[DA 6/25] Put new clipping routine here. It should return P clipped  
to clipping path
%[DA 6/25] for all choices of choice and reflect:

% draw grid
for k=-5u step 1u until 5u:
draw (-5u,k)--(5u,k) withcolor mygridcolor;
draw (k,-5u)--(k,5u) withcolor mygridcolor;
endfor;

% draw axes
drawarrow (-5u,0)--(5u,0);
drawarrow (0,-5u)--(0,5u);

% label axes
label.rt(btex $x$ etex, (5.2u,0));
label.top(btex $y$ etex, (0,5.2.u));
label.bot(btex $5$ etex, (5u,0));
label.lft(btex $5$ etex, (0,5u));

%[DA 6/25]==Replace with draw pic command with  
drawdblarrow P
% redraw line
draw pic;

\stopbuffer

\startlinecorrection[blank]
\midaligned{\processMPbuffer}
\stoplinecorrection





On Jun 25, 2006, at 1:14 PM, Mojca Miklavec wrote:

 On 6/25/06, David Arnold wrote:
 That is, I would choose a boundary that would present arrow heads at
 each end of the curve. In the case of rational functions, I would
 clip each branch separately.

 I hope this answers the question.

 So that necessary means an arrowhead each time when a function crosses
 the boundary if I understand correctly (i.e. 1/x would have 4
 arrowheads)?

 Mojca
 ___
 ntg-context mailing list
 ntg-context@ntg.nl
 http://www.ntg.nl/mailman/listinfo/ntg-context

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] feature request: clipping option for externalfigure

2006-04-13 Thread Peter Münster
On Wed, 12 Apr 2006, Hans Hagen wrote:

  \ruledhbox{\clip{\useMPgraphic{test}}}
 
  of course, I've already tried \clip{\externalfigure[...][...]} but the
  figure disappears completely. \clip{\useMPgraphic{test}} disappears too.
  And now I see: it works for PDF output, so there is probably just an error
  in the dvi driver.

 well, if you can find out what the problem is we can fix it (i dunno if
 it's in dvips or in the special driver of context; maybe something
 changes in dvips - which is probably only tested with latex -)

Probably I won't be able to find out the details, but I can make some
tests. I can already say, that dvips and xdvi behave the same: only white
area instead of the figure.
Cheers, Peter

-- 
http://pmrb.free.fr/contact/
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] feature request: clipping option for externalfigure

2006-04-12 Thread Peter Münster
On Wed, 12 Apr 2006, Hans Hagen wrote:

 \ruledhbox{\clip{\useMPgraphic{test}}}

Hello Hans,
of course, I've already tried \clip{\externalfigure[...][...]} but the
figure disappears completely. \clip{\useMPgraphic{test}} disappears too.
And now I see: it works for PDF output, so there is probably just an error
in the dvi driver.
Cheers and thanks, Peter

-- 
http://pmrb.free.fr/contact/
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] feature request: clipping option for externalfigure

2006-04-12 Thread Hans Hagen
� wrote:
 On Wed, 12 Apr 2006, Hans Hagen wrote:

   
 \ruledhbox{\clip{\useMPgraphic{test}}}
 

 Hello Hans,
 of course, I've already tried \clip{\externalfigure[...][...]} but the
 figure disappears completely. \clip{\useMPgraphic{test}} disappears too.
 And now I see: it works for PDF output, so there is probably just an error
 in the dvi driver.
   
well, if you can find out what the problem is we can fix it (i dunno if it's in 
dvips or in the special driver of context; maybe something changes in dvips - 
which is probably only tested with latex -) 

Hans 

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] feature request: clipping option for externalfigure

2006-04-11 Thread Hans Hagen
Vit Zyka wrote:
 Hans Hagen wrote:
   
 � wrote:

 
 Hello,
 I would like to clip an external eps-figure as LaTeX does with the clip
 option.

 Please consider the attachment as an example for en eps with white border
 and the following LaTeX and ConTeXt code:

 \starttext % no clipping possible here
 bla bla bla bla bla bla bla bla bla bla bla bla

 \externalfigure[test-img][width=0.5\textwidth]

 bla bla bla bla bla bla bla bla bla bla bla bla
 \stoptext

 \documentclass{article}
 \usepackage{graphicx}
 \begin{document} % here the white border is clipped away
 bla bla bla bla bla bla bla bla bla bla bla bla

 \includegraphics[clip,width=0.5\textwidth]{test-img}

 bla bla bla bla bla bla bla bla bla bla bla bla
 \end{document}

 Or is there already such (undocumented) feature?

  
   
 \clip[nx=10,ny=20,x=2,y=4]{}

 and alike (grep for clip)

 Hans
 

 Peter was asking for something different, I believe.

 \clip do the thing well but you have to measure a bb somewhere, e.g. in 
 GhostView. Since \externalfigure have to know bb then an option 'clip' 
 can do that without manual measuring. There might be even en extension: 
 apart from 'clip' option there could also be 'bb=10 20 100 200' option 
 for overwritting original boundingbox. Clipping a figures would be a bit 
 more strightforward.
   
i dunno what the intended effect is but here's an example

\starttext

\startuseMPgraphic{test}
draw fullcircle scaled 4cm withpen pencircle scaled 1cm ;
setbounds currentpicture to boundingbox fullcircle scaled 4cm ;
\stopuseMPgraphic

\ruledhbox{\useMPgraphic{test}}

\vskip3cm

\ruledhbox{\clip{\useMPgraphic{test}}}

\stoptext

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] feature request: clipping option for externalfigure

2006-04-11 Thread Vit Zyka
Hans Hagen wrote:
 Vit Zyka wrote:
 
Hans Hagen wrote:
  

� wrote:



Hello,
I would like to clip an external eps-figure as LaTeX does with the clip
option.

Please consider the attachment as an example for en eps with white border
and the following LaTeX and ConTeXt code:

\starttext % no clipping possible here
bla bla bla bla bla bla bla bla bla bla bla bla

\externalfigure[test-img][width=0.5\textwidth]

bla bla bla bla bla bla bla bla bla bla bla bla
\stoptext

\documentclass{article}
\usepackage{graphicx}
\begin{document} % here the white border is clipped away
bla bla bla bla bla bla bla bla bla bla bla bla

\includegraphics[clip,width=0.5\textwidth]{test-img}

bla bla bla bla bla bla bla bla bla bla bla bla
\end{document}

Or is there already such (undocumented) feature?

 
  

\clip[nx=10,ny=20,x=2,y=4]{}

and alike (grep for clip)

Hans


Peter was asking for something different, I believe.

\clip do the thing well but you have to measure a bb somewhere, e.g. in 
GhostView. Since \externalfigure have to know bb then an option 'clip' 
can do that without manual measuring. There might be even en extension: 
apart from 'clip' option there could also be 'bb=10 20 100 200' option 
for overwritting original boundingbox. Clipping a figures would be a bit 
more strightforward.
  
 
 i dunno what the intended effect is but here's an example
 
 \starttext
 
 \startuseMPgraphic{test}
 draw fullcircle scaled 4cm withpen pencircle scaled 1cm ;
 setbounds currentpicture to boundingbox fullcircle scaled 4cm ;
 \stopuseMPgraphic
 
 \ruledhbox{\useMPgraphic{test}}
 
 \vskip3cm
 
 \ruledhbox{\clip{\useMPgraphic{test}}}
 
 \stoptext

I see, I did not realize such simple usage of \clip (without options). 
That do exactly what was thinking about. One character of typing 
difference between:

   \clip{\externalfigure{test}}

and

   \externalfigure[clip]{test}

is not crutial:) So sorry for noise.

But as far as I know, \clip works only with left|top,width|height 
params. Could right|bottom be added (assuming at least one from 
left-width-right and top-height-bottom is missing - if not width|height 
is ignored)? Or there is again some secret that I missed?

Vit

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] feature request: clipping option for externalfigure

2006-04-08 Thread Hans Hagen
� wrote:
 Hello,
 I would like to clip an external eps-figure as LaTeX does with the clip
 option.

 Please consider the attachment as an example for en eps with white border
 and the following LaTeX and ConTeXt code:

 \starttext % no clipping possible here
 bla bla bla bla bla bla bla bla bla bla bla bla

 \externalfigure[test-img][width=0.5\textwidth]

 bla bla bla bla bla bla bla bla bla bla bla bla
 \stoptext

 \documentclass{article}
 \usepackage{graphicx}
 \begin{document} % here the white border is clipped away
 bla bla bla bla bla bla bla bla bla bla bla bla

 \includegraphics[clip,width=0.5\textwidth]{test-img}

 bla bla bla bla bla bla bla bla bla bla bla bla
 \end{document}

 Or is there already such (undocumented) feature?

   
\clip[nx=10,ny=20,x=2,y=4]{}

and alike (grep for clip)

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] feature request: clipping option for externalfigure

2006-04-08 Thread Vit Zyka
Hans Hagen wrote:
 � wrote:
 
Hello,
I would like to clip an external eps-figure as LaTeX does with the clip
option.

Please consider the attachment as an example for en eps with white border
and the following LaTeX and ConTeXt code:

\starttext % no clipping possible here
bla bla bla bla bla bla bla bla bla bla bla bla

\externalfigure[test-img][width=0.5\textwidth]

bla bla bla bla bla bla bla bla bla bla bla bla
\stoptext

\documentclass{article}
\usepackage{graphicx}
\begin{document} % here the white border is clipped away
bla bla bla bla bla bla bla bla bla bla bla bla

\includegraphics[clip,width=0.5\textwidth]{test-img}

bla bla bla bla bla bla bla bla bla bla bla bla
\end{document}

Or is there already such (undocumented) feature?

  
 
 \clip[nx=10,ny=20,x=2,y=4]{}
 
 and alike (grep for clip)
 
 Hans

Peter was asking for something different, I believe.

\clip do the thing well but you have to measure a bb somewhere, e.g. in 
GhostView. Since \externalfigure have to know bb then an option 'clip' 
can do that without manual measuring. There might be even en extension: 
apart from 'clip' option there could also be 'bb=10 20 100 200' option 
for overwritting original boundingbox. Clipping a figures would be a bit 
more strightforward.

Vit

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] feature request: clipping option for externalfigure

2006-04-07 Thread Peter Münster
Hello,
I would like to clip an external eps-figure as LaTeX does with the clip
option.

Please consider the attachment as an example for en eps with white border
and the following LaTeX and ConTeXt code:

\starttext % no clipping possible here
bla bla bla bla bla bla bla bla bla bla bla bla

\externalfigure[test-img][width=0.5\textwidth]

bla bla bla bla bla bla bla bla bla bla bla bla
\stoptext

\documentclass{article}
\usepackage{graphicx}
\begin{document} % here the white border is clipped away
bla bla bla bla bla bla bla bla bla bla bla bla

\includegraphics[clip,width=0.5\textwidth]{test-img}

bla bla bla bla bla bla bla bla bla bla bla bla
\end{document}

Or is there already such (undocumented) feature?

Cheers, Peter

-- 
http://pmrb.free.fr/contact/

test-img.eps
Description: PostScript document
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] feature request: clipping option for externalfigure

2006-04-07 Thread Taco Hoekwater
Peter Münster wrote:
 Hello,
 I would like to clip an external eps-figure as LaTeX does with the clip
 option.

Please browse through core-fig.tex. Around line 2100 there is
documentation for the \clip and \setiupclipping commands.

Cheers, taco
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] feature request: clipping option for externalfigure

2006-04-07 Thread Peter Münster
On Fri, 7 Apr 2006, Taco Hoekwater wrote:

 Peter Münster wrote:
  Hello,
  I would like to clip an external eps-figure as LaTeX does with the clip
  option.
 
 Please browse through core-fig.tex. Around line 2100 there is
 documentation for the \clip and \setiupclipping commands.

Thanks! I tried different options (x=1,y=1 or width=0.5\textwidth etc) but
whenever I use \clip[...]{\externalfigure...} the figure disappears.

What options should I use, to clip just exactly to the bounding-box (as the
LaTeX clip-option)?

Cheers, Peter

-- 
http://pmrb.free.fr/contact/
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] function machine

2005-12-28 Thread Mojca Miklavec
Please, put this example on the wiki (together with some sample images
that can be created, with or without some cheating).

The community would be greatful for that.

 Hans, Taco, et al,

 This is getting pretty close to the limit of my expertise. The good
 stuff of it is stolen from Metafun and mp-func.mp.

 Because of the way I handle clipping the path,

p:=p cutbefore cpath;
p:=reverse p;
p:=p cutbefore cpath;

 this will only work on functions (like lines, quadratics, and
 polynomials, maybe sinusoids) that both enter and leave the region
 inside the clipping path.

If I understand it properly (that you only want to draw the content
inside the square, while the function may be a circle or something
lying completely outside the region), you could also use something
like
clip currentpicture to cpath;
although you may have to change the code that draws double arrow then.

Mojca
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] function machine

2005-12-28 Thread David Arnold

Mojca,

I've used clip currentpicture to cpath before, then saved the result,  
draw the grid, draw the axes, then draw the saved clipped picture.  
But, you're right, I can't use drawdblarrow then.


In our classes, the drawdblarrow is important, having the same  
meaning as the ellipsis in 1, 3, 5, 7, 9, ..., that is, etc. In   
the case of a parabola opening upward, the arrow on the right half  
would indicate that the graph continues opening upward and to the  
right indefinitely. This is an important distinction from say a line  
segment that stops at one end, especially when asked to determine  
the domain and range of a function from its graph.


The clipping path is a huge convenience for an instructor crafting  
plots for an exam, activity, or lesson. Otherwise, the instructor  
would have to calculate the points where the graph leaves the  
bounding box (less painful if you use Matlab, Maple, or Mathematica,  
or a graphing calculator), a time consuming task.


I am not so concerned about a plot that might lie entirely outside  
the clipping window. That just requires, as on the graphing  
calculator, that one adjust the window (different xmin, xmax, xscl,  
ymin, ymax, and yscl). I just need to be able to clip the plot and  
retain the part that lies inside the clipping window, then use  
drawdblarrow on the part that remains.


My clip routine won't (cutbefore, reverse, cutbefore) won't work on  
something like y=sqrt(3-x) for two reasons:


1. A domain problem (easily solved by adjusting the drawfcn command  
to include two more parameters: beginx, endx.


2. The clip routine is not general enough to handle this situation.

So, there's room for improvement if you want to use this routine on  
irrational, rational, and logarithmic functions.



On Dec 28, 2005, at 8:57 AM, Mojca Miklavec wrote:


Please, put this example on the wiki (together with some sample images
that can be created, with or without some cheating).

The community would be greatful for that.


Hans, Taco, et al,

This is getting pretty close to the limit of my expertise. The good
stuff of it is stolen from Metafun and mp-func.mp.

Because of the way I handle clipping the path,

   p:=p cutbefore cpath;
   p:=reverse p;
   p:=p cutbefore cpath;

this will only work on functions (like lines, quadratics, and
polynomials, maybe sinusoids) that both enter and leave the region
inside the clipping path.


If I understand it properly (that you only want to draw the content
inside the square, while the function may be a circle or something
lying completely outside the region), you could also use something
like
clip currentpicture to cpath;
although you may have to change the code that draws double arrow then.

Mojca

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] Metapost -- What am I doing wrong

2005-12-25 Thread David Arnold

All,

Can someone tell me what I am doing wrong here?

%Ouput=pdf

\setupcolors[state=start]

\definecolor[gridlines][s=0.7]

\startMPinclusions
  color gridlines; gridlines=\MPcolor{gridlines}
\stopMPinclusions


\startMPgraphic{create function path f 5-by-5}

  %define clipping path
  path cpath;
  cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle;

  %create function path
  path p; p:=(-5,f(-5));
  for x=-5 step .1 until 5:
p:=p--(x,f(x));
  endfor;
  p:=p--(5,f(5));

  %clip function path to clipping path
  p:=p cutbefore cpath;
  p:=reverse p;
  p:=p cutbefore cpath;

\stopMPgraphic

\startMPgraphic{scale and draw f 5-by-5}

  %scale function path
  p:=p scaled u;

  %draw function path
  drawdblarrow p withcolor blue;

\stopMPgraphic

\startMPgraphic{draw axis 5-by-5}

  %draw the grid
  for k=-5u step 1u until 5u:
draw (k,-5u)--(k,5u) withcolor gridlines;
draw (-5u,k)--(5u,k) withcolor gridlines;
  endfor;

  %draw axes
  drawdblarrow (-5.2u,0)--(5.2u,0);
  drawdblarrow (0,-5.2u)--(0,5.2u);

  %label axes
  label.rt(btex $x$ etex, (5.2u,0));
  label.top(btex $y$ etex, (0,5.2u));
  label.bot(btex $5$ etex, (5u,0));
  label.lft(btex $5$ etex, (0,5u));

\stopMPgraphic

\starttext

\startMPpage

  %define function
  vardef f(expr x)=
x*x
  enddef;

  \useMPgraphic{create function path f 5-by-5}

  %initialize scale
  numeric u; 10u=2in;

  \useMPgraphic{draw axis 5-by-5}

  \useMPgraphic{scale and draw f 5-by-5}

  %draw plotted points
  for x=-2 step 1 until 2:
drawdot ((x,f(x)) scaled u) withpen pencircle scaled 4pt withcolor
blue;
  endfor;

\stopMPpage

\stoptext

%%% Local Variables:
%%% mode: conTeXt-en
%%% End:
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Metapost -- What am I doing wrong

2005-12-25 Thread Mojca Miklavec
David Arnold wrote:
 All,

 Can someone tell me what I am doing wrong here?

\useMPgraphic is meant to include whole figures inside text, not for
including portions of other metapost code inside metapost.

What you can do is to define new functions inside \startMPinclusions
... \stopMPinclusions or in an external file.

I don't doubt that implementing support for your way of thinking in
metafun is doable, but I don't know if it is worth the effort or not.

Here's an approximate transliteration into working code (I don't claim
that it's most elegant and I didn't know how to pass a function as an
argument, but I hope you can get an idea how to proceed. With slightly
more arguments/parameters to the defined functions, you can get rid of
hardcoding fives in your code for example.)

\setupcolors[state=start]

\definecolor[gridlines][s=0.7]

\startMPinclusions
color gridlines; gridlines=\MPcolor{gridlines};

% draw the grid 2n x 2n with unit length u
def draw_axis(expr n, u) =

% draw the grid
for i=-5 upto 5:
draw ((i,-5)--(i,5)) scaled u;
draw ((-5,i)--(5,i)) scaled u;
endfor;

%draw axes
drawdblarrow (-5.2u,0)--(5.2u,0);
drawdblarrow (0,-5.2u)--(0,5.2u);

%label axes
label.rt(btex $x$ etex, (5.2u,0));
label.top(btex $y$ etex, (0,5.2u));
label.bot(btex $5$ etex, (5u,0));
label.lft(btex $5$ etex, (0,5u));
enddef;

def scale_and_draw_f(expr p, u) =

%scale function path
%p:=p scaled u;

%draw function path
drawdblarrow (p scaled u) withcolor blue;

enddef;

% I don't know how to give the function as an argument,
% so I cheated and copied it here once more
vardef create_function_path_f =

%define clipping path
path cpath;
cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle;

%define function
vardef f(expr x)=
x*x
enddef;

%create function path
path p; p:=(-5,f(-5));
for x=-5 step .1 until 5:
p:=p--(x,f(x));
endfor;
p:=p--(5,f(5));

%clip function path to clipping path
p:=p cutbefore cpath;
p:=reverse p;
p:=p cutbefore cpath;

p
enddef;

\stopMPinclusions

\starttext

\startMPpage

%define function
vardef f(expr x)=
x*x
enddef;

path p;

p := create_function_path_f;

%initialize scale
numeric u; 10u=2in;

draw_axis(n, u);

scale_and_draw_f(p, u);

%draw plotted points
for x=-2 step 1 until 2:
drawdot ((x,f(x)) scaled u) withpen pencircle scaled 4pt 
withcolor blue;
endfor;

\stopMPpage

\stoptext


 %Ouput=pdf

 \setupcolors[state=start]

 \definecolor[gridlines][s=0.7]

 \startMPinclusions
color gridlines; gridlines=\MPcolor{gridlines}
 \stopMPinclusions


 \startMPgraphic{create function path f 5-by-5}

%define clipping path
path cpath;
cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle;

%create function path
path p; p:=(-5,f(-5));
for x=-5 step .1 until 5:
  p:=p--(x,f(x));
endfor;
p:=p--(5,f(5));

%clip function path to clipping path
p:=p cutbefore cpath;
p:=reverse p;
p:=p cutbefore cpath;

 \stopMPgraphic

 \startMPgraphic{scale and draw f 5-by-5}

%scale function path
p:=p scaled u;

%draw function path
drawdblarrow p withcolor blue;

 \stopMPgraphic

 \startMPgraphic{draw axis 5-by-5}

%draw the grid
for k=-5u step 1u until 5u:
  draw (k,-5u)--(k,5u) withcolor gridlines;
  draw (-5u,k)--(5u,k) withcolor gridlines;
endfor;

%draw axes
drawdblarrow (-5.2u,0)--(5.2u,0);
drawdblarrow (0,-5.2u)--(0,5.2u);

%label axes
label.rt(btex $x$ etex, (5.2u,0));
label.top(btex $y$ etex, (0,5.2u));
label.bot(btex $5$ etex, (5u,0));
label.lft(btex $5$ etex, (0,5u));

 \stopMPgraphic

 \starttext

 \startMPpage

%define function
vardef f(expr x)=
  x*x
enddef;

\useMPgraphic{create function path f 5-by-5}

%initialize scale
numeric u; 10u=2in;

\useMPgraphic{draw axis 5-by-5}

\useMPgraphic{scale and draw f 5-by-5}

%draw plotted points
for x=-2 step 1 until 2:
  drawdot ((x,f(x)) scaled u) withpen pencircle scaled 4pt withcolor
  blue;
endfor;

 \stopMPpage

 \stoptext
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Re: including swf files?

2005-12-18 Thread Hans Hagen

Patrick Gundlach wrote:


out of curiosity: how do I include a swf file into a pdf? So I can
click on 'play' (or
wherever) to start it?  

 


it's in the mediademo/mediashow files (i should be somewhere on the site -)
   



I've seen mediashow.pdf, but how do I integrate this in one of my own
documents?
 


grep for placerendering

(cont-new.tex and x-res-50)

so, one needs to reserve some area and then start/stop the media clip

(embedding the file in a pdffile is fragile [differes per pdf version])

Hans
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] drawdot fails?

2005-12-18 Thread David Arnold

All,

I am wondering why my dots are not filled with the drawdot command.

\startuseMPgraphic{yeqx2}
  %define function
  vardef f(expr x)=
x*x
  enddef;
  %define clipping path
  path cpath;
  cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle;
  %create function path
  path p; p:=(-5,f(-5));
  for x=-5 step .1 until 5:
p:=p--(x,f(x));
  endfor;
  p:=p--(5,f(5));
  %clip function path to clipping path
  p:=p cutbefore cpath;
  p:=reverse p;
  p:=p cutbefore cpath;
  %initialize scale
  numeric u; 10u=2in;
  %draw the grid
  for k=-5u step 1u until 5u:
draw (k,-5u)--(k,5u) withcolor 0.85white;
draw (-5u,k)--(5u,k) withcolor 0.85white;
  endfor;
  %draw axes
  drawdblarrow (-5.2u,0)--(5.2u,0);
  drawdblarrow (0,-5.2u)--(0,5.2u);
  %label axes
  label.rt(btex $x$ etex, (5.2u,0));
  label.top(btex $y$ etex, (0,5.2u));
  label.bot(btex $5$ etex, (5u,0));
  label.lft(btex $5$ etex, (0,5u));
  %scale function path
  p:=p scaled u;
  %draw function path
  drawdblarrow p withcolor blue;
  %draw plotted points
  for x=-2 step 1 until 2:
drawdot ((x,f(x)) scaled u) withpen pencircle scaled 4pt;
  endfor;
\stopuseMPgraphic

\placefigure{The simple parabola.}{\useMPgraphic{yeqx2}}
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] Re: function plotting

2005-10-05 Thread David Arnold

Alexander,

There is a lot of plots you can do with Metapost. Ordinary, every day  
stuff. For example:


beginfig(1);

% initialize a and c for f(x)=|x-a| and g(x)=c
numeric a, c;
a=-2;
c=2;

% initialize function label abcissas and postions
numeric flabel, glabel;
flabel:=-5;
glabel:=-5;

% define function f(x)=|x-a|
vardef f(expr x)=
abs(x-a)
enddef;

% draw line with given point and slope
path F;
F:=(-5,f(-5));
for x=-5 step 1 until 5:
F:=F--(x,f(x));
endfor;

% initialize scale
numeric u; 10u=4cm;

% the line
F:=F scaled 1u;
draw F withcolor blue;

% clipping path
path cpath;
cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle;
cpath:=cpath scaled 1u;

% clip and save current picture
picture pic;
clip currentpicture to cpath;
pic:=currentpicture;

% erase currentpicture
currentpicture:=nullpicture;

% draw grid
for k=-5u step 1u until 5u:
draw (-5u,k)--(5u,k) withcolor 0.85white;
draw (k,-5u)--(k,5u) withcolor 0.85white;
endfor;

% draw axes
drawarrow (-5u,0)--(5u,0);
drawarrow (0,-5u)--(0,5u);

% label axes
label.rt(btex $x$ etex, (5.2u,0));
label.top(btex $y$ etex, (0,5.2.u));
label.bot(btex $5$ etex, (5u,0));
label.lft(btex $5$ etex, (0,5u));

% redraw line
draw pic;

% label the functions f(x)=|x-a| and g(x)=c
pair D, E;
D:=(-5,f(-5)) scaled u;
label.lft(btex $f$ etex,D);
E:=(-5,2) scaled u;
label.lft(btex $g$ etex, E);

% draw the graph of g(x)=c
path G;
G:=(-5,2)--(5,2);
G:=G scaled u;
draw G withcolor blue;

endfig;

end.

And for a good stats package, see:

http://www-math.univ-poitiers.fr/~phan/statsmac.html

And for good circuits diagrams, see:

http://www.cnm.es/~pserra/schema/whatis.html

Don't give up on Metapost too soon. It's an awesome language and the  
file size created are small, a plus when you're document includes  
lots of figures and you want it to download in reasonable time on the  
internet.


___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] lilypond inclusion + pdf crop

2005-09-16 Thread andrea valle


How did you get your LilyPond fragments?
The only way I know would be to cut them from whole PDF pages with 
Acrobat.


Ah, I understand the point.
Yes, in my new composition I create a graph connecting some musical 
fragment (I don't wanna bore yuo too much with these details). In any 
case, I use Context as general typesetting environment, Metafun as 
vectorial, scalable, scriptable drawing engine, and lilypond as 
notation generator.
The idea is to produce lily files, to render them, to include them in a 
metafun drawing, where I can clip and place them opportunely, and to 
render context files. My program is written in Python.


But, it's true, I got involved in the problem of cropping PDFs output 
by lily (from the a6 format I chose). I solved using externalfigure 
clip in metafun.
I tried Imagemagik: it crops the PDFs but it seems that it rasterizes 
the image.
So, what can one use to crop a pdf? Preview in macosx, as acrobat, does 
the job, but I'd prefer too to use something from the command line.



But I'm only a newbie (and I don't really feel like learning Scheme).

I don't want, too. I'd like to have python :)

Here are two of the resulting scores (not totally finished yet)
www.semiotiche.it/andrea/membrana/nodi-I.pdf
www.semiotiche.it/andrea/membrana/nodi-II.pdf

and one of the context file
www.semiotiche.it/andrea/membrana/nodi-I.tex

Best

-a-

PS: ah, thanks to the list, without support I won't be able to draw a 
line...


___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] \limitatefirstline and the new beta

2005-09-15 Thread Peter Rolf
Hi Hans,

I just installed the latest beta (14.09.2005) and realised, that
\limitatefirstline is still unchanged. Just read my last mail from the
12th for the details. Sorry for stealing your time.

So I have either to change the description on the wiki, or you have to
change the macro :)

Greetings,

Peter


P.S.:

This is the version I'am currently using (but with 6ex instead of 2ex
tolerance). Using a variable value for the tolerance would make it even
more flexible and user friendly.


\def\limitatefirstline#1#2#3%
 {\hbox\bgroup\strut\dontcomplain
  \setbox\scratchbox\hbox{\begstrut#1\endstrut}%
  \ifdim\wd\scratchbox#2\relax
\setbox\scratchbox\hbox{#3}%
\hsize#2\relax
\advance\hsize-\wd\scratchbox
\setbox\scratchbox\vbox{\forgetall\veryraggedright#1}%
\setbox\scratchbox\vsplit\scratchbox to \lineheight
\vbox
  {\unvbox\scratchbox
   \global\setbox\plusone\lastbox
   \global\setbox\plusone\hbox{\strut\unhbox\plusone}%
   \hbox % to #2
 {\ifx\clip\undefined
\box\plusone
  \else\ifdim\wd\plusone\hsize

\lower\strutdepth\hbox{\clip[\c!width=\hsize,\c!height=\lineheight]{\hbox{\raise\strutdepth\box\plusone}}}%
  \else\ifdim\wd\plusone\dimexpr\hsize-6ex\relax

\lower\strutdepth\hbox{\clip[\c!width=\hsize,\c!height=\lineheight]{\hbox{\raise\strutdepth\hbox{\begstrut#1\endstrut%
  \else
\box\plusone
  \fi\fi\fi
  \removeunwantedspaces#3}}% \removeunwantedspaces\hss#3}}%
  \else
#1%
  \fi
  \egroup}
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] \limitatefirstline (or slave to the wiki)

2005-09-12 Thread Peter Rolf
Hi all,

Hans Hagen wrote:
 Peter Rolf wrote:
 
 another one
 
 \def\limitatefirstline#1#2#3%
  {\hbox\bgroup\strut
   \setbox\scratchbox\hbox{\begstrut#1\endstrut}%
   \ifdim\wd\scratchbox#2\relax
 \setbox\scratchbox\hbox{#3}%
 \hsize#2\relax
 \advance\hsize-\wd\scratchbox
 \setbox\scratchbox\vbox{\forgetall\veryraggedright#1}%
 \setbox\scratchbox\vsplit\scratchbox to \lineheight
 \vbox
   {\unvbox\scratchbox
\global\setbox\plusone\lastbox
\global\setbox\plusone\hbox{\strut\unhbox\plusone}%
\hbox % to #2
  {\ifx\clip\undefined
 \box\plusone
   \else\ifdim\wd\plusone\hsize

 \lower\strutdepth\hbox{\clip[\c!width=\hsize,\c!height=\lineheight]{\hbox{\raise\strutdepth\box\plusone}}}%
 
   \else
 \box\plusone
   \fi\fi
   \removeunwantedspaces#3}}% \removeunwantedspaces\hss#3}}%
   \else
 #1%
   \fi
   \egroup}
 
 Hans
 

Seems to work now :)

There is only one thing left. The clip mechanism is only called, if
breaking fails (which is not enought). An example:

My name is ThisPartIsVisiblexx.
 ^^^^
break   cut here

Breaking is successful, so \limitatefirstline acts nearly like
\limitatetext and you get

My name is...

  instead of

My name is ThisPartIsVisible...

There must be another test, which checks the quality (width) of the
breaking. If there is too much wasted space, clipping should be used
instead.

\else\ifdim\wd\plusone\dimexpr\hsize-2ex\relax% breaking tolerance
\lower\strutdepth\hbox{\clip[\c!width=\hsize,\c!height=\lineheight]{\hbox{\raise\strutdepth\hbox{\begstrut#1\endstrut%


I don't know, if boxing #1 is enought (more than one line problem)...
and we have to add \dontcomplain somewhere.
The tolerance of 2ex acts very greedy, so in most cases, clipping is
used (not usefull in common , but that's the way I need it).
Maybe 6-8ex are a better value for the final (no need to force 2ex to
others).

Thanks Hans. This was a hard birth, but the baby is looking nice :)

Peter
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] \limitatefirstline (or slave to the wiki)

2005-09-11 Thread Peter Rolf
Peter Rolf wrote:
 Hi all,
 
 I've tested the latest version of \limitatefirstline and it still
 doesn't work as expected. This is really a complex story (problem).
 
 - the clip mechanism cuts off the lowest part of some special chars
   (clipping graphics is easy, but I don't understand what happens here)
This one is unsolved. I added height to the clipping (\struttotal; maybe
not enought for \underbar). Now I get complete characters, but the
cropped text and the sentinel are not on the same baseline anymore.

 - text is sometimes cropped at word boundaries (example 110pt),
   instead of beeing clipped
I have fixed this one. There must be another check in case of a
successful break (else it acts like \limitatetext). Haven't thought
about this :)

So just ignore the prior mail (example) and look at the attached code
instead.

Greetings,

Peter
% interface=en output=pdftex
% Time-stamp: Sonntag, 11 September 2005 14:19:53; crop.tex
%

\setupcolors[state=start]
\setupstrut

\unprotect

%% \def\limitatefirstline#1#2#3%
%% {\hbox\bgroup\strut
%%  \setbox\scratchbox\hbox{#1}%
%%  \ifdim\wd\scratchbox#2\relax
%%\setbox\scratchbox\hbox{#3}%
%%\hsize#2\relax
%%\advance\hsize-\wd\scratchbox
%%\setbox\scratchbox\vbox{\forgetall\veryraggedright#1}%
%%\setbox\scratchbox\vsplit\scratchbox to \lineheight
%%\vbox
%%  {\unvbox\scratchbox
%%   \global\setbox\plusone\lastbox
%%   \global\setbox\plusone\hbox{\unhbox\plusone}%
%%   \hbox to #2
%% {\ifx\clip\undefined
%%\box\plusone
%%  \else\ifdim\wd\plusone\hsize
%%\clip[\c!width=\hsize]{\box\plusone}%
%%  \else
%%\box\plusone
%%  \fi\fi
%%  \removeunwantedspaces\hss#3}}%
%%  \else
%%#1%
%%  \fi
%%  \egroup}


\def\limitatefirstline#1#2#3%
{\hbox\bgroup\strut
 \setbox\scratchbox\hbox{#1}%
 \ifdim\wd\scratchbox#2\relax
   \setbox\scratchbox\hbox{#3}%
   \hsize#2\relax
   \advance\hsize-\wd\scratchbox
   \setbox\scratchbox\vbox{\forgetall\veryraggedright#1}%
   \setbox\scratchbox\vsplit\scratchbox to \lineheight
   \vbox
 {\unvbox\scratchbox
  \global\setbox\plusone\lastbox
  \global\setbox\plusone\hbox{\unhbox\plusone}%
  \hbox to #2
{\ifx\clip\undefined
   \box\plusone
 \else
   \ifdim\wd\plusone\hsize
 
\clip[\c!width=\hsize,\c!height=\struttotal]{\ruledhbox{\box\plusone}}
   \else
 \ifdim\wd\plusone\dimexpr\hsize-2ex\relax% tolerance for 
successful breaking
   \clip[\c!width=\hsize,\c!height=\struttotal]{\ruledhbox{#1}}% 
must be #1 here
 \else
   \box\plusone
 \fi
   \fi
 \fi
 \removeunwantedspaces\hss#3}}%
 \else
   #1%
 \fi
 \egroup}

\protect


\def\CropSymbol{\red...}%

\starttext

% blue for the limitatetext examples

\setupframed[offset=overlay, framecolor=lightgray]

\framed[width=8ex,height=\struttotal,background=color,backgroundcolor=black]{\white
 8ex}
\framed{\limitatefirstline{\underbar{WqTextdummy}}{8ex}{\CropSymbol}}
\framed{\limitatetext{\blue\underbar{WqTextdummy}}{8ex}{\CropSymbol}}

\blank

\framed[width=120pt,height=\struttotal,background=color,backgroundcolor=black]{\white
 120 pt}
\framed{\limitatefirstline{\textbar \_\textcircumflex\texttilde 
\%\$\#\textbraceleft \textbraceright \textpm \copyright \registered \pi 
\textdegree \}{120pt}{\CropSymbol}}
\framed{\limitatetext{\blue\textbar \_\textcircumflex\texttilde 
\%\$\#\textbraceleft \textbraceright \textpm \copyright \registered \pi 
\textdegree \}{120pt}{\CropSymbol}}

\blank

\framed[width=110pt,height=\struttotal,background=color,backgroundcolor=black]{\white
 110 pt}
\framed{\limitatefirstline{\textbar \_\textcircumflex\texttilde 
\%\$\#\textbraceleft \textbraceright \textpm \copyright \registered \pi 
\textdegree \}{110pt}{\CropSymbol}}
\framed{\limitatefirstline{This text is definitely too long to fit this 
frame.}{110pt}{\CropSymbol}}
\framed{\limitatetext{\blue This text is definitely too long to fit this 
frame.}{110pt}{\CropSymbol}}

\blank

\framed[width=100pt,height=\struttotal,background=color,backgroundcolor=black]{\white
 100 pt}
\framed{\limitatefirstline{\textbar \_\textcircumflex\texttilde 
\%\$\#\textbraceleft \textbraceright \textpm \copyright \registered\space \pi 
\textdegree \}{100pt}{\CropSymbol}}

\stoptext

%%% Local Variables:
%%% mode: context
%%% TeX-master: 
%%% End:
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] \limitatefirstline (or slave to the wiki)

2005-09-11 Thread Hans Hagen

Peter Rolf wrote:


Hi all,

I've tested the latest version of \limitatefirstline and it still
doesn't work as expected. This is really a complex story (problem).

- the clip mechanism cuts off the lowest part of some special chars
 (clipping graphics is easy, but I don't understand what happens here)
- text is sometimes cropped at word boundaries (example 110pt),
 instead of beeing clipped

The example file is appended and I use the latest beta. There is no
timeline, so fixing is not that urgent.
 



add some struts:

  \setbox\scratchbox\hbox{\begstrut#1\endstrut}%
  \ifdim\wd\scratchbox#2\relax
\setbox\scratchbox\hbox{\begstrut#3\endstrut}%

and remove your funny voffset 

Hans 


-
 Hans Hagen | PRAGMA ADE
 Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] \limitatefirstline (or slave to the wiki)

2005-09-11 Thread Peter Rolf
Hans Hagen wrote:
 Peter Rolf wrote:
 
 Hi all,

 I've tested the latest version of \limitatefirstline and it still
 doesn't work as expected. This is really a complex story (problem).

 - the clip mechanism cuts off the lowest part of some special chars
  (clipping graphics is easy, but I don't understand what happens here)
 - text is sometimes cropped at word boundaries (example 110pt),
  instead of beeing clipped

 The example file is appended and I use the latest beta. There is no
 timeline, so fixing is not that urgent.
  

 
 add some struts:
 
   \setbox\scratchbox\hbox{\begstrut#1\endstrut}%
   \ifdim\wd\scratchbox#2\relax
 \setbox\scratchbox\hbox{\begstrut#3\endstrut}%
 
 and remove your funny voffset

oeps, a relict from testing.

 Hans

Yep, it (later example) works with the struts. Thank you Hans!
But the clipping still needs the height parameter, else you get no
drawings below the baseline. I use \struttotal in my example, which can
be too small in case of underbar/underline.

working example is attached.

Greetings,

Peter
% interface=en output=pdftex
% Time-stamp: Sonntag, 11 September 2005 18:28:02; crop.tex
%

\setupcolors[state=start]

\unprotect


\def\limitatefirstline#1#2#3%
{\hbox\bgroup\strut
 \setbox\scratchbox\hbox{\begstrut#1\endstrut}%
 \ifdim\wd\scratchbox#2\relax
   \setbox\scratchbox\hbox{\begstrut#3\endstrut}%
   \hsize#2\relax
   \advance\hsize-\wd\scratchbox
   \setbox\scratchbox\vbox{\forgetall\veryraggedright\begstrut#1\endstrut}%
   \setbox\scratchbox\vsplit\scratchbox to \lineheight
   \vbox
 {\unvbox\scratchbox
  \global\setbox\plusone\lastbox
  \global\setbox\plusone\hbox{\unhbox\plusone}%
  \hbox to #2
{\ifx\clip\undefined
   \box\plusone
 \else
   \ifdim\wd\plusone\hsize
 
\clip[\c!width=\hsize,\c!height=\struttotal]{\ruledhbox{\box\plusone}}
   \else
 \ifdim\wd\plusone\dimexpr\hsize-2ex\relax% tolerance for 
successful breaking
   
\clip[\c!width=\hsize,\c!height=\struttotal]{\ruledhbox{\begstrut#1\endstrut}}% 
must be #1 here
 \else
   \box\plusone
 \fi
   \fi
 \fi
 \removeunwantedspaces\hss#3}}%
 \else
   #1%
 \fi
 \egroup}

\protect


\def\CropSymbol{\red...}%

\starttext

% blue for the limitatetext examples

\setupframed[offset=overlay, framecolor=lightgray]

\framed[width=8ex,height=\struttotal,background=color,backgroundcolor=black]{\white
 8ex}
\framed{\limitatefirstline{\underbar{WqTextdummy}}{8ex}{\CropSymbol}}
\framed{\limitatetext{\blue\underbar{WqTextdummy}}{8ex}{\CropSymbol}}

\blank

\framed[width=120pt,height=\struttotal,background=color,backgroundcolor=black]{\white
 120 pt}
\framed{\limitatefirstline{\textbar \_\textcircumflex\texttilde 
\%\$\#\textbraceleft \textbraceright \textpm \copyright \registered \pi 
\textdegree \}{120pt}{\CropSymbol}}
\framed{\limitatetext{\blue\textbar \_\textcircumflex\texttilde 
\%\$\#\textbraceleft \textbraceright \textpm \copyright \registered \pi 
\textdegree \}{120pt}{\CropSymbol}}

\blank

\framed[width=110pt,height=\struttotal,background=color,backgroundcolor=black]{\white
 110 pt}
\framed{\limitatefirstline{\textbar \_\textcircumflex\texttilde 
\%\$\#\textbraceleft \textbraceright \textpm \copyright \registered \pi 
\textdegree \}{110pt}{\CropSymbol}}
\framed{\limitatefirstline{This text is definitely too long to fit this 
frame.}{110pt}{\CropSymbol}}
\framed{\limitatetext{\blue This text is definitely too long to fit this 
frame.}{110pt}{\CropSymbol}}

\blank

\framed[width=100pt,height=\struttotal,background=color,backgroundcolor=black]{\white
 100 pt}
\framed{\limitatefirstline{\textbar \_\textcircumflex\texttilde 
\%\$\#\textbraceleft \textbraceright \textpm \copyright \registered\space \pi 
\textdegree \}{100pt}{\CropSymbol}}

\stoptext

%%% Local Variables:
%%% mode: context
%%% TeX-master: 
%%% End:
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] \limitatefirstline (or slave to the wiki)

2005-09-11 Thread Hans Hagen

Peter Rolf wrote:

 \ifdim\wd\plusone\dimexpr\hsize-2ex\relax% tolerance for 
successful breaking
   
\clip[\c!width=\hsize,\c!height=\struttotal]{\ruledhbox{\begstrut#1\endstrut}}% 
must be #1 here


This may fail, since it #1 may have more than one line, and this whole 
branch is entered when there are more lines


Hans  


-
 Hans Hagen | PRAGMA ADE
 Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] \limitatefirstline (or slave to the wiki)

2005-09-11 Thread Hans Hagen

Peter Rolf wrote:

another one

\def\limitatefirstline#1#2#3%
 {\hbox\bgroup\strut
  \setbox\scratchbox\hbox{\begstrut#1\endstrut}%
  \ifdim\wd\scratchbox#2\relax
\setbox\scratchbox\hbox{#3}%
\hsize#2\relax
\advance\hsize-\wd\scratchbox
\setbox\scratchbox\vbox{\forgetall\veryraggedright#1}%
\setbox\scratchbox\vsplit\scratchbox to \lineheight
\vbox
  {\unvbox\scratchbox
   \global\setbox\plusone\lastbox
   \global\setbox\plusone\hbox{\strut\unhbox\plusone}%
   \hbox % to #2
 {\ifx\clip\undefined
\box\plusone
  \else\ifdim\wd\plusone\hsize

\lower\strutdepth\hbox{\clip[\c!width=\hsize,\c!height=\lineheight]{\hbox{\raise\strutdepth\box\plusone}}}%

  \else
\box\plusone
  \fi\fi
  \removeunwantedspaces#3}}% \removeunwantedspaces\hss#3}}%
  \else
#1%
  \fi
  \egroup}

Hans


-
 Hans Hagen | PRAGMA ADE
 Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] \limitatefirstline (or slave to the wiki)

2005-09-09 Thread Peter Rolf
Hi all,

I've tested the latest version of \limitatefirstline and it still
doesn't work as expected. This is really a complex story (problem).

- the clip mechanism cuts off the lowest part of some special chars
  (clipping graphics is easy, but I don't understand what happens here)
- text is sometimes cropped at word boundaries (example 110pt),
  instead of beeing clipped

The example file is appended and I use the latest beta. There is no
timeline, so fixing is not that urgent.

And yes, I've cancelled my hollidays and will live for the wiki only
from now on :)

wiki, wiki, wiki,

Greetings,

Peter
% interface=en output=pdftex
% Time-stamp: Freitag, 09 September 2005 11:40:17; crop.tex
%

\setupcolors[state=start]

\unprotect

\def\limitatefirstline#1#2#3%
{\hbox\bgroup\strut
 \setbox\scratchbox\hbox{#1}%
 \ifdim\wd\scratchbox#2\relax
   \setbox\scratchbox\hbox{#3}%
   \hsize#2\relax
   \advance\hsize-\wd\scratchbox
   \setbox\scratchbox\vbox{\forgetall\veryraggedright#1}%
   \setbox\scratchbox\vsplit\scratchbox to \lineheight
   \vbox
 {\unvbox\scratchbox
  \global\setbox\plusone\lastbox
  \global\setbox\plusone\hbox{\unhbox\plusone}%
  \hbox to #2
{\ifx\clip\undefined
   \box\plusone
 \else\ifdim\wd\plusone\hsize
   
\clip[\c!width=\hsize,\c!height=\lineheight,\c!voffset=-4pt]{\box\plusone}%
 \else
   \box\plusone
 \fi\fi
 \removeunwantedspaces\hss#3}}%
 \else
   #1%
 \fi
 \egroup} 

\protect


\def\CropSymbol{\red...}%

\starttext

% blue for the limitatetext case

\setupframed[offset=overlay, framecolor=lightgray]

\framed[width=8ex,height=\struttotal,background=color,backgroundcolor=black]{\white
 8ex}
\framed{\limitatefirstline{\underbar{WqTextdummy}}{8ex}{\CropSymbol}}
\framed{\limitatetext{\blue\underbar{WqTextdummy}}{8ex}{\CropSymbol}}

\blank

\framed[width=120pt,height=\struttotal,background=color,backgroundcolor=black]{\white
 120 pt}
\framed{\limitatefirstline{\textbar \_\textcircumflex\texttilde 
\%\$\#\textbraceleft \textbraceright \textpm \copyright \registered \pi 
\textdegree \}{120pt}{\CropSymbol}}
\framed{\limitatetext{\blue\textbar \_\textcircumflex\texttilde 
\%\$\#\textbraceleft \textbraceright \textpm \copyright \registered \pi 
\textdegree \}{120pt}{\CropSymbol}}

\blank

\framed[width=110pt,height=\struttotal,background=color,backgroundcolor=black]{\white
 110 pt}
\framed{\limitatefirstline{\textbar \_\textcircumflex\texttilde 
\%\$\#\textbraceleft \textbraceright \textpm \copyright \registered \pi 
\textdegree \}{110pt}{\CropSymbol}}
\framed{\limitatefirstline{This text is definitely too long to fit this 
frame.}{110pt}{\CropSymbol}}
\framed{\limitatetext{\blue This text is definitely too long to fit this 
frame.}{110pt}{\CropSymbol}}

\blank

\framed[width=100pt,height=\struttotal,background=color,backgroundcolor=black]{\white
 100 pt}
\framed{\limitatefirstline{\textbar \_\textcircumflex\texttilde 
\%\$\#\textbraceleft \textbraceright \textpm \copyright \registered\space \pi 
\textdegree \}{100pt}{\CropSymbol}}

\stoptext

%%% Local Variables:
%%% mode: context
%%% TeX-master: 
%%% End:
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] cropping with \limitatefirstline

2005-09-08 Thread Peter Rolf
Hi,

Hans Hagen wrote:
 Peter Rolf wrote:
 
 Sorry to bother you Hans, but the macro is not working as expected...

 I can see the cropped text (\underbar + special symbols) and there is an
 hyphen symbol in the text only example.

 I've added the example code I used for tests with \limitatetext and
 \doboundtext.
  

 \def\limitatefirstline#1#2#3%
  {\hbox\bgroup\strut
   \setbox\scratchbox\hbox{#1}%
   \ifdim\wd\scratchbox#2\relax
 \setbox\scratchbox\hbox{#3}%
 \hsize#2\relax
 \advance\hsize-\wd\scratchbox
 \setbox\scratchbox\vbox{\forgetall\veryraggedright#1}%
 \setbox\scratchbox\vsplit\scratchbox to \lineheight
 \vbox
   {\unvbox\scratchbox
\global\setbox\plusone\lastbox
\global\setbox\plusone\hbox{\unhbox\plusone}}%


 \box\plusone\removeunwantedspaces#3%
   \else
 #1%
   \fi
   \egroup}
 
 of course there must be something to break (not possible with the non
 letters, so there you either need to add \hskip0pt's or do real clipping
 Hans

So it fails in any case of nonbreakable text.

How about adding a failsafe test ala

\ifdim\dimexpr\wd\plusone+\wd of sentinel\relax#2\relax
  \clip[width=\wd\plusone,...]{...#1...}\removeunwantedspaced#3%
\else
  \box\plusone\removeunwantedspaces#3%
\fi

One (ugly looking) partial character is still better than a bunch of
characters, that cross the width border.

I have played around with \clip, but it acts a little wild (vertical
position and height). Can't subdue it myself...

Greetings,

Peter
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] cropping with \limitatefirstline

2005-09-08 Thread Hans Hagen

Peter Rolf wrote:


Hi,

Hans Hagen wrote:
 


Peter Rolf wrote:

   


Sorry to bother you Hans, but the macro is not working as expected...

I can see the cropped text (\underbar + special symbols) and there is an
hyphen symbol in the text only example.

I've added the example code I used for tests with \limitatetext and
\doboundtext.


 


\def\limitatefirstline#1#2#3%
{\hbox\bgroup\strut
 \setbox\scratchbox\hbox{#1}%
 \ifdim\wd\scratchbox#2\relax
   \setbox\scratchbox\hbox{#3}%
   \hsize#2\relax
   \advance\hsize-\wd\scratchbox
   \setbox\scratchbox\vbox{\forgetall\veryraggedright#1}%
   \setbox\scratchbox\vsplit\scratchbox to \lineheight
   \vbox
 {\unvbox\scratchbox
  \global\setbox\plusone\lastbox
  \global\setbox\plusone\hbox{\unhbox\plusone}}%
   




 


   \box\plusone\removeunwantedspaces#3%
 \else
   #1%
 \fi
 \egroup}

of course there must be something to break (not possible with the non
letters, so there you either need to add \hskip0pt's or do real clipping
Hans
   



So it fails in any case of nonbreakable text.

How about adding a failsafe test ala

\ifdim\dimexpr\wd\plusone+\wd of sentinel\relax#2\relax
 \clip[width=\wd\plusone,...]{...#1...}\removeunwantedspaced#3%
\else
 \box\plusone\removeunwantedspaces#3%
\fi

One (ugly looking) partial character is still better than a bunch of
characters, that cross the width border.

I have played around with \clip, but it acts a little wild (vertical
position and height). Can't subdue it myself...
 


\unprotect

\def\limitatefirstline#1#2#3%
 {\hbox\bgroup\strut
  \setbox\scratchbox\hbox{#1}%
  \ifdim\wd\scratchbox#2\relax
\setbox\scratchbox\hbox{#3}%
\hsize#2\relax
\advance\hsize-\wd\scratchbox
\setbox\scratchbox\vbox{\forgetall\veryraggedright#1}%
\setbox\scratchbox\vsplit\scratchbox to \lineheight
\vbox
  {\unvbox\scratchbox
   \global\setbox\plusone\lastbox
   \global\setbox\plusone\hbox{\unhbox\plusone}%
   \ifx\clip\undefined
 \box\plusone\removeunwantedspaces#3%
   \else\ifdim\wd\plusone\hsize
 \hbox{\clip[\c!width=\hsize]{\box\plusone}#3}%
   \else
 \box\plusone\removeunwantedspaces#3%
   \fi\fi}%
  \else
#1%
  \fi
  \egroup}

\protect

\ruledhbox{\limitatefirstline{}{3cm}{...}}


now you owe this list at least three wiki pages -) 

Hans 


-
 Hans Hagen | PRAGMA ADE
 Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] cropping with \limitatefirstline

2005-09-08 Thread Peter Rolf
Hans, is this a trick to get even more wiki pages?
\clip is still running wild... :)

Greetings,

Peter

% interface=en output=pdftex
% Time-stamp: Donnerstag, 08 September 2005 18:28:23; crop.tex
%

\setupcolors[state=start]

\unprotect

\def\limitatefirstline#1#2#3%
 {\hbox\bgroup\strut
  \setbox\scratchbox\hbox{#1}%
  \ifdim\wd\scratchbox#2\relax
\setbox\scratchbox\hbox{#3}%
\hsize#2\relax
\advance\hsize-\wd\scratchbox
\setbox\scratchbox\vbox{\forgetall\veryraggedright#1}%
\setbox\scratchbox\vsplit\scratchbox to \lineheight
\vbox
  {\unvbox\scratchbox
   \global\setbox\plusone\lastbox
   \global\setbox\plusone\hbox{\unhbox\plusone}%
   \ifx\clip\undefined
 \box\plusone\removeunwantedspaces#3%
   \else\ifdim\wd\plusone\hsize
 \hbox{\clip[\c!width=\hsize]{\box\plusone}#3}%
   \else
 \box\plusone\removeunwantedspaces#3%
   \fi\fi}%
  \else
#1%
  \fi
  \egroup} 

\protect


\def\CropSymbol{\red...}%

\starttext

\setupframed[offset=overlay, height=\struttotal, framecolor=lightgray]
\setupframed[offset=overlay, height=\struttotal, framecolor=lightgray]

\framed[width=8ex,background=color,backgroundcolor=black]{\white 8ex}
\framed{\limitatefirstline{\underbar{Text dummy}}{8ex}{\CropSymbol}}
\framed{\limitatetext{\underbar{Text dummy}}{8ex}{\CropSymbol}}

\blank

\framed[width=120pt,background=color,backgroundcolor=black]{\white 120 pt}
\framed{\limitatefirstline{\textbar \_\textcircumflex\texttilde 
\%\$\#\textbraceleft \textbraceright \textpm \copyright \registered \pi 
\textdegree \}{120pt}{\CropSymbol}}

\blank

\framed[width=110pt,background=color,backgroundcolor=black]{\white 110 pt}
\framed{\limitatefirstline{\textbar \_\textcircumflex\texttilde 
\%\$\#\textbraceleft \textbraceright \textpm \copyright \registered \pi 
\textdegree \}{110pt}{\CropSymbol}}
\framed{\limitatefirstline{This text is definitely too long to fit this 
frame.}{110pt}{\CropSymbol}}

\blank

\framed[width=100pt,background=color,backgroundcolor=black]{\white 100 pt}
\framed{\limitatefirstline{\textbar \_\textcircumflex\texttilde 
\%\$\#\textbraceleft \textbraceright \textpm \copyright \registered\space \pi 
\textdegree \}{100pt}{\CropSymbol}}

\stoptext

%%% Local Variables:
%%% mode: context
%%% TeX-master: 
%%% End:
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] cropping with \limitatefirstline

2005-09-08 Thread Hans Hagen

Peter Rolf wrote:


Hans, is this a trick to get even more wiki pages?
\clip is still running wild... :)
 



hm, clipping looks ok here; is ok here; what version do you use? what 
sample text?


Hans

--

-
 Hans Hagen | PRAGMA ADE
 Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] cropping with \limitatefirstline

2005-09-08 Thread Peter Rolf
Hans Hagen wrote:
 Peter Rolf wrote:
 
 Hans, is this a trick to get even more wiki pages?
 \clip is still running wild... :)
  

 
 hm, clipping looks ok here; is ok here; what version do you use? what
 sample text?
 
seems to be my fault, but I have no time at the moment to find the
cause. more tomorrow...anyhow, thanks.

 Hans
 

Peter

P.S.: I will also fix the wiki page (with \limintatefirstline support).
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] cropping with \limitatefirstline

2005-09-08 Thread Hans Hagen

Peter Rolf wrote:


Hans, is this a trick to get even more wiki pages?
\clip is still running wild... :)
 


\unprotect

\def\limitatefirstline#1#2#3%
{\hbox\bgroup\strut
 \setbox\scratchbox\hbox{#1}%
 \ifdim\wd\scratchbox#2\relax
   \setbox\scratchbox\hbox{#3}%
   \hsize#2\relax
   \advance\hsize-\wd\scratchbox
   \setbox\scratchbox\vbox{\forgetall\veryraggedright#1}%
   \setbox\scratchbox\vsplit\scratchbox to \lineheight
   \vbox
 {\unvbox\scratchbox
  \global\setbox\plusone\lastbox
  \global\setbox\plusone\hbox{\unhbox\plusone}%
  \hbox to #2
{\ifx\clip\undefined
   \box\plusone
 \else\ifdim\wd\plusone\hsize
   \clip[\c!width=\hsize]{\box\plusone}%
 \else
   \box\plusone
 \fi\fi
 \removeunwantedspaces\hss#3}}%
 \else
   #1%
 \fi
 \egroup}

\protect

indeed, 4 wiki pages now -) 

Hans 


-
 Hans Hagen | PRAGMA ADE
 Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Clipping a path to a boundary --- Being more specific

2005-08-10 Thread David Arnold

Hans et al,

I think I've found something that works. I know ahead of time that 
there will only be two crossings of the clipping path boundary (I make 
sure of the by the parameters I choose):


beginfig(0);

% initialize a, h, and h for f(x)=ax^2+bx+c=a(x-h)^2+k
numeric a, h, k;
a=-1;
h=-3;
k=2;

% initialize scale
numeric u; 10u=3in;

% draw grid
for k=-5u step 1u until 5u:
draw (-5u,k)--(5u,k) withcolor 0.85white;
draw (k,-5u)--(k,5u) withcolor 0.85white;
endfor;

% draw axes
drawarrow (-5u,0)--(5u,0);
drawarrow (0,-5u)--(0,5u);

% label axes
label.rt(btex $x$ etex, (5.2u,0));
label.top(btex $y$ etex, (0,5.2.u));
label.bot(btex $5$ etex, (5u,0));
label.lft(btex $5$ etex, (0,5u));

% define function f(x)=a|x-b|+c
vardef f(expr x)=
a*(x-h)*(x-h)+k
enddef;

% draw line with given point and slope
path F;
F:=(-6,f(-6));
for x=-6 step .1 until 6:
F:=F--(x,f(x));
endfor;

% the line
F:=F scaled 1u;

% clipping path
path cpath;
cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle;
cpath:=cpath scaled 1u;

% clip the path F
pair A, B;
F:=F cutbefore cpath;
F:=reverse F;
F:=F cutbefore cpath;
drawdblarrow F;



endfig;

end.

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Clipping a path to a boundary --- Being more specific

2005-08-09 Thread David Arnold

Hans et al,

I tried what follows. But as far as I can see, I am not getting back a 
path q that is clipped to the cpath.


   vardef lastpath (expr p) =
   save _p_ ; path _p_ ; _p_ := origin ;
   for i within p :
   if stroked i : _p_ := pathpart i ; fi ;
   endfor ;
   _p_
   enddef ;

   vardef firstpath (expr p) =
   save _p_, _b_ ; path _p_ ; _p_ := origin ; boolean _b_ ; _b_ := 
false ;

   for i within p :
   if not _b_ : if stroked i : _b_ := true ; _p_ := pathpart i 
; fi ; fi ;

   endfor ;
   _p_
   enddef ;


beginfig(0);

%initialize a of f(x)=|x-a|
numeric a;
a=-2;

% initialize scale
numeric u; 10u=3in;

%function definition
vardef f(expr x)=
abs(x-a)
enddef;

%path
path F;
F:=(-5,f(-5));
for x=-5 step 1 until 5:
F:=F--(x,f(x));
endfor;

%scale and draw F
F:=F scaled u;
draw F withcolor blue;

%clip path
path cpath;
cpath:=(5,-5)--(5,5)--(-5,5)--(-5,-5)--cycle;
cpath:=cpath scaled u;
clip currentpicture to cpath;

%save and null currentpicture
picture pic;
pic:=currentpicture;
currentpicture:=nullpicture;

%retrieve first path
path q; q:=firstpath(pic);

%draw grid
for k=-5u step 1u until 5u:
draw (-5u,k)--(5u,k) withcolor 0.85white;
draw (k,-5u)--(k,5u) withcolor 0.85white;
endfor;

% draw axes
drawarrow (-5u,0)--(5u,0);
drawarrow (0,-5u)--(0,5u);

% label axes
label.rt(btex $x$ etex, (5.2u,0));
label.top(btex $y$ etex, (0,5.2.u));
label.bot(btex $5$ etex, (5u,0));
label.lft(btex $5$ etex, (0,5u));

drawdblarrow q withcolor blue;

endfig;

end.

On Aug 8, 2005, at 6:20 AM, Hans Hagen wrote:


David Arnold wrote:


Hans et al,

Let me try to be more specific. Here is a file which is very typical 
of the way I draw graphs for my mathematics classes. When you 
compile, you will see the graph of the absolute value of x-1. That 
is, it draws the graph of y=|x-1|, but only after clipping it to the 
cpath.  What I would like to do is draw the graph with the 
drawdblarrow command so that the graph of the absolute value ends in 
arrowheads. So, I want to clip the graph to the bounding box, save 
the picture, null the picture, then somehow extract the path into the 
variable F in its clipped form (not the original path F that extends 
outside the clip path) so that I can replace the command draw pic 
with drawdblarrow F.



hm, this need some more brainpower than the previous solution,

in mp-tool there is a repathed macro that does most of the job so 
let's extend that one a bit:


\starttext

\setupcolors[state=start]

\startMPpage

def restroke  suffix p = p := repathed (21,p) enddef ; % keep 
attributes

def reprocess suffix p = p := repathed (22,p) enddef ; % no attributes

vardef repathed (expr mode, p) text t =
 begingroup ;
 if mode=0 : save withcolor ; remapcolors ; fi ;
 save _p_, _pp_, _ppp_, _f_, _b_, _t_ ;
 picture _p_, _pp_, _ppp_ ; color _f_ ; path _b_ ; transform _t_ ;
 _b_ := boundingbox p ; _p_ := nullpicture ;
 for i within p :
   _f_ := (redpart i, greenpart i, bluepart i) ;
   if bounded i :
 _pp_ := repathed(mode,i) t ;
 setbounds _pp_ to pathpart i ;
 addto _p_ also _pp_ ;
   elseif clipped i :
 _pp_ := repathed(mode,i) t ;
 clip _pp_ to pathpart i ;
 addto _p_ also _pp_ ;
   elseif stroked i :
 if mode=21 :
   _ppp_ := i ; % indirectness is needed
   addto _p_ also image(scantokens(t   pathpart _ppp_)
 dashed dashpart i withpen penpart i
 withcolor _f_ ; ) ;
 elseif mode=22 :
   _ppp_ := i ; % indirectness is needed
   addto _p_ also image(scantokens(t   pathpart _ppp_)) ;
 else :
   addto _p_ doublepath pathpart i
 dashed dashpart i withpen penpart i
 withcolor _f_ % (redpart i, greenpart i, bluepart i)
 if mode=2 : t fi ;
 fi ;
   elseif filled  i :
 if mode=11 :
   _ppp_ := i ; % indirectness is needed
   addto _p_ also image(scantokens(t   pathpart _ppp_)
 withcolor _f_ ; ) ;
 elseif mode=12 :
   _ppp_ := i ; % indirectness is needed
   addto _p_ also image(scantokens(t   pathpart _ppp_)) ;
 else :
   addto _p_ contour pathpart i
 withcolor _f_
   if (mode=1) and (_f_refillbackground) : t fi ;
 fi ;
   elseif textual i : % textpart i   :
 if mode  4 :
   addto _p_ also i if mode=3 : t fi ;
 fi ;
   else :
 addto _p_ also i ;
   fi ;
 endfor ;
 setbounds _p_ to _b_ ;
 _p_
 endgroup
enddef ;


   picture pic; pic := image(
   draw fullcircle scaled 5cm withpen pencircle scaled 5mm ;
   draw fullsquare scaled 2cm withpen pencircle scaled 5mm ;
   fill fullcircle scaled 1cm withpen pencircle scaled 5mm ;
   ) ;

   redraw pic withpen pencircle scaled 1mm withcolor red ;
% restroke pic drawdblarrow ;
   pic := repathed(21,pic) drawdblarrow ;
   pic := repathed(11,pic) drawdblarrow ;
   draw pic ;

\stopMPpage

\stoptext

the new restroke variant takes a macro name that itself takes one 
argument, i.e. a path

Re: [NTG-context] Clipping a path to a boundary

2005-08-08 Thread Hans Hagen

David Arnold wrote:


Hans,

I tried:

% redraw line
path q;
q:=pathpart pic;
drawdblarrow q withcolor blue;

But it drew the clipping path. I wanted the part of the path inside 
the clipping path.


Am I missing something in your directions?



ok, here's the full solution ...

\starttext

\setupcolors[state=start]

\startMPpage
   vardef lastpath (expr p) =
   save _p_ ; path _p_ ; _p_ := origin ;
   for i within p :
   if stroked i : _p_ := pathpart i ; fi ;
   endfor ;
   _p_
   enddef ;
   vardef firstpath (expr p) =
   save _p_, _b_ ; path _p_ ; _p_ := origin ; boolean _b_ ; _b_ := 
false ;

   for i within p :
   if not _b_ : if stroked i : _b_ := true ; _p_ := pathpart i 
; fi ; fi ;

   endfor ;
   _p_
   enddef ;
  
   picture pic; pic := image(

   draw fullcircle scaled 5cm withpen pencircle scaled 5mm ;
   draw fullsquare scaled 2cm withpen pencircle scaled 5mm ;
   fill fullcircle scaled 1cm withpen pencircle scaled 5mm ;
   ) ;
  
   draw pic ;

   drawdblarrow lastpath (pic) withcolor blue ;
   drawdblarrow firstpath(pic) withcolor red ;
\stopMPpage

\stoptext

...  suitable for submission to the wiki


On Aug 7, 2005, at 2:56 PM, Hans Hagen wrote:


David Arnold wrote:



This works fine. However, what I need to do is somehow clip the path 
P to the bounding box, but retain the resulting cutpath in a path 
variable Q. That is, I need to cut off the parts of the path P that 
lie outside the bounding box 
cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle and store the clipped 
path in the path variable Q. The difficulty is I have no advance 
knowledge if the path P lies entirely inside the bounding box or if 
it escapes through one of the sides.



it all depends on what you want to do further on;
- you can do some cutbefore and cutafter trickery, i.e. determine 
intersectionpoints with the edges of the bbox and do some cutting


- if you just want the path back .. just ask for pathpart pic
Hans
-
 Hans Hagen | PRAGMA ADE
 Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context



___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context






--

-
 Hans Hagen | PRAGMA ADE
 Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Clipping a path to a boundary --- Being more specific

2005-08-08 Thread Hans Hagen

David Arnold wrote:


Hans et al,

Let me try to be more specific. Here is a file which is very typical 
of the way I draw graphs for my mathematics classes. When you compile, 
you will see the graph of the absolute value of x-1. That is, it draws 
the graph of y=|x-1|, but only after clipping it to the cpath.  What I 
would like to do is draw the graph with the drawdblarrow command so 
that the graph of the absolute value ends in arrowheads. So, I want to 
clip the graph to the bounding box, save the picture, null the 
picture, then somehow extract the path into the variable F in its 
clipped form (not the original path F that extends outside the clip 
path) so that I can replace the command draw pic with drawdblarrow F.



hm, this need some more brainpower than the previous solution,

in mp-tool there is a repathed macro that does most of the job so let's 
extend that one a bit:


\starttext

\setupcolors[state=start]

\startMPpage

def restroke  suffix p = p := repathed (21,p) enddef ; % keep attributes
def reprocess suffix p = p := repathed (22,p) enddef ; % no attributes

vardef repathed (expr mode, p) text t =
 begingroup ;
 if mode=0 : save withcolor ; remapcolors ; fi ;
 save _p_, _pp_, _ppp_, _f_, _b_, _t_ ;
 picture _p_, _pp_, _ppp_ ; color _f_ ; path _b_ ; transform _t_ ;
 _b_ := boundingbox p ; _p_ := nullpicture ;
 for i within p :
   _f_ := (redpart i, greenpart i, bluepart i) ;
   if bounded i :
 _pp_ := repathed(mode,i) t ;
 setbounds _pp_ to pathpart i ;
 addto _p_ also _pp_ ;
   elseif clipped i :
 _pp_ := repathed(mode,i) t ;
 clip _pp_ to pathpart i ;
 addto _p_ also _pp_ ;
   elseif stroked i :
 if mode=21 :
   _ppp_ := i ; % indirectness is needed
   addto _p_ also image(scantokens(t   pathpart _ppp_)
 dashed dashpart i withpen penpart i
 withcolor _f_ ; ) ;
 elseif mode=22 :
   _ppp_ := i ; % indirectness is needed
   addto _p_ also image(scantokens(t   pathpart _ppp_)) ;
 else :
   addto _p_ doublepath pathpart i
 dashed dashpart i withpen penpart i
 withcolor _f_ % (redpart i, greenpart i, bluepart i)
 if mode=2 : t fi ;
 fi ;
   elseif filled  i :
 if mode=11 :
   _ppp_ := i ; % indirectness is needed
   addto _p_ also image(scantokens(t   pathpart _ppp_)
 withcolor _f_ ; ) ;
 elseif mode=12 :
   _ppp_ := i ; % indirectness is needed
   addto _p_ also image(scantokens(t   pathpart _ppp_)) ;
 else :
   addto _p_ contour pathpart i
 withcolor _f_
   if (mode=1) and (_f_refillbackground) : t fi ;
 fi ;
   elseif textual i : % textpart i   :
 if mode  4 :
   addto _p_ also i if mode=3 : t fi ;
 fi ;
   else :
 addto _p_ also i ;
   fi ;
 endfor ;
 setbounds _p_ to _b_ ;
 _p_
 endgroup
enddef ;


   picture pic; pic := image(
   draw fullcircle scaled 5cm withpen pencircle scaled 5mm ;
   draw fullsquare scaled 2cm withpen pencircle scaled 5mm ;
   fill fullcircle scaled 1cm withpen pencircle scaled 5mm ;
   ) ;

   redraw pic withpen pencircle scaled 1mm withcolor red ;
% restroke pic drawdblarrow ;
   pic := repathed(21,pic) drawdblarrow ;
   pic := repathed(11,pic) drawdblarrow ;
   draw pic ;

\stopMPpage

\stoptext

the new restroke variant takes a macro name that itself takes one argument, i.e. a path, so in order to do more complex things, you need to define those 

Hans 


-
 Hans Hagen | PRAGMA ADE
 Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] Clipping a path to a boundary

2005-08-07 Thread David Arnold

All,

I'm looking for a new idea for something I need to do. I typically 
create a path on a domain [-5,5] as follows, a arbitrary. Then I 
randomly reflect the path about and axis, a line, or maybe rotate it. 
The result is that parts of the path may lie outside a bounding window.


% define linear function f
vardef f(expr x)=
a*x*x
enddef;

% define paths for functions f, g, and h, respectively
path P;

P:=(-5,f(-5));
for x=-5 step .1 until 5:
P:=P--(x,f(x));
endfor;

% initialize scale
numeric u; 10u=w;

% scale and draw graph
P:=P scaled u;
draw P withcolor blue;

% clipping path
path cpath;
cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle;
cpath:=cpath scaled 1u;

% clip and save current picture
picture pic;
clip currentpicture to cpath;
pic:=currentpicture;

% erase currentpicture
currentpicture:=nullpicture;

Then I do some stuff I need to do and bring back the path at a later 
time with:


draw pic;

This works fine. However, what I need to do is somehow clip the path P 
to the bounding box, but retain the resulting cutpath in a path 
variable Q. That is, I need to cut off the parts of the path P that lie 
outside the bounding box cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle 
and store the clipped path in the path variable Q. The difficulty is I 
have no advance knowledge if the path P lies entirely inside the 
bounding box or if it escapes through one of the sides.


Any hints, tips, etc., would be very appreciated.

Thanks.

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Clipping a path to a boundary

2005-08-07 Thread David Arnold

Hans,

I tried:

% redraw line
path q;
q:=pathpart pic;
drawdblarrow q withcolor blue;

But it drew the clipping path. I wanted the part of the path inside the 
clipping path.


Am I missing something in your directions?

On Aug 7, 2005, at 2:56 PM, Hans Hagen wrote:


David Arnold wrote:



This works fine. However, what I need to do is somehow clip the path 
P to the bounding box, but retain the resulting cutpath in a path 
variable Q. That is, I need to cut off the parts of the path P that 
lie outside the bounding box 
cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle and store the clipped 
path in the path variable Q. The difficulty is I have no advance 
knowledge if the path P lies entirely inside the bounding box or if 
it escapes through one of the sides.


it all depends on what you want to do further on;
- you can do some cutbefore and cutafter trickery, i.e. determine 
intersectionpoints with the edges of the bbox and do some cutting


- if you just want the path back .. just ask for pathpart pic
Hans
-
 Hans Hagen | PRAGMA ADE
 Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context



___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] Clipping a path to a boundary --- Being more specific

2005-08-07 Thread David Arnold

Hans et al,

Let me try to be more specific. Here is a file which is very typical of 
the way I draw graphs for my mathematics classes. When you compile, you 
will see the graph of the absolute value of x-1. That is, it draws the 
graph of y=|x-1|, but only after clipping it to the cpath.  What I 
would like to do is draw the graph with the drawdblarrow command so 
that the graph of the absolute value ends in arrowheads. So, I want to 
clip the graph to the bounding box, save the picture, null the picture, 
then somehow extract the path into the variable F in its clipped form 
(not the original path F that extends outside the clip path) so that I 
can replace the command draw pic with drawdblarrow F.


beginfig(0);

numeric a, c;
a=1;

% define function f(x)=|x-a|
vardef f(expr x)=
abs(x-a)
enddef;

% draw line with given point and slope
path F;
F:=(-5,f(-5));
for x=-5 step 1 until 5:
F:=F--(x,f(x));
endfor;

% initialize scale
numeric u; 10u=3in;

% the line
F:=F scaled 1u;
draw F withcolor blue;

% clipping path
path cpath;
cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle;
cpath:=cpath scaled 1u;

% clip and save current picture
picture pic;
clip currentpicture to cpath;
pic:=currentpicture;
currentpicture:=nullpicture;

% erase currentpicture
currentpicture:=nullpicture;

% draw grid
for k=-5u step 1u until 5u:
draw (-5u,k)--(5u,k) withcolor 0.85white;
draw (k,-5u)--(k,5u) withcolor 0.85white;
endfor;

% draw axes
drawarrow (-5u,0)--(5u,0);
drawarrow (0,-5u)--(0,5u);

% label axes
label.rt(btex $x$ etex, (5.2u,0));
label.top(btex $y$ etex, (0,5.2.u));
label.bot(btex $5$ etex, (5u,0));
label.lft(btex $5$ etex, (0,5u));

% redraw line
draw pic;

endfig;

end.

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] clip bug?

2005-05-28 Thread Vit Zyka

Dear Hans,

it seems to me that \clip was extended by the useful params 
left|right|top|bottomoffset. But they do not work:


\starttext
  \clip
[leftoffset=1cm,rightoffset=1cm,topoffset=2cm,bottomoffset=.5cm]
{\externalfigure[cow]}
\stoptext

Thanks
Vit

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] How to insert a full page pdf.

2005-04-20 Thread luigi.scarso
David Munger wrote:
Hi John,
John R. Culleton :
 

I need to insert some example pages from one document into
another. Both are 8.5 x 11. 

I have read the old posts about \startTEXpage etc. and looked at
the source code. But I still have a few questions:
1. Can I select e.g., just page 2 from the external document to
insert in my document? How?
   

I'm no expert, but here's the way I do it:
\externalfigure[filename][page=2]
Then, I adjust the clipping to -- for instance -- get rid of the page
number of the inserted `figure', as well as of its top and left margins.
\clip [ voffset=1.25in, % clip the topmost part of the inserted page
 

Also can help to specify width and height and factor
\externalfigure[filename][page=2,width..,height=.., factor=..]
See
http://texshow.contextgarden.net/
and search for \externalfigure
Actually it seems to me that inclusion doesn't manage things like 
comments etc.

luigi
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] How to insert a full page pdf.

2005-04-19 Thread David Munger
Hi John,

John R. Culleton :
 I need to insert some example pages from one document into
 another. Both are 8.5 x 11. 
 
 I have read the old posts about \startTEXpage etc. and looked at
 the source code. But I still have a few questions:
 1. Can I select e.g., just page 2 from the external document to
 insert in my document? How?

I'm no expert, but here's the way I do it:

\externalfigure[filename][page=2]

Then, I adjust the clipping to -- for instance -- get rid of the page
number of the inserted `figure', as well as of its top and left margins.

\clip [ voffset=1.25in, % clip the topmost part of the inserted page
hoffset=1.5in,  % clip the left margin of the inserted page
height=9in, % clip the bottom of the inserted page
width=5.1in]% clip the right margin
  {\externalfigure[filename][page=2]}}

And, if you like, you can put all this into a \midaligned{}.


 2. Does Context automatically bump its page counter to compensate
 for the inserted page or pages, or do I have to adjust it after
 each such insertion?

Well, if you treat the inserted PDF page as a figure, the page number of
your main document won't be affected. Just clip the page number (if any)
which lies on the inserted PDF page.


Regards,

David

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] OT: looking for metapost/fun examples

2005-03-26 Thread David Arnold
Gerben,
I am so happy I can contribute as a way of thanking you for all the 
work that you've done for us. Thanks. Here, try this one, which uses an 
RK4 routine. I just tried it out in Texshop, so I know they both 
compile.

%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;
%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, trajxy;
 pair L, R, B, T;
%Initialize clipping window
 a:=0; b:=150;   %left and right of viewing rectangle
 c:=0; d:=100;  %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 (x(t),y(t))
%Choose initial condition
 t:=tstart;
 x:=40;
 y:=20;
 trajxy:=(x,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;
  trajxy:=trajxy..(x,y);
  exitif ((ttstop) or (tb) or (xa) or (xb) or (yc) or (yd));
 endfor;
%Draw the paths x(t) and y(t) and clip them to bounding box
 draw trajxy xscaled ux yscaled uy withcolor red;
 clip currentpicture to (q xscaled ux yscaled uy);
%Initialize left and right endpoints on x-axis
 L=(a*ux,0);R=(b

Re: [NTG-context] imposition for a pdf file

2005-03-16 Thread luigi.scarso




Sorry ciro, but i like write tex code.

  save following code as test.tex
%%
%% save it as test.tex
%%
\setupcolors[state=start]
\starttext
\dorecurse{660}%
{\startTEXpage[width=3cm,height=2cm]
\vbox to \vsize{\vss
\hbox
to\hsize{\hss\framed[width=2cm,align={middle,lohi},background=""
\stopTEXpage}
\stoptext
  
  create the pdf
$texexec --pdf test.tex
  Save the following into my-imp.tex
%%
%% save as my-imp.tex
%%
%% \setuplayout
\starttext
\centerline{%
\externalfigure[test][page=1]
\externalfigure[test][page=3]
\externalfigure[test][page=5]
\externalfigure[test][page=7]
\externalfigure[test][page=9]
\externalfigure[test][page=11]
}
\blank[1cm]
\centerline{%
\externalfigure[test][page=2]
\externalfigure[test][page=4]
\externalfigure[test][page=6]
\externalfigure[test][page=8]
\externalfigure[test][page=10]
\externalfigure[test][page=12]
}
\stoptext
  
  
create the pdf
$ texexec --pdf my-imp



  
  the first page of my-imp.pdf now has 12 pages from test.pdf;

Now, if you have yourfile.pdf you can replace 
\externalfigure[test][page=8]
with 
\externalfigure[yourfile][page=8] etc.


\externalfigure has parameters page,width,height, etc...;
you can use it to scale to appropriate dimensions (they depends by size
of paper);search on wiki for externalfigure


Usually i make simple scripts that create my-imp.tex with correct
pagenumber (ie the pagenumber that i want to select); also i use \clip
(search on wiki) to correct some page and pdfinfo to have some
informations on pdf files.

But hans also replay with a quick and clean solution.



luigi






___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] help - spine centered figure

2005-01-30 Thread h h extern
Ciro A. Soto wrote:
I am hoping to get the version 1.  The other version
is like an exercise for me, to see how it would be
done.
well, the machinery is there, and there are several solutions, of which i show 
only one (watch further on how we enable clipping);

don't forget to submit this example to the wiki
\definelayer
  [page]
  [width=\paperwidth,
   height=\paperheight,
   offset=-\measure{page-bleed},
   doublesided=yes]
\setupbackgrounds
  [page]
  [background=page]
\setuppagenumbering
  [alternative=doublesided]
\definemeasure [page-bleed] [\dimexpr(10mm)]
\useexternalfigure
  [page-graphic]
  [cow]
  [ width=\dimexpr(2\paperwidth +2\measure{page-bleed}),
   height=\dimexpr( \paperheight+2\measure{page-bleed})]
\starttext
% cleaner here
\startstandardmakeup[doublesized=no,page={empty,left}]
\setlayer
  [page] [preset=lefttop]
  {\externalfigure[page-graphic]}
\stopstandardmakeup
\startstandardmakeup[doublesized=no,page=right]
\setlayer
  [page] [preset=righttop]
  {\externalfigure[page-graphic]}
\stopstandardmakeup
% less intuitive here
%
% \page[left]
%
% \setlayer
%   [page] [left] [preset=lefttop]
%   {\externalfigure[page-graphic]}
%
% \setlayer
%   [page] [right] [preset=righttop]
%   {\externalfigure[page-graphic]}
%
% \startstandardmakeup
%   flush a page
% \stopstandardmakeup
% to show bleeding:
\setuppapersize
  [A4][A3]
\setuplayout
  [location=middle]
\setupbackgrounds
  [page][frame=on]
% add this in order to clip
\setuplayout
  [clipoffset=\measure{page-bleed}]
\startstandardmakeup[doublesized=no,page={empty,left}]
\setlayer
  [page] [preset=lefttop]
  {\externalfigure[page-graphic]}
\stopstandardmakeup
\startstandardmakeup[doublesized=no,page=right]
\setlayer
  [page] [preset=righttop]
  {\externalfigure[page-graphic]}
\stopstandardmakeup
\stoptext
-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] \reuseMPgraphic error

2004-11-08 Thread Hans Hagen
Matthias Weber wrote:
On Nov 4, 2004, at 1:07 PM, David Arnold wrote:
All,
This file:
\setupoutput[pdf]
\startreusableMPgraphic{layout 1}
pickup pencircle scaled 1mm;
fill unitsquare xyscaled (7cm,8cm) withcolor 0.85white;
fill unitsquare xyscaled (5cm,5cm) shifted (1cm,1.5cm) withcolor 
0.625yellow;
fill unitsquare xyscaled (5cm,1cm) shifted (1cm,0.5cm) withcolor 
0.625red;
fill unitsquare xyscaled (5cm,1cm) shifted (1cm,6.5cm) withcolor 
0.625red;
draw unitsquare xyscaled (5cm,7cm) shifted (1cm,0.5cm) withcolor 
0.25white;
drawarrow (2cm,8cm)--top (2cm,7.5cm);
drawarrow (0cm,7cm)--lft(1cm,7cm);
clip currentpicture to unitsquare xyscaled (7cm,8cm);
\stopreusableMPgraphic

\startreusableMPgraphic{layout 2}
\includeMPgraphic{layout 1}

^
is that allowed? (it works without)
it is allowed, but only when layout 1 is a usableMPgraphic
Hans
-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] No color even though \setupcolors[state=start]

2004-11-04 Thread David Arnold
All,

Can anyone tell me why I am not getting any color (red and yellow)?

\startuseMPgraphic{layout 1}
pickup pencircle scaled 1mm;
fill unitsquare xyscaled (7cm,8cm) withcolor 0.85white;
fill unitsquare xyscaled (5cm,5cm) shifted (1cm,1.5cm) withcolor 0.625yellow;
fill unitsquare xyscaled (5cm,1cm) shifted (1cm,0.5cm) withcolor 0.625red;
fill unitsquare xyscaled (5cm,1cm) shifted (1cm,6.5cm) withcolor 0.625red;
fill unitsquare xyscaled (5cm,7cm) shifted (1cm,0.5cm) withcolor 0.25white;
drawarrow (2cm,8cm)--top (2cm,7.5cm);
drawarrow (0cm,7cm)--lft(1cm,7cm);
clip currentpicture to unitsquare xyscaled (7cm,8cm);
\stopuseMPgraphic

\startuseMPgraphic{layout 2}
\includeMPgraphic{layout 1}
clip currentpicture to unitsquare scaled 3cm shifted (0,5cm);
currentpicture:=currentpicture scaled 2 shifted (0,-8cm);
setbounds currentpicture to unitsquare xyscaled (6cm,8cm);
\stopuseMPgraphic


\setupcolors[state=start]

\starttext

\startlinecorrection[blank]
\hbox
{\useMPgraphic{layout 1}\hskip1cm
\useMPgraphic{layout 2}}
\stoplinecorrection

\stoptext

___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] No color even though \setupcolors[state=start]

2004-11-04 Thread David Arnold
All,

Duh! draw, not fill! Sorry.

At 09:07 AM 11/4/04 -0800, you wrote:
All,

Can anyone tell me why I am not getting any color (red and yellow)?

\startuseMPgraphic{layout 1}
pickup pencircle scaled 1mm;
fill unitsquare xyscaled (7cm,8cm) withcolor 0.85white;
fill unitsquare xyscaled (5cm,5cm) shifted (1cm,1.5cm) withcolor 0.625yellow;
fill unitsquare xyscaled (5cm,1cm) shifted (1cm,0.5cm) withcolor 0.625red;
fill unitsquare xyscaled (5cm,1cm) shifted (1cm,6.5cm) withcolor 0.625red;
fill unitsquare xyscaled (5cm,7cm) shifted (1cm,0.5cm) withcolor 0.25white;

draw unitsquare xyscaled (5cm,7cm) shifted (1cm,0.5cm) withcolor 0.25white;

drawarrow (2cm,8cm)--top (2cm,7.5cm);
drawarrow (0cm,7cm)--lft(1cm,7cm);
clip currentpicture to unitsquare xyscaled (7cm,8cm);
\stopuseMPgraphic

\startuseMPgraphic{layout 2}
\includeMPgraphic{layout 1}
clip currentpicture to unitsquare scaled 3cm shifted (0,5cm);
currentpicture:=currentpicture scaled 2 shifted (0,-8cm);
setbounds currentpicture to unitsquare xyscaled (6cm,8cm);
\stopuseMPgraphic


\setupcolors[state=start]

\starttext

\startlinecorrection[blank]
\hbox
{\useMPgraphic{layout 1}\hskip1cm
\useMPgraphic{layout 2}}
\stoplinecorrection

\stoptext

___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] No color even though \setupcolors[state=start]

2004-11-04 Thread Matthias Weber
Put your text  between \startproduct ... \stopproduct
Matthias
On Nov 4, 2004, at 12:07 PM, David Arnold wrote:
All,
Can anyone tell me why I am not getting any color (red and yellow)?
\startuseMPgraphic{layout 1}
pickup pencircle scaled 1mm;
fill unitsquare xyscaled (7cm,8cm) withcolor 0.85white;
fill unitsquare xyscaled (5cm,5cm) shifted (1cm,1.5cm) withcolor 
0.625yellow;
fill unitsquare xyscaled (5cm,1cm) shifted (1cm,0.5cm) withcolor 
0.625red;
fill unitsquare xyscaled (5cm,1cm) shifted (1cm,6.5cm) withcolor 
0.625red;
fill unitsquare xyscaled (5cm,7cm) shifted (1cm,0.5cm) withcolor 
0.25white;
drawarrow (2cm,8cm)--top (2cm,7.5cm);
drawarrow (0cm,7cm)--lft(1cm,7cm);
clip currentpicture to unitsquare xyscaled (7cm,8cm);
\stopuseMPgraphic

\startuseMPgraphic{layout 2}
\includeMPgraphic{layout 1}
clip currentpicture to unitsquare scaled 3cm shifted (0,5cm);
currentpicture:=currentpicture scaled 2 shifted (0,-8cm);
setbounds currentpicture to unitsquare xyscaled (6cm,8cm);
\stopuseMPgraphic
\setupcolors[state=start]
\starttext
\startlinecorrection[blank]
\hbox
{\useMPgraphic{layout 1}\hskip1cm
\useMPgraphic{layout 2}}
\stoplinecorrection
\stoptext
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context

___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] \reuseMPgraphic error

2004-11-04 Thread David Arnold
All,

This file:

\setupoutput[pdf]

\startreusableMPgraphic{layout 1}
pickup pencircle scaled 1mm;
fill unitsquare xyscaled (7cm,8cm) withcolor 0.85white;
fill unitsquare xyscaled (5cm,5cm) shifted (1cm,1.5cm) withcolor 0.625yellow;
fill unitsquare xyscaled (5cm,1cm) shifted (1cm,0.5cm) withcolor 0.625red;
fill unitsquare xyscaled (5cm,1cm) shifted (1cm,6.5cm) withcolor 0.625red;
draw unitsquare xyscaled (5cm,7cm) shifted (1cm,0.5cm) withcolor 0.25white;
drawarrow (2cm,8cm)--top (2cm,7.5cm);
drawarrow (0cm,7cm)--lft(1cm,7cm);
clip currentpicture to unitsquare xyscaled (7cm,8cm);
\stopreusableMPgraphic


\startreusableMPgraphic{layout 2}
\includeMPgraphic{layout 1}
clip currentpicture to unitsquare scaled 3cm shifted (0,5cm);
currentpicture:=currentpicture scaled 2 shifted (0,-8cm);
setbounds currentpicture to unitsquare xyscaled (6cm,8cm);
\stopreusableMPgraphic



\setupcolors[state=start]

\starttext

Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.

 \hbox
{\reuseMPgraphic{layout 1}\hskip1cm
\reuseMPgraphic{layout 2}}

Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.

\page
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.

\startlinecorrection[blank]
 \hbox
{\reuseMPgraphic{layout 1}\hskip1cm
\reuseMPgraphic{layout 2}}
\stoplinecorrection

Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.

\stoptext


Produces this error:

ERROR: Undefined control sequence.

--- TeX said ---
\getobject ...-\blabelgroup \let \dohandleobject 
  \dogetobject \csname
\r!ob...
argument \includeMPgraphic {layout 1}
clip currentpicture to unitsquare
sc...

\nonowriteMPgraphicline ... \long \edef \ascii {#1
  }\expandafter
\flushMPgrap...

\shortMPflushN ...nowriteMPgraphicline #1#2\MPend 
  \expandafter
\shortMPflush...
argument ...itsquare scaled 3cm shifted (0,5cm);

currentpicture:=currentpi...

\writeMPgraphicshortN ... \space \shortMPflushN #1
  \empty ;\relax ;\egroup 
...
l.40 \reuseMPgraphic{layout 2}}
   
--- HELP ---
TeX encountered an unknown command name. You probably misspelled the
name. If this message occurs when a LaTeX command is being processed,
the command is probably in the wrong place---for example, the error
can be produced by an \item command that's not inside a list-making
environment. The error can also be caused by a missing \documentstyle
command.

Any ideas?
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] \reuseMPgraphic error

2004-11-04 Thread Matthias Weber
On Nov 4, 2004, at 1:07 PM, David Arnold wrote:
All,
This file:
\setupoutput[pdf]
\startreusableMPgraphic{layout 1}
pickup pencircle scaled 1mm;
fill unitsquare xyscaled (7cm,8cm) withcolor 0.85white;
fill unitsquare xyscaled (5cm,5cm) shifted (1cm,1.5cm) withcolor 
0.625yellow;
fill unitsquare xyscaled (5cm,1cm) shifted (1cm,0.5cm) withcolor 
0.625red;
fill unitsquare xyscaled (5cm,1cm) shifted (1cm,6.5cm) withcolor 
0.625red;
draw unitsquare xyscaled (5cm,7cm) shifted (1cm,0.5cm) withcolor 
0.25white;
drawarrow (2cm,8cm)--top (2cm,7.5cm);
drawarrow (0cm,7cm)--lft(1cm,7cm);
clip currentpicture to unitsquare xyscaled (7cm,8cm);
\stopreusableMPgraphic

\startreusableMPgraphic{layout 2}
\includeMPgraphic{layout 1}
^
is that allowed? (it works without)

clip currentpicture to unitsquare scaled 3cm shifted (0,5cm);
currentpicture:=currentpicture scaled 2 shifted (0,-8cm);
setbounds currentpicture to unitsquare xyscaled (6cm,8cm);
\stopreusableMPgraphic

\setupcolors[state=start]
\starttext
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
 \hbox
{\reuseMPgraphic{layout 1}\hskip1cm
\reuseMPgraphic{layout 2}}
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
\page
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
\startlinecorrection[blank]
 \hbox
{\reuseMPgraphic{layout 1}\hskip1cm
\reuseMPgraphic{layout 2}}
\stoplinecorrection
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
\stoptext
Produces this error:
ERROR: Undefined control sequence.
--- TeX said ---
\getobject ...-\blabelgroup \let \dohandleobject
  \dogetobject \csname
\r!ob...
argument \includeMPgraphic {layout 1}
clip currentpicture to 
unitsquare
sc...

\nonowriteMPgraphicline ... \long \edef \ascii {#1
  }\expandafter
\flushMPgrap...
\shortMPflushN ...nowriteMPgraphicline #1#2\MPend
  \expandafter
\shortMPflush...
argument ...itsquare scaled 3cm shifted (0,5cm);
currentpicture:=currentpi...
\writeMPgraphicshortN ... \space \shortMPflushN #1
  \empty ;\relax 
;\egroup
...
l.40 \reuseMPgraphic{layout 2}}

--- HELP ---
TeX encountered an unknown command name. You probably misspelled the
name. If this message occurs when a LaTeX command is being processed,
the command is probably in the wrong place---for example, the error
can be produced by an \item command that's not inside a list-making
environment. The error can also be caused by a missing \documentstyle
command.
Any ideas?
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context

___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] \reuseMPgraphic error

2004-11-04 Thread David Arnold
Matthias,

This was allowed at one time. It is straight out of the Metafun manual.

At 02:03 PM 11/4/04 -0500, you wrote:

On Nov 4, 2004, at 1:07 PM, David Arnold wrote:

 All,

 This file:

 \setupoutput[pdf]

 \startreusableMPgraphic{layout 1}
 pickup pencircle scaled 1mm;
 fill unitsquare xyscaled (7cm,8cm) withcolor 0.85white;
 fill unitsquare xyscaled (5cm,5cm) shifted (1cm,1.5cm) withcolor 
 0.625yellow;
 fill unitsquare xyscaled (5cm,1cm) shifted (1cm,0.5cm) withcolor 
 0.625red;
 fill unitsquare xyscaled (5cm,1cm) shifted (1cm,6.5cm) withcolor 
 0.625red;
 draw unitsquare xyscaled (5cm,7cm) shifted (1cm,0.5cm) withcolor 
 0.25white;
 drawarrow (2cm,8cm)--top (2cm,7.5cm);
 drawarrow (0cm,7cm)--lft(1cm,7cm);
 clip currentpicture to unitsquare xyscaled (7cm,8cm);
 \stopreusableMPgraphic


 \startreusableMPgraphic{layout 2}
 \includeMPgraphic{layout 1}

^
is that allowed? (it works without)


 clip currentpicture to unitsquare scaled 3cm shifted (0,5cm);
 currentpicture:=currentpicture scaled 2 shifted (0,-8cm);
 setbounds currentpicture to unitsquare xyscaled (6cm,8cm);
 \stopreusableMPgraphic



 \setupcolors[state=start]

 \starttext

 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.

  \hbox
 {\reuseMPgraphic{layout 1}\hskip1cm
 \reuseMPgraphic{layout 2}}

 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.

 \page
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.

 \startlinecorrection[blank]
  \hbox
 {\reuseMPgraphic{layout 1}\hskip1cm
 \reuseMPgraphic{layout 2}}
 \stoplinecorrection

 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.
 Now is the time for all good men to come to the aid of their country.

 \stoptext


 Produces this error:

 ERROR: Undefined control sequence.

 --- TeX said ---
 \getobject ...-\blabelgroup \let \dohandleobject
   \dogetobject \csname
 \r!ob...
 argument \includeMPgraphic {layout 1}
 clip currentpicture to 
 unitsquare
 sc...

 \nonowriteMPgraphicline ... \long \edef \ascii {#1
   }\expandafter
 \flushMPgrap...

 \shortMPflushN ...nowriteMPgraphicline #1#2\MPend
   \expandafter
 \shortMPflush...
 argument ...itsquare scaled 3cm shifted (0,5cm);

 currentpicture:=currentpi...

 \writeMPgraphicshortN ... \space \shortMPflushN #1
   \empty ;\relax 
 ;\egroup
 ...
 l.40 \reuseMPgraphic{layout 2}}

 --- HELP ---
 TeX encountered an unknown command name. You probably misspelled the
 name. If this message occurs when a LaTeX command is being processed,
 the command is probably in the wrong place---for example, the error
 can be produced by an \item command that's not inside a list-making
 environment. The error can also be caused by a missing \documentstyle
 command.

 Any ideas?
 ___
 ntg-context mailing list
 [EMAIL PROTECTED

[NTG-context] row background (TABLE)

2004-09-08 Thread Peter Rolf
Hello,
I need a way to set the background for a complete row in the TABLE 
environment.
TABLE uses \framed for every single entry. But if I set the framed 
parameters
right after \bTR, it sets the defaults for all the \bTD \eTD entries and 
not for that
row. See example below to give you an idea.

So what I need is an additional \framed for every row entry or any 
other miracle :)

Greetings,
   Peter

% interface=en output=pdftex
\setupcolors[state=start]
\startuniqueMPgraphic{row}
 save ow,oh,p ;
 path p ;
 ow:= \overlaywidth ; oh:= \overlayheight ;
 p:= unitsquare xyscaled(ow,oh) ;
 fill p withcolor yellow ;
 draw origin--(ow,0) yshifted oh withcolor blue ;
 clip currentpicture to boundingbox p ;
\stopuniqueMPgraphic
\defineoverlay[rowbg] [\uniqueMPgraphic{row}]
\starttext
% what I want (but in a TABLE)
\framed[background={rowbg}, align={middle,lohi}, strut=no, offset=0pt]{%
 \setupframed[frame=off]
 \framed{Just}\framed[background=color,backgroundcolor=white]{a 
stupid}\framed{test}}

\blank[big]
% what I get
\bTABLE
 \bTR [background={rowbg}, offset=0pt]
   \bTD Just \eTD
   \bTD [background=color,backgroundcolor=white] a stupid \eTD
   \bTD test \eTD
 \eTR
\eTABLE
\stoptext
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] Selecting a page as a figure from a pdf

2003-12-15 Thread Nigel King
All,
I am aware of \filterpages but I would like to be able to insert part of a
single page from a multi page pdf and I have not been able to find anything
on the list of manuals. (\clip does not seem to work with \filterpages).
Does anybody have any ideas?

TIA
-- 
Nigel

___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] letter style

2003-11-11 Thread Janko Hauser
Hello, my name is Janko Hauser, I'm a new context user, after many
years of LaTeX :-)

I want to use context for two different projects.

1. Produce styled PDF documents from a web-content-managment-system.
This will be web-page based but also complete sets of pages to
generate longer documents. One conceptual idea is to have something
like a clip-board of visited pages, which can be printed as one
document. 

Ok, this Zope-based site will be an effort going into the next year. I
mention it only for background for the coming questions in the next
months.

2. I want to generate my invoice and business-letters with context. I
searched the mailinglist but the only note I got was a reference to
the last MAPS which should contain an article about this. Ah and
Hans has mentioned that there is something in the making :-) 
Is there already something to look at? Does someone know a direct link
to the mentioned MAPS-article?

Thanks in advance, I'm really looking forward to using context.

__Janko
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] Re: Figure reuse

2003-10-24 Thread Patrick Gundlach
Hi, 

 I believe that pdfs can make multiple use of pictures (and other objects). 

right.

 I have a fairly large picture which I want to include a number of
 times, once as the full picture and several other times
 concentrating on a portion of it. Are there any commands for
 cropping other than going through metapost?

Yes. Try this example. You can see from the resulting pdf file that
the cow.pdf gets included only once.


\useexternalfigure[cow]
\starttext
\setupclipping[nx=3,ny=3]
% 1/3 of a sliced cow
\hbox{%
\clip [x=1,y=2]{\externalfigure[cow]}
\clip [x=2,y=2]{\externalfigure[cow]}
\clip [x=3,y=2]{\externalfigure[cow]}
}

\blank[4*big]
% its in the details:
\scale[sx=2,sy=2]{\clip [x=2,y=2]{\externalfigure[cow]}}
\stoptext


Patrick
-- 
You are your own rainbow!
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] Re: [NTG-context]metapost prblem

2003-09-23 Thread Emil Hedevang Lohse
Severin Obertuefer [EMAIL PROTECTED] writes:

 thanks for your answer

 it works, but only with a normal circle.
 if the circle is xyscaled the same thing seems to bee much more
 complicate...
 here is the mp-code once again:

 beginfig(2);
 path c;
 pair A, B;
 c := fullcircle scaled 2 cm xyscaled(1.3,.8);
 A := (origin--(3cm,2cm)) intersectionpoint subpath (0,2) of c;
 B := (origin--(-5cm,1cm)) intersectionpoint subpath (2,4) of c;
 draw c;
 draw origin--B;
 draw origin--A;
 endfig;

 how can i clip the part of the path c between A and B in this case??

Isn't it easier to use arctime and the specify A and B as lengths
instead of points? For example:

  A := 1cm;
  B := 1cm;
  draw subpath (arctime A of c, arctime (arclength c) - B of c) of c;

The code is not tested.

Regards,

-- 
Emil Hedevang Lohse http://home.imf.au.dk/emil/ 

Alle spørgsmål er lige dumme. 
Og spørgsmålet Kan ænder flyve? er ikke dumt.

___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] Re: [NTG-context]metapost prblem

2003-09-22 Thread Severin Obertuefer
thanks for your answer

it works, but only with a normal circle.
if the circle is xyscaled the same thing seems to bee much more
complicate...
here is the mp-code once again:

beginfig(2);
path c;
pair A, B;
c := fullcircle scaled 2 cm xyscaled(1.3,.8);
A := (origin--(3cm,2cm)) intersectionpoint subpath (0,2) of c;
B := (origin--(-5cm,1cm)) intersectionpoint subpath (2,4) of c;
draw c;
draw origin--B;
draw origin--A;
endfig;

how can i clip the part of the path c between A and B in this case??

thanks for help

severin
 On Sun, 21 Sep 2003 21:24:04 +0200 (MEST)
 Severin Obertuefer [EMAIL PROTECTED] wrote:
 
  how can I cut the the part of the path c between A and B, so that the
 result
  is like a cheese :)
 
 path cheese ;
 cheese := c rotated angle B ;
 cheese := cheese cutafter (origin--A) ;
 
 
 Jens
 ___
 ntg-context mailing list
 [EMAIL PROTECTED]
 http://www.ntg.nl/mailman/listinfo/ntg-context
 

-- 
+++ GMX - die erste Adresse für Mail, Message, More! +++

Getestet von Stiftung Warentest: GMX FreeMail (GUT), GMX ProMail (GUT)
(Heft 9/03 - 23 e-mail-Tarife: 6 gut, 12 befriedigend, 5 ausreichend)

Jetzt selbst kostenlos testen: http://www.gmx.net

___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Re: [NTG-context]metapost prblem

2003-09-22 Thread Jens-Uwe Morawski
On Mon, 22 Sep 2003 13:37:47 +0200 (MEST)
Severin Obertuefer [EMAIL PROTECTED] wrote:


 it works, but only with a normal circle.
 if the circle is xyscaled the same thing seems to bee much more
 complicate...

additionally, a more general solution:

%%%
\setupoutput[pdftex]
\setupcolors[state=start]

\startMPinclusions
vardef cutbetween (expr p,a,b)=
  if (xpart (p intersectiontimes a))
 (xpart (p intersectiontimes b)):
((p cutbefore b) cutafter a)
  else:
(p cutbefore b)--(p cutafter a)
  fi
enddef;
\stopMPinclusions

\starttext
\startMPpage
save c, A, B ; path c, A, B;

A := (origin--(3cm,2cm)) ;
B := (origin--(-5cm,1cm)) ;

draw B ; 
draw A ; 
c := fullcircle scaled 2cm xyscaled(1.3,.8) ;
clip currentpicture to c ;


draw c withpen pencircle scaled 1.4pt withcolor .7white ;
drawarrow cutbetween(c,B,A) withcolor .7green ;
drawarrow cutbetween(c,A,B) withcolor green ;

c := reverse c xyscaled (0.3,0.9) ;
draw c withpen pencircle scaled 1.4pt withcolor .7white ;
drawarrow cutbetween(c,B,A) withcolor .7red ;
drawarrow cutbetween(c,A,B) withcolor red ;

\stopMPpage
\stoptext
%%%

Jens
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


<    1   2   3