ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Bug in latest beta, shifted metapost (possibly with drawarrow)
@ 2016-11-03 16:09 Mikael P. Sundqvist
  2016-11-04 10:00 ` Hans Hagen
  0 siblings, 1 reply; 2+ messages in thread
From: Mikael P. Sundqvist @ 2016-11-03 16:09 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 1010 bytes --]

Dear list,

the example below has shifted axes. I updated to the latest standalone
earlier today. The problem was not present some weeks ago.

In particular look at the red line that should start from the origin...

\starttext
\startMPpage
ut:=1.0cm;
ux:=0.6cm;

vardef diffp(expr riktn) =
 ((-1,0)--(1,0)) rotatedaround (origin,angle(ut,riktn*ux))
enddef;

path taxel,xaxel;
taxel:=((-1.4,0)--(5.4,0));
xaxel:=((0,-1.4)--(0,4.6));
drawarrow taxel xyscaled(ut,ux);
drawarrow xaxel xyscaled(ut,ux);

label.bot("$t$", (point length(taxel) of taxel) xyscaled(ut,ux));
label.lft("$P$", (point length(xaxel) of xaxel) xyscaled(ut,ux));

draw image(
 vardef fun(expr t, x) = x*(3-x) enddef;
 for i=-1 step 0.5 until 5 :
  for j=-1 step 0.5 until 4 :
    ii:=i;
    jj:=j;
    draw diffp(fun(ii,jj)) scaled 2bp shifted (ii*ut,jj*ux);
  endfor;
 endfor;

draw function (2, "x", "3/(1+2*exp(-3*x))" ,-1, 5, 1/5) xyscaled (ut,ux);

draw (0,0)--(3,3) xyscaled(ut,ux) withcolor darkred;

);
\stopMPpage
\stoptext

/Mikael

[-- Attachment #2: ctx-listexample17.pdf --]
[-- Type: application/pdf, Size: 8453 bytes --]

[-- Attachment #3: Type: text/plain, Size: 492 bytes --]

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

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug in latest beta, shifted metapost (possibly with drawarrow)
  2016-11-03 16:09 Bug in latest beta, shifted metapost (possibly with drawarrow) Mikael P. Sundqvist
@ 2016-11-04 10:00 ` Hans Hagen
  0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen @ 2016-11-04 10:00 UTC (permalink / raw)
  To: ntg-context

On 11/3/2016 5:09 PM, Mikael P. Sundqvist wrote:
> Dear list,
>
> the example below has shifted axes. I updated to the latest standalone
> earlier today. The problem was not present some weeks ago.
>
> In particular look at the red line that should start from the origin...
>
> \starttext
> \startMPpage
> ut:=1.0cm;
> ux:=0.6cm;
>
> vardef diffp(expr riktn) =
>  ((-1,0)--(1,0)) rotatedaround (origin,angle(ut,riktn*ux))
> enddef;
>
> path taxel,xaxel;
> taxel:=((-1.4,0)--(5.4,0));
> xaxel:=((0,-1.4)--(0,4.6));
> drawarrow taxel xyscaled(ut,ux);
> drawarrow xaxel xyscaled(ut,ux);
>
> label.bot("$t$", (point length(taxel) of taxel) xyscaled(ut,ux));
> label.lft("$P$", (point length(xaxel) of xaxel) xyscaled(ut,ux));
>
> draw image(
>  vardef fun(expr t, x) = x*(3-x) enddef;
>  for i=-1 step 0.5 until 5 :
>   for j=-1 step 0.5 until 4 :
>     ii:=i;
>     jj:=j;
>     draw diffp(fun(ii,jj)) scaled 2bp shifted (ii*ut,jj*ux);
>   endfor;
>  endfor;
>
> draw function (2, "x", "3/(1+2*exp(-3*x))" ,-1, 5, 1/5) xyscaled (ut,ux);
>
> draw (0,0)--(3,3) xyscaled(ut,ux) withcolor darkred;
>
> );
> \stopMPpage
> \stoptext

I'll fix it. Alan: we really need this one then:

vardef image@#(text t) =
     save currentpicture ;
     picture currentpicture ;
     currentpicture := nullpicture ;
     t ;
     currentpicture
     if str @# <> "" :
         shifted (
               mfun_labxf@#               * lrcorner currentpicture
          +                 mfun_labyf@#  * ulcorner currentpicture
          + (1-mfun_labxf@#-mfun_labyf@#) * llcorner currentpicture
         )
     fi
enddef ;




-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-11-04 10:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-03 16:09 Bug in latest beta, shifted metapost (possibly with drawarrow) Mikael P. Sundqvist
2016-11-04 10:00 ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).