ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Re: Metafun  shifting pictures - again
       [not found] <mailman.1686.1308769368.4231.ntg-context@ntg.nl>
@ 2011-06-23  4:32 ` Jeong Dalyoung
  2011-06-23  7:41   ` Hans Hagen
  0 siblings, 1 reply; 4+ messages in thread
From: Jeong Dalyoung @ 2011-06-23  4:32 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 1114 bytes --]

Hi all,

I got the reason why the pictures locate in different position.
"rotation" causes the problem.

I defined domino as follows.
It is not the exact code but just show the form of the codes.

...
def domino (a, b, c, d  )
	save pic;
	picture pic;
	draw something 1;
	draw something 2;
	pic := currentpicture;
	draw pic rotated 90 shifted ( c, d );
enddef;

and call it using

\startbuffer[domino3]
	domino (1, 2, 3, 4);
	domino (2, 1, 1, 2);
	domino (3, 3, 2, 3);
\stopbuffer

and \processMPbuffer[].

it draw the first domino at the right place, but it is rotated when the second domino is drawn. Hence, it actually rotated 180 degree. Also two dominos rotated again when the third domino is drawn. 
Previous drawings are rotated again again when the function domino called.

How to avoid this problem? How to draw one figure and move to wanted position and draw another figure and move to another location without changing the previous figure?

If you want to see the whole codes, please see the attachment in the previous mail in ntg-context Digest, Vol 84, Issue 94.

Thank you.

Best regards,

Dalyoung


[-- Attachment #1.2: Type: text/html, Size: 2433 bytes --]

[-- Attachment #2: 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] 4+ messages in thread

* Re: Metafun  shifting pictures - again
  2011-06-23  4:32 ` Metafun shifting pictures - again Jeong Dalyoung
@ 2011-06-23  7:41   ` Hans Hagen
  2011-06-24  6:32     ` dalyoung
  0 siblings, 1 reply; 4+ messages in thread
From: Hans Hagen @ 2011-06-23  7:41 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Jeong Dalyoung

On 23-6-2011 6:32, Jeong Dalyoung wrote:
> Hi all,
>
> I got the reason why the pictures locate in different position.
> "rotation" causes the problem.
>
> I defined domino as follows.
> It is not the exact code but just show the form of the codes.
>
> ....
> def domino (a, b, c, d  )
> 	save pic;
> 	picture pic;
> 	draw something 1;
> 	draw something 2;
> 	pic := currentpicture;
> 	draw pic rotated 90 shifted ( c, d );
> enddef;
>
> and call it using
>
> \startbuffer[domino3]
> 	domino (1, 2, 3, 4);
> 	domino (2, 1, 1, 2);
> 	domino (3, 3, 2, 3);
> \stopbuffer
>
> and \processMPbuffer[].
>
> it draw the first domino at the right place, but it is rotated when the second domino is drawn. Hence, it actually rotated 180 degree. Also two dominos rotated again when the third domino is drawn.
> Previous drawings are rotated again again when the function domino called.
>
> How to avoid this problem? How to draw one figure and move to wanted position and draw another figure and move to another location without changing the previous figure?
>
> If you want to see the whole codes, please see the attachment in the previous mail in ntg-context Digest, Vol 84, Issue 94.

set the boundingbox in each domino to the same size

-----------------------------------------------------------------
                                           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] 4+ messages in thread

* Re: Metafun  shifting pictures - again
  2011-06-23  7:41   ` Hans Hagen
@ 2011-06-24  6:32     ` dalyoung
  2011-06-24 11:55       ` Hans Hagen
  0 siblings, 1 reply; 4+ messages in thread
From: dalyoung @ 2011-06-24  6:32 UTC (permalink / raw)
  To: Hans Hagen; +Cc: mailing list for ConTeXt users

Dear Hans,


Thank you for the suggestion to use "setbounds".
And sorry to send you a untested sample file which is not working.

However, I couldn't succeed because of my lack of knowledge on "setbounds, boundingbox".

Instead, I try to use "addto" and get a wanted result.
There is a better way to do that, but it is not easy for me to find a better way right now.
Here is a tested sample code.

\startbuffer[dominos]
picture finalpicture;

def dominoV (expr m,n, i, j) =
numeric dx, dy, DieSize,corner_rad;
path p, DominoFace;
DieSize := 1cm;
corner_rad := 1/12;
DominoFace := (1,0)--(1,1)--(corner_rad, 1){left}..{down}(0,1-corner_rad)	..(0,corner_rad){down}..{right}(corner_rad,0)
..(2-corner_rad,0){right}..{up}(2,corner_rad)
..(2,1-corner_rad){up}..{left}(2-corner_rad,1)--(1,1);
currentpicture := nullpicture;
dx := 1.1*i*DieSize;
dy := 2.1*j*DieSize;
draw DominoFace scaled DieSize rotated 270;
%draw pips[m] scaled DieSize;% shifted (dx, dy);
%draw pips[n] scaled DieSize shifted (DieSize, 0) ;
addto finalpicture also currentpicture shifted (dx, dy);
currentpicture := nullpicture;
enddef;

finalpicture := nullpicture;
dominoV (6, 0, 0, 0);
dominoV (5, 1, 1, 0);
dominoV (4, 2, 2, 0);
dominoV (3, 3, 3, 0);
currentpicture := finalpicture;
\stopbuffer

\starttext
\processMPbuffer[dominos]
\stoptext

Thank you again.

Best regards,

Dalyoung

On 2011. 6. 23., at 오후 4:41, Hans Hagen wrote:

> On 23-6-2011 6:32, Jeong Dalyoung wrote:
>> Hi all,
>> 
>> I got the reason why the pictures locate in different position.
>> "rotation" causes the problem.
>> 
>> I defined domino as follows.
>> It is not the exact code but just show the form of the codes.
>> 
>> ....
>> def domino (a, b, c, d  )
>> 	save pic;
>> 	picture pic;
>> 	draw something 1;
>> 	draw something 2;
>> 	pic := currentpicture;
>> 	draw pic rotated 90 shifted ( c, d );
>> enddef;
>> 
>> and call it using
>> 
>> \startbuffer[domino3]
>> 	domino (1, 2, 3, 4);
>> 	domino (2, 1, 1, 2);
>> 	domino (3, 3, 2, 3);
>> \stopbuffer
>> 
>> and \processMPbuffer[].
>> 
>> it draw the first domino at the right place, but it is rotated when the second domino is drawn. Hence, it actually rotated 180 degree. Also two dominos rotated again when the third domino is drawn.
>> Previous drawings are rotated again again when the function domino called.
>> 
>> How to avoid this problem? How to draw one figure and move to wanted position and draw another figure and move to another location without changing the previous figure?
>> 
>> If you want to see the whole codes, please see the attachment in the previous mail in ntg-context Digest, Vol 84, Issue 94.
> 
> set the boundingbox in each domino to the same size
> 
> -----------------------------------------------------------------
>                                          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] 4+ messages in thread

* Re: Metafun  shifting pictures - again
  2011-06-24  6:32     ` dalyoung
@ 2011-06-24 11:55       ` Hans Hagen
  0 siblings, 0 replies; 4+ messages in thread
From: Hans Hagen @ 2011-06-24 11:55 UTC (permalink / raw)
  To: dalyoung; +Cc: mailing list for ConTeXt users

On 24-6-2011 8:32, dalyoung wrote:
> Dear Hans,
>
>
> Thank you for the suggestion to use "setbounds".
> And sorry to send you a untested sample file which is not working.
>
> However, I couldn't succeed because of my lack of knowledge on "setbounds, boundingbox".
>
> Instead, I try to use "addto" and get a wanted result.
> There is a better way to do that, but it is not easy for me to find a better way right now.

\startbuffer[dominos]
vardef dominoV (expr m) =
     numeric corner_rad ;
     path DominoFace ;
     corner_rad := 1/12 ;
     DominoFace :=
             (1,0)
         --  (1,1)
         --  (corner_rad,1)  {left}  .. {down} (0,1-corner_rad)
         ... (0,corner_rad)  {down}  .. {right}(corner_rad,0)
         ... (2-corner_rad,0){right} .. {up}   (2,corner_rad)
         ... (2,1-corner_rad){up}    .. {left} (2-corner_rad,1)
         --  (1,1) ;
     DominoFace rotated 270
enddef ;

def shiftX(expr d) =
     currentpicture := currentpicture shifted (-xpart urcorner 
currentpicture - d, 0) ;
enddef ;

numeric d ; d := 1cm ;

draw dominoV(6) scaled d ; shiftX(d/10) ;
draw dominoV(5) scaled d ; shiftX(d/10) ;
draw dominoV(4) scaled d ; shiftX(d/10) ;
draw dominoV(3) scaled d ;
\stopbuffer

\starttext

     \processMPbuffer[dominos]

\stoptext


-----------------------------------------------------------------
                                           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] 4+ messages in thread

end of thread, other threads:[~2011-06-24 11:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.1686.1308769368.4231.ntg-context@ntg.nl>
2011-06-23  4:32 ` Metafun shifting pictures - again Jeong Dalyoung
2011-06-23  7:41   ` Hans Hagen
2011-06-24  6:32     ` dalyoung
2011-06-24 11:55       ` 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).