From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/14389 Path: main.gmane.org!not-for-mail From: David Arnold Newsgroups: gmane.comp.tex.context Subject: Draw grid Date: Fri, 02 Jan 2004 10:34:48 -0800 Sender: ntg-context-admin@ntg.nl Message-ID: <3.0.5.32.20040102103448.00984d20@mail.northcoast.com> Reply-To: ntg-context@ntg.nl NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: sea.gmane.org 1073072147 9917 80.91.224.253 (2 Jan 2004 19:35:47 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 2 Jan 2004 19:35:47 +0000 (UTC) Cc: ntg-context@ntg.nl Original-X-From: ntg-context-admin@ntg.nl Fri Jan 02 20:35:34 2004 Return-path: Original-Received: from ref.vet.uu.nl ([131.211.172.13] helo=ref.ntg.nl) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AcV53-0001pj-00 for ; Fri, 02 Jan 2004 20:35:33 +0100 Original-Received: from ref.ntg.nl (localhost.localdomain [127.0.0.1]) by ref.ntg.nl (Postfix) with ESMTP id AD77F10B30; Fri, 2 Jan 2004 20:35:08 +0100 (MET) Original-Received: from smtp.inreach.com (smtp.inreach.com [209.142.2.34]) by ref.ntg.nl (Postfix) with SMTP id 2498A10AFC for ; Fri, 2 Jan 2004 20:34:12 +0100 (MET) Original-Received: (qmail 32642 invoked from network); 2 Jan 2004 19:34:30 -0000 Original-Received: from unknown (HELO newmicronpc) (209.209.15.62) by smtp.inreach.com with SMTP; 2 Jan 2004 19:34:30 -0000 X-Sender: darnold@mail.northcoast.com (Unverified) X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.5 (32) Original-To: pragma@wxs.nl Errors-To: ntg-context-admin@ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.0.13 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.comp.tex.context:14389 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:14389 Hans, This sample code will give you an idea of my last feature request for mp-tool. Often, I will design my schematic on graph paper, then start to code. But there are times when I like to work interactively, write a little code, test to see what I get, adjust, ... When I am in that mode, a grid is "very" helpful. Once I am through with adjustments, I simply comment out the line " drawgrid(0,0,20,10,1u,1u);". My drawgrid routine was stolen from the schema.mp file and adjusted for a quick fix (I am writing for a deadline again), but it works. But it would be nice if something like this were in mp-tool. Turn on your numbered grid, work interactively, turn it off when done. Very nice. Happy New Year! input mp-tool def drawgrid(expr xo,yo,nx,ny,sx,sy)= begingroup save cpen,result; pen cpen; picture result; cpen:=pencircle scaled 1pt; result:=nullpicture; for x=0 upto nx: for y=0 upto ny: addto result doublepath (x*sx,y*sy) withpen cpen; endfor endfor defaultfont:="cmr7"; defaultscale:=7pt/fontsize defaultfont; for x=0 upto nx: addto result also thelabel.bot(decimal(x),(x*sx,0)) withpen cpen; endfor for y=0 upto ny: addto result also thelabel.lft(decimal(y),(0,y*sy)) withpen cpen; endfor; draw result; endgroup enddef; beginfig(6); %initialize scale numeric u; 1u=0.25in; drawgrid(0,0,20,10,1u,1u); %draw line for measurement later draw (0,0)--(10u,0); %draw base for pivot path base; base:=unitsquare xyscaled (4u,1u); base:=base shifted (8u,-2u); stripe_path_a(withcolor black)(draw) base withcolor white; draw (8u,-1u)--(12u,-1u); %draw pivot path tri; tri:=(-1,-1)--(0,1)--(1,-1)--cycle; tri:=tri scaled u; tri:=tri shifted (10u,0); fill tri withcolor 0.85white; %initialize pendulum path pend; pend:=(9.5,-0.5)--(10.5,-0.5)--(10.5,10.5)--(9.5,10.5)--cycle; pend:=pend scaled u; draw pend; %draw pivot point drawdot(10u,0) withpen pencircle scaled 6pt; %draw spring block left path left; left:=(2,9)--(3,9)--(3,11)--(2,11)--cycle; left:=left scaled u; stripe_path_a(withcolor black)(draw) left withcolor white; draw (3u,9u)--(3u,11u); %draw spring block right path right; right:=(17,9)--(18,9)--(18,11)--(17,11)--cycle; right:=right scaled u; stripe_path_a(withcolor black)(draw) right withcolor white; draw (17u,9u)--(17u,11u); %spring path spring, link; link:=(0,0)--(0.25,0.5)--(0.75,-0.5)--(1,0); spring:=link; for k=1 upto 2: spring:=spring--(link shifted (k,0)); endfor spring:=spring scaled u; %left spring draw (3u,10u)--(5u,10u); draw spring shifted (5u,10u); draw (8u,10u)--(10u,10u); %right spring draw (10u,10u)--(12u,10u); draw spring shifted (12u,10u); draw (15u,10u)--(17u,10u); %draw spring contact point drawdot(10u,10u) withpen pencircle scaled 6pt; %label springs label(btex $k$ etex, (6.5u,11u)); label(btex $k$ etex, (13.5u,11u)); %label some measurement lengths pair A, B, C, D, E; A:=(1u,0); B:=(1u,10u); C:=(5u,0); D:=(5u,5u); E:=(10u,5u); drawdblarrow A--B; label.lft(btex $L$ etex, 0.5[A,B]); drawdblarrow C--D; draw (0,10u)--(2u,10u); label.lft(btex $L/2$ etex, 0.5[C,D]); draw (4u,5u)--(6u,5u); drawdot(E) withpen pencircle scaled 6pt; label.top(btex cm etex,E shifted (0,5)); endfig;