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
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 -----------------------------------------------------------------
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 -----------------------------------------------------------------
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 -----------------------------------------------------------------
participants (3)
-
dalyoung
-
Hans Hagen
-
Jeong Dalyoung