ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* clipping in metafun has weird side effects
@ 2014-10-30 19:56 Tobias Columbus
  2014-10-31  8:58 ` Tobias Columbus
  0 siblings, 1 reply; 9+ messages in thread
From: Tobias Columbus @ 2014-10-30 19:56 UTC (permalink / raw)
  To: ntg-context

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

Dear all,

I stumbled upon some very weird behaviour of clipping in metafun/context. When I
add some clipped pictures to currentpicture and draw something dashed, some
subsequent lines will also be drawn dashed.

This behaviour only shows up with context but not with mptopdf or mpost. I
attached a minimal example and the corresponding output of context and mptopdf.

I tried context versions 2014.05.21 22:04 and 2014.10.29 17:47, but the result
is the same in both.

Tobias




-- 

[-- Attachment #2: mwe.mp --]
[-- Type: text/plain, Size: 929 bytes --]


vardef mycircle =
  save c ; picture c ; c := nullpicture ;
  addto c contour fullcircle scaled 2mm ;
  c
enddef ;

def a expr p =
  path _p_ ; _p_ := p ;
  a_impl
enddef ;

def a_impl text t =
  begingroup
    save c ; picture c ; c := mycircle ;
    clip c to bbox c scaled 0.5 ;
    addto currentpicture also c t ;
    addto currentpicture doublepath _p_ t ;
  endgroup
enddef ;

def b expr p =
  path _p_ ; _p_ := p ;
  b_impl
enddef ;

def b_impl text t =
  begingroup
    save c; picture c ; c := mycircle ;
    addto currentpicture also c t ;
    addto currentpicture doublepath _p_ t ;
  endgroup
enddef ;
beginfig(1)

  a (0,0) -- (1cm,0) dashed evenly ;
  currentpicture := currentpicture shifted (2cm,0) ;
  a (0,0) -- (1cm,0) ;

  currentpicture := currentpicture shifted (-2cm, 0.5cm );

  b (0,0) -- (1cm,0) dashed evenly ;
  currentpicture := currentpicture shifted (2cm,0) ;
  b (0,0) -- (1cm,0) ;

endfig ;
end

[-- Attachment #3: mwe-context.pdf --]
[-- Type: application/pdf, Size: 3773 bytes --]

[-- Attachment #4: mwe-mptopdf.pdf --]
[-- Type: application/pdf, Size: 1843 bytes --]

[-- Attachment #5: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: clipping in metafun has weird side effects
  2014-10-30 19:56 clipping in metafun has weird side effects Tobias Columbus
@ 2014-10-31  8:58 ` Tobias Columbus
  2014-10-31  9:05   ` Hans Hagen
  0 siblings, 1 reply; 9+ messages in thread
From: Tobias Columbus @ 2014-10-31  8:58 UTC (permalink / raw)
  To: ntg-context

Hi again,

I tried my example from yesterday in context with metapost format, but
the output still differs from what mptopdf produces.

While doing that, I noticed that the mpost format is currently not usable out of
the box: 

\startMPcode{metapost}
  draw (0,0) -- (1cm,0) ;
\stopMPcode

produces the error message

>> mfun_first_run
>> true
! Equation cannot be performed (numeric=boolean).

and the same for 'mfun_trial_run'. Simply adding 

boolean mfun_trial_run, mfun_first_run ;

to texmf/metapost/base/mpost.mp resolved the issue for me. However, that may
introduce other complications that I have no idea of.

Tobias



On Thu, Oct 30, 2014 at 08:56:34PM +0100, Tobias Columbus wrote:
> Dear all,
> 
> I stumbled upon some very weird behaviour of clipping in metafun/context. When I
> add some clipped pictures to currentpicture and draw something dashed, some
> subsequent lines will also be drawn dashed.
> 
> This behaviour only shows up with context but not with mptopdf or mpost. I
> attached a minimal example and the corresponding output of context and mptopdf.
> 
> I tried context versions 2014.05.21 22:04 and 2014.10.29 17:47, but the result
> is the same in both.
> 
> Tobias
> 
> 
> 
> 
> -- 

> 
> vardef mycircle =
>   save c ; picture c ; c := nullpicture ;
>   addto c contour fullcircle scaled 2mm ;
>   c
> enddef ;
> 
> def a expr p =
>   path _p_ ; _p_ := p ;
>   a_impl
> enddef ;
> 
> def a_impl text t =
>   begingroup
>     save c ; picture c ; c := mycircle ;
>     clip c to bbox c scaled 0.5 ;
>     addto currentpicture also c t ;
>     addto currentpicture doublepath _p_ t ;
>   endgroup
> enddef ;
> 
> def b expr p =
>   path _p_ ; _p_ := p ;
>   b_impl
> enddef ;
> 
> def b_impl text t =
>   begingroup
>     save c; picture c ; c := mycircle ;
>     addto currentpicture also c t ;
>     addto currentpicture doublepath _p_ t ;
>   endgroup
> enddef ;
> beginfig(1)
> 
>   a (0,0) -- (1cm,0) dashed evenly ;
>   currentpicture := currentpicture shifted (2cm,0) ;
>   a (0,0) -- (1cm,0) ;
> 
>   currentpicture := currentpicture shifted (-2cm, 0.5cm );
> 
>   b (0,0) -- (1cm,0) dashed evenly ;
>   currentpicture := currentpicture shifted (2cm,0) ;
>   b (0,0) -- (1cm,0) ;
> 
> endfig ;
> end




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

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: clipping in metafun has weird side effects
  2014-10-31  8:58 ` Tobias Columbus
@ 2014-10-31  9:05   ` Hans Hagen
  2014-10-31  9:15     ` Tobias Columbus
  0 siblings, 1 reply; 9+ messages in thread
From: Hans Hagen @ 2014-10-31  9:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 10/31/2014 9:58 AM, Tobias Columbus wrote:
> Hi again,
>
> I tried my example from yesterday in context with metapost format, but
> the output still differs from what mptopdf produces.
>
> While doing that, I noticed that the mpost format is currently not usable out of
> the box:
>
> \startMPcode{metapost}
>    draw (0,0) -- (1cm,0) ;
> \stopMPcode
>
> produces the error message
>

\startMPcode
   draw (0,0) -- (1cm,0) ;
\stopMPcode

why the {metapost}

>>> mfun_first_run
>>> true
> ! Equation cannot be performed (numeric=boolean).
>
> and the same for 'mfun_trial_run'. Simply adding
>
> boolean mfun_trial_run, mfun_first_run ;
>
> to texmf/metapost/base/mpost.mp resolved the issue for me. However, that may
> introduce other complications that I have no idea of.
>
> Tobias
>
>
>
> On Thu, Oct 30, 2014 at 08:56:34PM +0100, Tobias Columbus wrote:
>> Dear all,
>>
>> I stumbled upon some very weird behaviour of clipping in metafun/context. When I
>> add some clipped pictures to currentpicture and draw something dashed, some
>> subsequent lines will also be drawn dashed.
>>
>> This behaviour only shows up with context but not with mptopdf or mpost. I
>> attached a minimal example and the corresponding output of context and mptopdf.
>>
>> I tried context versions 2014.05.21 22:04 and 2014.10.29 17:47, but the result
>> is the same in both.
>>
>> Tobias
>>
>>
>>
>>
>> --
>
>>
>> vardef mycircle =
>>    save c ; picture c ; c := nullpicture ;
>>    addto c contour fullcircle scaled 2mm ;
>>    c
>> enddef ;
>>
>> def a expr p =
>>    path _p_ ; _p_ := p ;
>>    a_impl
>> enddef ;
>>
>> def a_impl text t =
>>    begingroup
>>      save c ; picture c ; c := mycircle ;
>>      clip c to bbox c scaled 0.5 ;
>>      addto currentpicture also c t ;
>>      addto currentpicture doublepath _p_ t ;
>>    endgroup
>> enddef ;
>>
>> def b expr p =
>>    path _p_ ; _p_ := p ;
>>    b_impl
>> enddef ;
>>
>> def b_impl text t =
>>    begingroup
>>      save c; picture c ; c := mycircle ;
>>      addto currentpicture also c t ;
>>      addto currentpicture doublepath _p_ t ;
>>    endgroup
>> enddef ;
>> beginfig(1)
>>
>>    a (0,0) -- (1cm,0) dashed evenly ;
>>    currentpicture := currentpicture shifted (2cm,0) ;
>>    a (0,0) -- (1cm,0) ;
>>
>>    currentpicture := currentpicture shifted (-2cm, 0.5cm );
>>
>>    b (0,0) -- (1cm,0) dashed evenly ;
>>    currentpicture := currentpicture shifted (2cm,0) ;
>>    b (0,0) -- (1cm,0) ;
>>
>> endfig ;
>> end
>
>
>
>


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: clipping in metafun has weird side effects
  2014-10-31  9:05   ` Hans Hagen
@ 2014-10-31  9:15     ` Tobias Columbus
  2014-10-31 11:10       ` Hans Hagen
  2014-10-31 11:22       ` Hans Hagen
  0 siblings, 2 replies; 9+ messages in thread
From: Tobias Columbus @ 2014-10-31  9:15 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Fri, Oct 31, 2014 at 10:05:35AM +0100, Hans Hagen wrote:
> On 10/31/2014 9:58 AM, Tobias Columbus wrote:
> >Hi again,
> >
> >I tried my example from yesterday in context with metapost format, but
> >the output still differs from what mptopdf produces.
> >
> >While doing that, I noticed that the mpost format is currently not usable out of
> >the box:
> >
> >\startMPcode{metapost}
> >   draw (0,0) -- (1cm,0) ;
> >\stopMPcode
> >
> >produces the error message
> >
> 
> \startMPcode
>   draw (0,0) -- (1cm,0) ;
> \stopMPcode
> 
> why the {metapost}

I wanted to know if the impact of clipping is caused by the metafun format.
According to the wiki page
http://wiki.contextgarden.net/Command/defineMPinstance the instances "metapost"
and "metafun" are predefined and can be used by

\startMPcode{instance}
  ...
\stopMPcode

where metafun is the default instance, i.e. used when there is no instance
given.

> 
> >>>mfun_first_run
> >>>true
> >! Equation cannot be performed (numeric=boolean).
> >
> >and the same for 'mfun_trial_run'. Simply adding
> >
> >boolean mfun_trial_run, mfun_first_run ;
> >
> >to texmf/metapost/base/mpost.mp resolved the issue for me. However, that may
> >introduce other complications that I have no idea of.
> >
> >Tobias
> >
> >
> >
> >On Thu, Oct 30, 2014 at 08:56:34PM +0100, Tobias Columbus wrote:
> >>Dear all,
> >>
> >>I stumbled upon some very weird behaviour of clipping in metafun/context. When I
> >>add some clipped pictures to currentpicture and draw something dashed, some
> >>subsequent lines will also be drawn dashed.
> >>
> >>This behaviour only shows up with context but not with mptopdf or mpost. I
> >>attached a minimal example and the corresponding output of context and mptopdf.
> >>
> >>I tried context versions 2014.05.21 22:04 and 2014.10.29 17:47, but the result
> >>is the same in both.
> >>
> >>Tobias
> >>
> >>
> >>
> >>
> >>--
> >
> >>
> >>vardef mycircle =
> >>   save c ; picture c ; c := nullpicture ;
> >>   addto c contour fullcircle scaled 2mm ;
> >>   c
> >>enddef ;
> >>
> >>def a expr p =
> >>   path _p_ ; _p_ := p ;
> >>   a_impl
> >>enddef ;
> >>
> >>def a_impl text t =
> >>   begingroup
> >>     save c ; picture c ; c := mycircle ;
> >>     clip c to bbox c scaled 0.5 ;
> >>     addto currentpicture also c t ;
> >>     addto currentpicture doublepath _p_ t ;
> >>   endgroup
> >>enddef ;
> >>
> >>def b expr p =
> >>   path _p_ ; _p_ := p ;
> >>   b_impl
> >>enddef ;
> >>
> >>def b_impl text t =
> >>   begingroup
> >>     save c; picture c ; c := mycircle ;
> >>     addto currentpicture also c t ;
> >>     addto currentpicture doublepath _p_ t ;
> >>   endgroup
> >>enddef ;
> >>beginfig(1)
> >>
> >>   a (0,0) -- (1cm,0) dashed evenly ;
> >>   currentpicture := currentpicture shifted (2cm,0) ;
> >>   a (0,0) -- (1cm,0) ;
> >>
> >>   currentpicture := currentpicture shifted (-2cm, 0.5cm );
> >>
> >>   b (0,0) -- (1cm,0) dashed evenly ;
> >>   currentpicture := currentpicture shifted (2cm,0) ;
> >>   b (0,0) -- (1cm,0) ;
> >>
> >>endfig ;
> >>end
> >
> >
> >
> >
> 
> 
> -- 
> 
> -----------------------------------------------------------------
>                                           Hans Hagen | PRAGMA ADE
>               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
>                                              | www.pragma-pod.nl
> -----------------------------------------------------------------
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

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

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: clipping in metafun has weird side effects
  2014-10-31  9:15     ` Tobias Columbus
@ 2014-10-31 11:10       ` Hans Hagen
  2014-10-31 11:22       ` Hans Hagen
  1 sibling, 0 replies; 9+ messages in thread
From: Hans Hagen @ 2014-10-31 11:10 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 10/31/2014 10:15 AM, Tobias Columbus wrote:
> On Fri, Oct 31, 2014 at 10:05:35AM +0100, Hans Hagen wrote:
>> On 10/31/2014 9:58 AM, Tobias Columbus wrote:
>>> Hi again,
>>>
>>> I tried my example from yesterday in context with metapost format, but
>>> the output still differs from what mptopdf produces.
>>>
>>> While doing that, I noticed that the mpost format is currently not usable out of
>>> the box:
>>>
>>> \startMPcode{metapost}
>>>    draw (0,0) -- (1cm,0) ;
>>> \stopMPcode
>>>
>>> produces the error message
>>>
>>
>> \startMPcode
>>    draw (0,0) -- (1cm,0) ;
>> \stopMPcode
>>
>> why the {metapost}
>
> I wanted to know if the impact of clipping is caused by the metafun format.
> According to the wiki page
> http://wiki.contextgarden.net/Command/defineMPinstance the instances "metapost"
> and "metafun" are predefined and can be used by
>
> \startMPcode{instance}
>    ...
> \stopMPcode
>
> where metafun is the default instance, i.e. used when there is no instance
> given.

i fixed the metapost run and also added basic text support in it (next 
beta)


>>
>>>>> mfun_first_run
>>>>> true
>>> ! Equation cannot be performed (numeric=boolean).
>>>
>>> and the same for 'mfun_trial_run'. Simply adding
>>>
>>> boolean mfun_trial_run, mfun_first_run ;
>>>
>>> to texmf/metapost/base/mpost.mp resolved the issue for me. However, that may
>>> introduce other complications that I have no idea of.
>>>
>>> Tobias
>>>
>>>
>>>
>>> On Thu, Oct 30, 2014 at 08:56:34PM +0100, Tobias Columbus wrote:
>>>> Dear all,
>>>>
>>>> I stumbled upon some very weird behaviour of clipping in metafun/context. When I
>>>> add some clipped pictures to currentpicture and draw something dashed, some
>>>> subsequent lines will also be drawn dashed.
>>>>
>>>> This behaviour only shows up with context but not with mptopdf or mpost. I
>>>> attached a minimal example and the corresponding output of context and mptopdf.
>>>>
>>>> I tried context versions 2014.05.21 22:04 and 2014.10.29 17:47, but the result
>>>> is the same in both.
>>>>
>>>> Tobias
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>
>>>>
>>>> vardef mycircle =
>>>>    save c ; picture c ; c := nullpicture ;
>>>>    addto c contour fullcircle scaled 2mm ;
>>>>    c
>>>> enddef ;
>>>>
>>>> def a expr p =
>>>>    path _p_ ; _p_ := p ;
>>>>    a_impl
>>>> enddef ;
>>>>
>>>> def a_impl text t =
>>>>    begingroup
>>>>      save c ; picture c ; c := mycircle ;
>>>>      clip c to bbox c scaled 0.5 ;
>>>>      addto currentpicture also c t ;
>>>>      addto currentpicture doublepath _p_ t ;
>>>>    endgroup
>>>> enddef ;
>>>>
>>>> def b expr p =
>>>>    path _p_ ; _p_ := p ;
>>>>    b_impl
>>>> enddef ;
>>>>
>>>> def b_impl text t =
>>>>    begingroup
>>>>      save c; picture c ; c := mycircle ;
>>>>      addto currentpicture also c t ;
>>>>      addto currentpicture doublepath _p_ t ;
>>>>    endgroup
>>>> enddef ;
>>>> beginfig(1)
>>>>
>>>>    a (0,0) -- (1cm,0) dashed evenly ;
>>>>    currentpicture := currentpicture shifted (2cm,0) ;
>>>>    a (0,0) -- (1cm,0) ;
>>>>
>>>>    currentpicture := currentpicture shifted (-2cm, 0.5cm );
>>>>
>>>>    b (0,0) -- (1cm,0) dashed evenly ;
>>>>    currentpicture := currentpicture shifted (2cm,0) ;
>>>>    b (0,0) -- (1cm,0) ;
>>>>
>>>> endfig ;
>>>> end
>>>
>>>
>>>
>>>
>>
>>
>> --
>>
>> -----------------------------------------------------------------
>>                                            Hans Hagen | PRAGMA ADE
>>                Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>>      tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
>>                                               | www.pragma-pod.nl
>> -----------------------------------------------------------------
>> ___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to the Wiki!
>>
>> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
>> archive  : http://foundry.supelec.fr/projects/contextrev/
>> wiki     : http://contextgarden.net
>> ___________________________________________________________________________________
>


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: clipping in metafun has weird side effects
  2014-10-31  9:15     ` Tobias Columbus
  2014-10-31 11:10       ` Hans Hagen
@ 2014-10-31 11:22       ` Hans Hagen
  2014-10-31 12:33         ` Tobias Columbus
  1 sibling, 1 reply; 9+ messages in thread
From: Hans Hagen @ 2014-10-31 11:22 UTC (permalink / raw)
  To: ntg-context

On 10/31/2014 10:15 AM, Tobias Columbus wrote:

>>>> def a_impl text t =
>>>>    begingroup
>>>>      save c ; picture c ; c := mycircle ;
>>>>      clip c to bbox c scaled 0.5 ;

try this to see what happens:

% clip c to bbox c scaled 0.5 ;
draw bbox c scaled 0.5 ;

and then this to solve it:

clip c to bbox (c scaled 0.5) ;

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: clipping in metafun has weird side effects
  2014-10-31 11:22       ` Hans Hagen
@ 2014-10-31 12:33         ` Tobias Columbus
  2014-11-02 10:29           ` Hans Hagen
  0 siblings, 1 reply; 9+ messages in thread
From: Tobias Columbus @ 2014-10-31 12:33 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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

On Fri, Oct 31, 2014 at 12:22:37PM +0100, Hans Hagen wrote:
> On 10/31/2014 10:15 AM, Tobias Columbus wrote:
> 
> >>>>def a_impl text t =
> >>>>   begingroup
> >>>>     save c ; picture c ; c := mycircle ;
> >>>>     clip c to bbox c scaled 0.5 ;
> 
> try this to see what happens:
> 
> % clip c to bbox c scaled 0.5 ;
> draw bbox c scaled 0.5 ;
> 
> and then this to solve it:
> 
> clip c to bbox (c scaled 0.5) ;

I tried your suggestions and attached both the example and output. Drawing and
clipping solves the problem indeed. But using only the modified clip either does
not solve the problem, or I am just too stupid to implement your solution.

Note also that in the modified example the context output coincides with the
mptopdf output if one draws the label before calling "test" the second time. (I
marked the position in the metapost file.)

Sorry for probably getting on your nerves ... 

> 
> -----------------------------------------------------------------
>                                           Hans Hagen | PRAGMA ADE
>               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
>                                              | www.pragma-pod.nl
> -----------------------------------------------------------------
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

-- 

[-- Attachment #2: mwe-context.pdf --]
[-- Type: application/pdf, Size: 7234 bytes --]

[-- Attachment #3: mwe-mptopdf.pdf --]
[-- Type: application/pdf, Size: 26530 bytes --]

[-- Attachment #4: mwe.mp --]
[-- Type: text/plain, Size: 1271 bytes --]


vardef mycircle =
  save c ; picture c ; c := nullpicture ;
  addto c contour fullcircle scaled 2mm ;
  c
enddef ;

def test (expr m) expr p =
  path _p_ ; _p_ := p ;
  scantokens m
enddef ;

def only_clip text t =
  begingroup
    save c ; picture c ; c := mycircle ;
    clip c to bbox (c scaled 0.5) ;
    addto currentpicture also c t ;
    addto currentpicture doublepath _p_ t ;
  endgroup
enddef ;


def no_clip text t =
  begingroup
    save c; picture c ; c := mycircle ;
    addto currentpicture also c t ;
    addto currentpicture doublepath _p_ t ;
  endgroup
enddef ;


def draw_clip text t =
  begingroup
    save c ; picture c ; c := mycircle ;
    draw bbox (c scaled 0.5) ;
    clip c to bbox (c scaled 0.5) ;
    addto currentpicture also c t ;
    addto currentpicture doublepath _p_ t ;
  endgroup
enddef ;

beginfig(1)
  
  for macro = "only_clip", "no_clip", "draw_clip":
    test( macro ) (0,0) -- (1cm,0) dashed evenly ;
    % NOTE:
    % Drawing the label here makes the weird second dashed line go away.
    % label.rt(macro, (-5cm,0) );
    currentpicture := currentpicture shifted (-2cm,0) ;
    test( macro ) (0,0) -- (1cm,0) ;
    label.rt(macro, (-5cm,0) );
    currentpicture := currentpicture shifted(2cm,0.5cm );
  endfor

endfig ;
end

[-- Attachment #5: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: clipping in metafun has weird side effects
  2014-10-31 12:33         ` Tobias Columbus
@ 2014-11-02 10:29           ` Hans Hagen
  2014-11-02 12:09             ` Tobias Columbus
  0 siblings, 1 reply; 9+ messages in thread
From: Hans Hagen @ 2014-11-02 10:29 UTC (permalink / raw)
  To: ntg-context

On 10/31/2014 1:33 PM, Tobias Columbus wrote:
> On Fri, Oct 31, 2014 at 12:22:37PM +0100, Hans Hagen wrote:
>> On 10/31/2014 10:15 AM, Tobias Columbus wrote:
>>
>>>>>> def a_impl text t =
>>>>>>    begingroup
>>>>>>      save c ; picture c ; c := mycircle ;
>>>>>>      clip c to bbox c scaled 0.5 ;
>>
>> try this to see what happens:
>>
>> % clip c to bbox c scaled 0.5 ;
>> draw bbox c scaled 0.5 ;
>>
>> and then this to solve it:
>>
>> clip c to bbox (c scaled 0.5) ;
>
> I tried your suggestions and attached both the example and output. Drawing and
> clipping solves the problem indeed. But using only the modified clip either does
> not solve the problem, or I am just too stupid to implement your solution.
>
> Note also that in the modified example the context output coincides with the
> mptopdf output if one draws the label before calling "test" the second time. (I
> marked the position in the metapost file.)
>
> Sorry for probably getting on your nerves ...

hopefully ok in next beta

Hans



-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: clipping in metafun has weird side effects
  2014-11-02 10:29           ` Hans Hagen
@ 2014-11-02 12:09             ` Tobias Columbus
  0 siblings, 0 replies; 9+ messages in thread
From: Tobias Columbus @ 2014-11-02 12:09 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Sun, Nov 02, 2014 at 11:29:24AM +0100, Hans Hagen wrote:
> On 10/31/2014 1:33 PM, Tobias Columbus wrote:
> >On Fri, Oct 31, 2014 at 12:22:37PM +0100, Hans Hagen wrote:
> >>On 10/31/2014 10:15 AM, Tobias Columbus wrote:
> >>
> >>>>>>def a_impl text t =
> >>>>>>   begingroup
> >>>>>>     save c ; picture c ; c := mycircle ;
> >>>>>>     clip c to bbox c scaled 0.5 ;
> >>
> >>try this to see what happens:
> >>
> >>% clip c to bbox c scaled 0.5 ;
> >>draw bbox c scaled 0.5 ;
> >>
> >>and then this to solve it:
> >>
> >>clip c to bbox (c scaled 0.5) ;
> >
> >I tried your suggestions and attached both the example and output. Drawing and
> >clipping solves the problem indeed. But using only the modified clip either does
> >not solve the problem, or I am just too stupid to implement your solution.
> >
> >Note also that in the modified example the context output coincides with the
> >mptopdf output if one draws the label before calling "test" the second time. (I
> >marked the position in the metapost file.)
> >
> >Sorry for probably getting on your nerves ...
> 
> hopefully ok in next beta
> 
> Hans

Seems to be fixed in 2014.11.02 12:23.

Thank you very much!
Tobias

> 
> 
> 
> -----------------------------------------------------------------
>                                           Hans Hagen | PRAGMA ADE
>               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
>                                              | www.pragma-pod.nl
> -----------------------------------------------------------------
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

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

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2014-11-02 12:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-30 19:56 clipping in metafun has weird side effects Tobias Columbus
2014-10-31  8:58 ` Tobias Columbus
2014-10-31  9:05   ` Hans Hagen
2014-10-31  9:15     ` Tobias Columbus
2014-10-31 11:10       ` Hans Hagen
2014-10-31 11:22       ` Hans Hagen
2014-10-31 12:33         ` Tobias Columbus
2014-11-02 10:29           ` Hans Hagen
2014-11-02 12:09             ` Tobias Columbus

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).