ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Context style macros for metapost
@ 2006-12-21  0:29 Aditya Mahajan
  2006-12-21  8:32 ` Taco Hoekwater
  0 siblings, 1 reply; 3+ messages in thread
From: Aditya Mahajan @ 2006-12-21  0:29 UTC (permalink / raw)


Hi,
  There are certain things that I do not like about metapost (it is not 
possible to specify drawoptions and filloptions separately, it lacks 
some of the features of tikz, etc.) and I was playing around trying to 
implement them. Being used to the ConTeXt way of things, I wanted to 
write macros in metapost the same way (define.... setup.... etc.) This 
is my first attempt --- a replacement for dashpattern macro.

delimiters [[ ]] ;

def definedash suffix @# =
   dodefinedash.@#
enddef ;

vardef dodefinedash@#[[text t]] =
   save on, off, w ;
   let on  = _on_  ;
   let off = _off_ ;
   w       = 0     ;
   picture @#      ;
   @# := nullpicture t
enddef ;

definedash
     [[myeven]]
     [[on 3 off 3]] ;

beginfig(1)
   draw (0,0)--(100,100) dashed myeven ;
endfig ;
end;

Is there a better way to do this in metapost?

Aditya

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

* Re: Context style macros for metapost
  2006-12-21  0:29 Context style macros for metapost Aditya Mahajan
@ 2006-12-21  8:32 ` Taco Hoekwater
  2006-12-21 15:43   ` Aditya Mahajan
  0 siblings, 1 reply; 3+ messages in thread
From: Taco Hoekwater @ 2006-12-21  8:32 UTC (permalink / raw)


Aditya Mahajan wrote:

> definedash
>      [[myeven]]
>      [[on 3 off 3]] ;
> 
> beginfig(1)
>    draw (0,0)--(100,100) dashed myeven ;
> endfig ;
> end;
> 
> Is there a better way to do this in metapost?

Not really, I think. A dash pattern like

   definedash
       [[stutter]]
       [[on 3 off 3 on 1 off 3]] ;

is allowed, making a true key-value solution almost impossible.
(and I expect similar situations with just about everything)

Taco

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

* Re: Context style macros for metapost
  2006-12-21  8:32 ` Taco Hoekwater
@ 2006-12-21 15:43   ` Aditya Mahajan
  0 siblings, 0 replies; 3+ messages in thread
From: Aditya Mahajan @ 2006-12-21 15:43 UTC (permalink / raw)


On Thu, 21 Dec 2006, Taco Hoekwater wrote:

> Aditya Mahajan wrote:
> 
> > definedash
> >      [[myeven]]
> >      [[on 3 off 3]] ;
> > 
> > beginfig(1)
> >    draw (0,0)--(100,100) dashed myeven ;
> > endfig ;
> > end;
> > 
> > Is there a better way to do this in metapost?
> 
> Not really, I think. A dash pattern like
>
>    definedash
>        [[stutter]]
>        [[on 3 off 3 on 1 off 3]] ;
> 
> is allowed, making a true key-value solution almost impossible.
> (and I expect similar situations with just about everything)

I am not too much worried about key-value assignment, but want a more 
familar (Contextish) interface. For example, I want to be able to do

definelines
 	[[verythin =.25bp,
           thin=.5bp,
           thick =1bp,
         verythick=1.5bp]]

transale internally into different pen shapes and then say

setupdraw[[lines=thick]]

which will store the pen "thick" in an internal variable (say 
_draw!pen_). The macro draw will start with

pickup pen _pen_ ;

So that I can say


setupdraw[[thick]]
draw (0,0)--(10,10) ;
....

setupdraw[[thin]]
draw (10,0)--(0,10) ;
.....


etc.

Basically, provide a layer of emulation around metapost, so that it 
appears to be more "intuitive". One thing that I am struggling with 
right now is to implement something equivalent to \dosingleempty, so 
that both

    draw (0,0)--(10,10) ;
and
   draw [[thick]] (0,0)--(10,10) ;

work. A lot of times, I find myself wanting to use different settings 
for draw and fill. Right now drawoptions specifies the options for 
both draw and fill. That is why, I want something like

  setupdraw[[lines=...,color=...,options=....]] and
  setupfill[[lines=...,color=...,options=....]] etc.

Right now, I am just experimenting on how difficult it is to have a 
consistent layer to do all this.

Aditya

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

end of thread, other threads:[~2006-12-21 15:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-21  0:29 Context style macros for metapost Aditya Mahajan
2006-12-21  8:32 ` Taco Hoekwater
2006-12-21 15:43   ` Aditya Mahajan

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