From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/69372 Path: news.gmane.org!not-for-mail From: dalyoung Newsgroups: gmane.comp.tex.context Subject: Metafun: shifting picture Date: Wed, 22 Jun 2011 19:40:59 +0900 Message-ID: <67AC56B4-6DC3-417A-A257-E107CFDAA34B@me.com> References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary_(ID_vXaLgGC69Pr4MrAWnpcPyA)" X-Trace: dough.gmane.org 1308739320 15534 80.91.229.12 (22 Jun 2011 10:42:00 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 22 Jun 2011 10:42:00 +0000 (UTC) To: ntg-context@ntg.nl Original-X-From: ntg-context-bounces@ntg.nl Wed Jun 22 12:41:54 2011 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QZKsb-0004Nd-V2 for gctc-ntg-context-518@m.gmane.org; Wed, 22 Jun 2011 12:41:54 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 0C7A4CADF3; Wed, 22 Jun 2011 12:41:53 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id dfjqu4hmsrPq; Wed, 22 Jun 2011 12:41:50 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 60130CADE5; Wed, 22 Jun 2011 12:41:50 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 780CBCADE5 for ; Wed, 22 Jun 2011 12:41:48 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id xgoyjc-Z0OKE for ; Wed, 22 Jun 2011 12:41:36 +0200 (CEST) Original-Received: from filter1-ams.mf.surf.net (filter1-ams.mf.surf.net [192.87.102.69]) by balder.ntg.nl (Postfix) with ESMTP id BA785CADA8 for ; Wed, 22 Jun 2011 12:41:36 +0200 (CEST) Original-Received: from asmtpout026.mac.com (asmtpout026.mac.com [17.148.16.101]) by filter1-ams.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p5MAfZkj013129 for ; Wed, 22 Jun 2011 12:41:35 +0200 Original-Received: from [211.212.222.116] (unknown [211.212.222.116]) by asmtp026.mac.com (Oracle Communications Messaging Exchange Server 7u4-20.01 64bit (built Nov 21 2010)) with ESMTPSA id <0LN600C3LTOCS420@asmtp026.mac.com> for ntg-context@ntg.nl; Wed, 22 Jun 2011 03:41:03 -0700 (PDT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.4.6813,1.0.148,0.0.0000 definitions=2011-06-22_05:2011-06-22, 2011-06-22, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 ipscore=0 suspectscore=1 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx engine=6.0.2-1012030000 definitions=main-1106220059 In-reply-to: X-Mailer: Apple Mail (2.1084) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=17.148.16.101; country=US; region=CA; city=Cupertino; postalcode=95014; latitude=37.3042; longitude=-122.0946; metrocode=807; areacode=408; http://maps.google.com/maps?q=37.3042,-122.0946&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 06EWWFzFs - 13c930f0d23e - 20110622 X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.69 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:69372 Archived-At: --Boundary_(ID_vXaLgGC69Pr4MrAWnpcPyA) Content-type: text/plain; CHARSET=US-ASCII Content-transfer-encoding: 7BIT Hi, I am trying to draw dominos using metapost and ConTeXt. I borrow part of the code in Threeddice.mp by Dan Lueking for drawing dots. To display blank dominos where I want and drawing one domino work well but drawing several dominos where I want is not working well. (compare domino0 and domino1 in the example) Why do the dominos overlap or locate on the wrong place? Thank you for reading. Best regards, Dalyoung --Boundary_(ID_vXaLgGC69Pr4MrAWnpcPyA) Content-type: application/octet-stream; name=DominoMp.tex Content-transfer-encoding: 7bit Content-disposition: attachment; filename=DominoMp.tex % File threeddice.mp % Version 1.0 %%%%%%%%%%%%%%%%%%%% numeric dot_diam, corner_rad, face_margin, die_size; % diameter of a dot dot_diam := 1/6; % distance from edge of face to edge of dot. face_margin := dot_diam/2; % rounded corner radius corner_rad := dot_diam/2; % size of a single die face: die_size := 1cm; % Outline of a face. path die_face; die_face := (0,corner_rad){down} ..{right}(corner_rad,0)..(1-corner_rad,0){right} ..{up}(1,corner_rad)..(1,1-corner_rad){up} ..{left}(1-corner_rad,1)..(corner_rad,1){left} ..{down}(0,1-corner_rad)..cycle; % dot shape path dot; dot := fullcircle scaled dot_diam; % distance from nearest edge to center of dot: numeric dot_shift; dot_shift := dot_diam/2 + face_margin; % Five of 9 locations where a dot could be located. pair die_face[]; die_face 1 := ( 0, 1) + dot_shift*( 1,-1); % TL die_face 2 := ( 0,.5) + dot_shift*( 1, 0); % TC die_face 3 := (.5,.5) ; % CC die_face 4 := ( 1,.5) + dot_shift*(-1, 0); % BC die_face 5 := ( 1, 0) + dot_shift*(-1, 1); % BR picture pips[]; pips 1 := pips 2 := nullpicture; % dot in center addto pips 1 contour dot shifted die_face 3; % dots in TL and BR corners addto pips 2 contour dot shifted die_face 1; addto pips 2 contour dot shifted die_face 5; % dots in TR and BL corners pips 7 := pips 2 rotatedabout ((.5,.5), 90); % 3 dots on TL to BR diagonal pips 3 := pips 2; addto pips 3 also pips 1; % 3 dots on BL to TR diagonal pips 8 := pips3 rotatedabout ((.5,.5),90); % Dots in all 4 corners pips 4 := pips 2; addto pips 4 also pips 7; % dots in all four corners and center pips 5 := pips 4; addto pips 5 also pips 1; % 6 dots, 3 dots on top and three on bottom pips 6 := pips 4; addto pips 6 contour dot shifted die_face 2; addto pips 6 contour dot shifted die_face 4; % 6 dots, 3 at left and 3 at right pips 11 := pips6 rotatedabout ((.5,.5),90); % When three faces are showing, alternates 7, 8 and 11 for 2, 3 and 6 are % used when the total of the pips is odd (). This is an ad hoc rule that % matches what I see on my reference die. vardef pips_sel_iii (expr X)= X if odd pips_total: if (X=2) or (X=3) or (X=6): + 5 fi fi enddef; % % Choices are less easy when only two faces show: vardef pips_sel_ii (expr X,Y)= X if ((X=2) and ((Y=3) or (Y=4))) or ((X=3) and ((Y=1) or (Y=6))) or ((X=6) and ((Y=2) or (Y=5))): + 5 fi enddef; % for die with 3 faces showing: path topface[], llftface, lrtface; topface 1 = die_face rotated 45 yscaled (1/sqrt(3)); llftface = topface 1 rotated 120; lrtface = topface 1 rotated -120; % for die with 2 faces showing: path frontface; topface 2 := (die_face shifted (-.5,0)) yscaled (1/sqrt(2)); frontface := topface 2 rotated 180; pair D[]; D1 := dir 30; D2 := dir 150; path corner_connect[]; corner_connect1 := (point 6 of lrtface){up}..{D2}(point 3 of topface 1); corner_connect2 := (point 6 of topface 1){-D1}..{down}(point 3 of llftface); corner_connect3 := (point 6 of llftface){-D2}..{D1}(point 3 of lrtface); corner_connect4 := (point 0 of frontface){up}..(point 3 of topface 2){up}; corner_connect5 := (point 0 of topface 2){down}..(point 3 of frontface){down}; % Text parameter is for drawing options (transformation, withcolor, etc.); % expression parameters are the # of pips on top, left and right. def die_three(expr T, L, R) text _do_ = numeric pips_total; pips_total := T + L + R; draw topface 1 _do_; draw llftface _do_; draw lrtface _do_; for n = 1 upto 3: draw corner_connect[n] _do_; endfor draw pips[pips_sel_iii(T)] rotated 45 yscaled (1/sqrt(3)) _do_; draw pips[pips_sel_iii(L)] rotated 45 yscaled (1/sqrt(3)) rotated 120 _do_; draw pips[pips_sel_iii(R)] rotated 45 yscaled (1/sqrt(3)) rotated -120 _do_; enddef; def die_two (expr T, F) text _do_ = draw topface 2 _do_; draw frontface _do_; draw (pips[pips_sel_ii(T,F)] shifted .5left) yscaled (1/sqrt(2)) _do_; draw (pips[pips_sel_ii(F,T)] shifted .5left) yscaled (1/sqrt(2)) rotated 180 _do_; draw corner_connect4 _do_; draw corner_connect5 _do_; enddef; def die_one (expr F) text _do_ = draw die_face _do_; draw pips[F] _do_; enddef; if known outputtemplate: outputtemplate := "die3d-%c.mps"; elseif known mpversion: filenametemplate "die3d-%c.mps"; fi % The 8 permissible views (up to rotation) with three faces equally % visible of a right handed die: beginfig(123); die_three(1,2,3) scaled die_size; endfig; beginfig(135); die_three(1,3,5) scaled die_size; endfig; beginfig(154); die_three(1,5,4) scaled die_size; endfig; beginfig(142); die_three(1,4,2) scaled die_size; endfig; beginfig(246); die_three(2,4,6) scaled die_size; endfig; beginfig(263); die_three(2,6,3) scaled die_size; endfig; beginfig(365); die_three(3,6,5) scaled die_size; endfig; beginfig(456); die_three(4,5,6) scaled die_size; endfig; % The 12 permissible views (up to rotation) with only two faces equally % visible of a right handed die: beginfig(12); die_two(1,2) scaled die_size; endfig; beginfig(13); die_two(1,3) scaled die_size; endfig; beginfig(14); die_two(1,4) scaled die_size; endfig; beginfig(15); die_two(1,5) scaled die_size; endfig; beginfig(23); die_two(2,3) scaled die_size; endfig; beginfig(24); die_two(2,4) scaled die_size; endfig; beginfig(26); die_two(2,6) scaled die_size; endfig; beginfig(35); die_two(3,5) scaled die_size; endfig; beginfig(36); die_two(3,6) scaled die_size; endfig; beginfig(45); die_two(4,5) scaled die_size; endfig; beginfig(46); die_two(4,6) scaled die_size; endfig; beginfig(56); die_two(5,6) scaled die_size; endfig; % The 6 possible single faces beginfig(1); die_one(1) scaled die_size; endfig; beginfig(2); die_one(2) scaled die_size; endfig; beginfig(3); die_one(3) scaled die_size; endfig; beginfig(4); die_one(4) scaled die_size; endfig; beginfig(5); die_one(5) scaled die_size; endfig; beginfig(6); die_one(6) scaled die_size; endfig; end --Boundary_(ID_vXaLgGC69Pr4MrAWnpcPyA) Content-type: text/plain; CHARSET=US-ASCII Content-transfer-encoding: 7BIT --Boundary_(ID_vXaLgGC69Pr4MrAWnpcPyA) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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 ___________________________________________________________________________________ --Boundary_(ID_vXaLgGC69Pr4MrAWnpcPyA)--