Stephan Hennig | 5 Feb 23:40 2009
Picon

ANN: colordef package preview

Hi,

I have written a small package colordef, that makes the color names
defined by dvips, SVG and X11 available to MetaPost.  A preview can be
found at

<URL:http://home.arcor.de/stephanhennig/Downloads/metapost/colordef-v014.zip>

Please test!  Comments are welcome!

I haven't named the package `color' intentionally, because I want to
leave that name open for a package, that provides some more operations
on colors, such as conversion between different color models or blending
colors similar to what the xcolor package provides.

Unfortunately, I have no idea how to implement an operator ! that works
like this:

  red!80  = .2[red, white]
  red!80!blue  = .2[red, blue]

The former case is simple, roughly

  primarydef col ! tint=
    min(1,max(0,tint/100))[white, col]
  enddef;

In the second case, however, there is the problem that from a MetaPost
point of view ! has two different meanings.

(Continue reading)

Dan&Jan Luecking | 6 Feb 08:48 2009
Picon

Re: ANN: colordef package preview

At 04:40 PM 2/5/2009, you wrote:

>Unfortunately, I have no idea how to implement an operator ! that works
>like this:
>
>   red!80  = .2[red, white]
>   red!80!blue  = .2[red, blue]
>
>The former case is simple, roughly
>
>   primarydef col ! tint=
>     min(1,max(0,tint/100))[white, col]
>   enddef;

You could have ! examine its second operand. If it is a
number, save that number somewhere. If it is a color,
assume it is the second ! of a colA!tint!colB and make
use of the previously saved numeric to recover colA.
This assumes that only the two cases are needed.
For example:

newinternal colorfactor;
primarydef op_i ! op_ii =
   if numeric op_ii:
     colorfactor := min(1,max(0,op_ii/100));
     (colorfactor)[white,op_i]
   elseif color op_ii:
     % presume first operand was produced from
     % (colorfactor)[white,somecolor], and find that color
     if colorfactor = 1:
(Continue reading)

Stephan Hennig | 6 Feb 14:04 2009
Picon

Re: ANN: colordef package preview

Dan&Jan Luecking schrieb:
> At 04:40 PM 2/5/2009, you wrote:
>
> You could have ! examine its second operand. If it is a number, save
> that number somewhere. If it is a color, assume it is the second ! of
> a colA!tint!colB and make use of the previously saved numeric to
> recover colA.

The problem with this approach is that it doesn't work with grey scale
colors, since that are numerics, too.  So you cannot distinguish between
a grey scale color and a tint argument.   In the following example

  0.618!30!.2

both ! see two numeric arguments.  One could let the first ! return a
non-numeric argument to flag this case, but then

  0.618!30

would fail, since it /should/ return a numeric.  A possible approach to
detect this case could be by checking the value of the arguments.  Grey
scale color arguments should always lie in the range [0, 1], but for

 0.618!0.5!0.2

that failed, too.  :(

>>In the second case, however, there is the problem that from a MetaPost
>>point of view ! has two different meanings.
>>
(Continue reading)

Steve MC Han | 7 Feb 02:36 2009
Picon

! MetaPost capacity exceeded

Hi,
 
Is there any way to increase memory size in Metapost? This is what I got.
 
 
This is MetaPost, Version 0.993 (Web2C 7.5.6)
(3trsf.mp [11] [12] [21] [31]
! MetaPost capacity exceeded, sorry [main memory size=1500000].
<for(4)> ...re:=nullpicture;h0:=h.scaled(u/(y+u));
                                                   ENDFOR
froct->...nullpicture;h0:=h.scaled(u/(y+u));endfor
                                    &n bsp;             ;draw.h;fi;
l.287 froct(4)
              ;
4 output files written: 3trsf.11 .. 3trsf.31
Transcript written on 3trsf.log.
Thanks,

--
http://tug.org/metapost/
Taco Hoekwater | 7 Feb 10:15 2009

Re: ! MetaPost capacity exceeded

Steve MC Han wrote:
> Hi,
>  
> Is there any way to increase memory size in Metapost? This is what I got.

You don't say what platform/distribution you are using, but it seems
you have texlive 2007. In any case, the following advice is for tex-live
based systems; miktex has a different inifile mechanism.

In texmf.cnf, there is a parameter named main_memory, which is
set at 1500000 in your installation. To find texmf.cnf:

   $ kpsewhich texmf.cnf

You can increase that parameter up to (if I recall correctly) 8000000.

Afterwards, you have to regenerate the format(s) via fmtutil.
If you want your change to affect only metapost, add or change
main_memory.mpost only. Otherwise, you will have to regerate the
latex etc. formats as well.

Best wishes,
Taco
--
http://tug.org/metapost/

Taco Hoekwater | 7 Feb 15:45 2009

Re: ! MetaPost capacity exceeded

Steve MC Han wrote:
> 
> <<Afterwards, you have to regenerate the format(s) via fmtutil.
> If you want your change to affect only metapost, add or change
> main_memory.mpost only. Otherwise, you will have to regerate the
> latex etc. formats as well.>>
> 
> This part I am afraid to say that I don't understand one bit. If you 
> could enumerate a little bit in detail, I would appreciate greately.

I believe you simply have to run

   $ fmtutil --all

but perhaps

   $ fmtutil-sys --all

is a little better (this re-creates the system-wide formats, not
just adds new ones for the current user). I do not use texlive,
and therefore I am uncertain what the 'best' command is.

Best wishes,
Taco
policy is.

--
http://tug.org/metapost/

Steve MC Han | 7 Feb 15:39 2009
Picon

Re: ! MetaPost capacity exceeded

Dear Taco,
 
Thank you for your response. You are correct that I have TaxLive 2007. But I am sorry to say that I don't understand what you described
 
<<In texmf.cnf, there is a parameter named main_memory, which is
set at 1500000 in your installation. To find texmf.cnf:

  $ kpsewhich texmf.cnf

You can increase that parameter up to (if I recall correctly) 8000000.>>
 
 
I could open this file using my editor. So, can I just change 1500000 to 800000 in the sentence at 524th line in the file:

main_memory = 1500000 % words of inimemory available; also applies to inimf&mp
 

<<Afterwards, you have to regenerate the format(s) via fmtutil.
If you want your change to affect only metapost, add or change
main_memory.mpost only. Otherwise, you will have to regerate the
latex etc. formats as well.>>

This part I am afraid to say that I don't understand one bit. If you could enumerate a little bit in detail, I would appreciate greately.
 
Thanks

--- On Sat, 2/7/09, Taco Hoekwater <taco <at> elvenkind.com> wrote:
From: Taco Hoekwater <taco <at> elvenkind.com>
Subject: Re: [metapost] ! MetaPost capacity exceeded
To: hmc0907 <at> yahoo.com
Cc: "MetaPost List" <metapost <at> tug.org>
Date: Saturday, February 7, 2009, 1:15 AM

Steve MC Han wrote: > Hi, > Is there any way to increase memory size in Metapost? This is what I got. You don't say what platform/distribution you are using, but it seems you have texlive 2007. In any case, the following advice is for tex-live based systems; miktex has a different inifile mechanism. In texmf.cnf, there is a parameter named main_memory, which is set at 1500000 in your installation. To find texmf.cnf: $ kpsewhich texmf.cnf You can increase that parameter up to (if I recall correctly) 8000000. Afterwards, you have to regenerate the format(s) via fmtutil. If you want your change to affect only metapost, add or change main_memory.mpost only. Otherwise, you will have to regerate the latex etc. formats as well. Best wishes, Taco

--
http://tug.org/metapost/
Steve MC Han | 7 Feb 16:55 2009
Picon

Re: ! MetaPost capacity exceeded

Thanks Taco,
 
Second command
 
$ fmtutil-sys --all

does not work, but first one does.
 
Thank you very much.
 
 

--- On Sat, 2/7/09, Taco Hoekwater <taco <at> elvenkind.com> wrote:
From: Taco Hoekwater <taco <at> elvenkind.com>
Subject: Re: [metapost] ! MetaPost capacity exceeded
To: hmc0907 <at> yahoo.com
Cc: "MetaPost List" <metapost <at> tug.org>
Date: Saturday, February 7, 2009, 6:45 AM

Steve MC Han wrote: > > <<Afterwards, you have to regenerate the format(s) via fmtutil. > If you want your change to affect only metapost, add or change > main_memory.mpost only. Otherwise, you will have to regerate the > latex etc. formats as well.>> > > This part I am afraid to say that I don't understand one bit. If you could enumerate a little bit in detail, I would appreciate greately. I believe you simply have to run $ fmtutil --all but perhaps $ fmtutil-sys --all is a little better (this re-creates the system-wide formats, not just adds new ones for the current user). I do not use texlive, and therefore I am uncertain what the 'best' command is. Best wishes, Taco policy is.

--
http://tug.org/metapost/
Karl Berry | 8 Feb 00:37 2009

Re: ! MetaPost capacity exceeded

    > If you want your change to affect only metapost, add or change
    > main_memory.mpost only

I'm curious what kind of graph you are generating that the current
main_memory is insufficient for!  My knee-jerk reaction to such reports
is always to just increase the defaults, since if you're running into
it, probably others are too.  It's not just an infinite recursion or
some such?

    texlive ...and therefore I am uncertain what the 'best' command is.

Er, well, it all depends on what one wants to do :).  It's already done,
but for the record ...

As you already mentioned, fmtutil generates stuff per-user; fmtutils-sys
generates it for the "system" install.  In this case, I gather there was
no permission to write in the system dirs.

As for the options, here are the principal ones:
  --all                      recreate all format files
  --missing                  create all missing format files
  --refresh                  recreate only existing format files
  --byfmt formatname         (re)create format for `formatname'

So,  fmtutil --byfmt mpost  would have been my first suggestion, 
since it didn't seem desired to remake the tex or metafont formats here.

Happy formatting,
karl
--
http://tug.org/metapost/

Steve MC Han | 8 Feb 02:17 2009
Picon

Re: ! MetaPost capacity exceeded

Hi Karl,
 
Thank you for your response.
 
It's just a simple recursion drawing.
 
numeric n, m, x,y,z,aa,bb;
picture h, h[], g, g[];
path p,p[];
pair a,a[],b,b[];
 
beginfig(1)
n:=8;
u:=.6cm;
for i=0 upto n-1:
a[i]:=u*dir(360*i/n);
endfor;
p0:=a[0] for i:=1 upto n-1: --a[i] endfor --cycle;
a:=u*dir(360/n) shifted a1;
y:=arclength ((0,0)--a);
y:=1.2y;

def froct(expr m)=
 if m=0:
   fill p0 scaled ((y+u)/u) withcolor red;
 else:
  fill p0 withcolor red;
  h0:=currentpicture;
  currentpicture:=nullpicture;
   for j=1 upto m:
   for i=0 upto n-1:
    b[i]:=y*dir(360*i/n);
    draw h0 shifted b[i];
   endfor;
   h:=currentpicture;
   currentpicture:=nullpicture;
   h0:=h scaled (u/(y+u));
   endfor;
   draw h;
  fi;
enddef;
 
froct(1);
h1:=currentpicture;
currentpicture:=nullpicture;

froct(2);
h2:=currentpicture;
currentpicture:=nullpicture;
froct(4);
h3:=currentpicture;
currentpicture:=nullpicture;
draw h1;
draw h2 shifted (8u,0);
draw h3 shifted (16u,0); 
endfig;
end
 

If you change froct(5) in picture 3, then the capacity is exceeded 800000 already, which is strange because 8^5 is only 32768, even though the growth is exponential, it will exceed any memory capacity with a few more iteration, I admit.
 
I don't know anything about what you described below, because I am a novice in programming and computer.
 
 
Another strange thing for me is at the beginning of the definition of a function,
 
def froct(expr m)=
 if m=0:
   fill p0 scaled ((y+u)/u) withcolor red;
 else:
  fill p0 withcolor red;
  h0:=currentpicture;
  currentpicture:=nullpicture;
 
these two highlighted sentences look redundant, so I pull them outside of function froct such as:
 
  fill p0 withcolor red;
  h0:=currentpicture;
  currentpicture:=nullpicture;
 
def froct(expr m)=
 if m=0:
   draw h0 scaled ((y+u)/u);
 else:
  draw h0;
 
 
this looks more efficient to me, but in this case, it cannot even perform 4 iterations. So, obviously, it is less efficient than the original one.
 
I am just a beginner of programming (this is basically my first), I would appreciate it very much if any experts can give some insight.
 
 
Thanks,
Steve
 


--- On Sat, 2/7/09, Karl Berry <karl <at> freefriends.org> wrote:
From: Karl Berry <karl <at> freefriends.org>
Subject: Re: [metapost] ! MetaPost capacity exceeded
To: hmc0907 <at> yahoo.com, metapost <at> tug.org
Date: Saturday, February 7, 2009, 3:37 PM

> If you want your change to affect only metapost, add or change > main_memory.mpost only I'm curious what kind of graph you are generating that the current main_memory is insufficient for! My knee-jerk reaction to such reports is always to just increase the defaults, since if you're running into it, probably others are too. It's not just an infinite recursion or some such? texlive ...and therefore I am uncertain what the 'best' command is. Er, well, it all depends on what one wants to do :). It's already done, but for the record ... As you already mentioned, fmtutil generates stuff per-user; fmtutils-sys generates it for the "system" install. In this case, I gather there was no permission to write in the system dirs. As for the options, here are the principal ones: --all recreate all format files --missing create all missing format files --refresh recreate only existing format files --byfmt formatname (re)create format for `formatname' So, fmtutil --byfmt mpost would have been my first suggestion, since it didn't seem desired to remake the tex or metafont formats here. Happy formatting, karl

--
http://tug.org/metapost/

Gmane