two requests with minor priority

0 views
Skip to first unread message

Mojca Miklavec

unread,
May 8, 2006, 12:50:57 PM5/8/06
to gnuplot...@googlegroups.com
Hello,

while Hans is still "in the middle of trying to hack metapost":

For complete (and first of all: more efficient) gnuplot support in
metafun I would need "two" additional functions. They are both
low-priority requests. (High-priority request would be to make
\startGNUPLOT work with the new context terminal efficiently and to be
able to make different settings - I can post a more precise
specification about that.)

1. Embeding bitmap figures (I need only RGB, but implementing
grayscale and cmyk probably doesn't take much more time than it would
take if someone would ask for it later)

1a) draw bitmap_image(3,2,"fffee200cc...") % perhaps something to
distinguish rgb, cmyk, grayscale
which would draw an image fron the data from the string

1b) Since strings probably have a limited size, something similar to
<<
fffee200cc ...
...
>>
or
start_data
....
stop_data
might be handy for large images (Taco said that this might be an
interesting challenge for Hans, but now that "mp.rb" is written it's
probably not that challenging any more - I don't know.)

1c) If someone would like to create an image from some function or
whatever other source of data ...:

color a[][];
a[0][0] = red;
a[0][1] = .3red
a[1][0] = green;
a[1][1] = .6green;
draw bitmap_image(2, 2, a);


2. color palettes (smooth shading) for pm3d, see
http://gnuplot.sourceforge.net/demo_4.1/pm3d.html

I got a headache once I figured out how this is implemented in
gnuplot. A user is free to choose a function for each of the three
color components (which might be RGB, HSV, CMY or a couple of other
strange I-never-heard-about-them colorspaces), ie: red component might
be 0, 1, linear, sin, ..., green might also be an arbitrary function,
... The color of a point is then determined from its value
(red_function(value), greenfunction(value), bluefunction(value)),
where 0 <= value <= 1.

If the function is linear (which is almost never the case) then linear
shading might be used, otherwise the only possibility that came to my
mind was an approximation with "linear shading with stitching
function" (you determine, say, a color in 20 points and the color in
the rest of the points is [linearly] interpolated between the 20
chosen points).

PostScript simply draws 1000 boxes of a single color, but this is both
inefficient and horrible-looking because of some white stripes
inbetween (it prints out OK, but the rendering in the screen is
horrible - you can notice that if you compile the attached file).


So I would need something to be able to draw such patterns as the ones
in the attached file, but using "smooth shading" instead of (ugly)
boxes. I would provide fractions (from 0 to 1) and colors at those
fractions (for example: there is a "yellow" color at 4/10 of the box)
as input.

Thanks a lot,
Mojca

funkcije.mp

Hans Hagen

unread,
May 8, 2006, 1:11:31 PM5/8/06
to gnuplot...@googlegroups.com
Mojca Miklavec wrote:
> 1. Embeding bitmap figures (I need only RGB, but implementing
> grayscale and cmyk probably doesn't take much more time than it would
> take if someone would ask for it later)
>
uncompressed bitmaps i suppose, else we can use those ppm to whatever
converters and you can write portable (hex encoded) temp files

> 1a) draw bitmap_image(3,2,"fffee200cc...") % perhaps something to
> distinguish rgb, cmyk, grayscale
> which would draw an image fron the data from the string
>
> 1b) Since strings probably have a limited size, something similar to
> <<
> fffee200cc ...
> ...
> >>
> or
> start_data
> ....
> stop_data
> might be handy for large images (Taco said that this might be an
> interesting challenge for Hans, but now that "mp.rb" is written it's
> probably not that challenging any more - I don't know.)
>
so you want me to read the pdf spec ...

> PostScript simply draws 1000 boxes of a single color, but this is both
> inefficient and horrible-looking because of some white stripes
> inbetween (it prints out OK, but the rendering in the screen is
> horrible - you can notice that if you compile the attached file).
>
>
how about using image instead of push/pop currentpicture :

vardef colorbox(expr formula_r, formula_g, formula_b) =
image (
save steps; numeric steps; steps := 100;
for i=0 upto steps:
fill unitsquare shifted (i,0) withcolor % can also be HSV or CMY
color
(xformula(formula_r, i/steps),
xformula(formula_g, i/steps),
xformula(formula_b, i/steps));
endfor;
currentpicture := currentpicture xscaled(1/(steps+1));
)
enddef;

> So I would need something to be able to draw such patterns as the ones
> in the attached file, but using "smooth shading" instead of (ugly)
> boxes. I would provide fractions (from 0 to 1) and colors at those
> fractions (for example: there is a "yellow" color at 4/10 of the box)
> as input.
>

hm, beyond my math skills

Hans

-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------

Hans Hagen

unread,
May 8, 2006, 1:33:21 PM5/8/06
to gnuplot...@googlegroups.com
Concerning bitmaps ... one cannot construct xobjects in pdftex so this
has to happen outside. An option is to try to get ppmtopng/jpeg into
pdftex ...

Mojca Miklavec

unread,
May 8, 2006, 1:57:43 PM5/8/06
to gnuplot...@googlegroups.com
On 5/8/06, Hans Hagen wrote:
>
> Mojca Miklavec wrote:
> > 1. Embeding bitmap figures (I need only RGB, but implementing
> > grayscale and cmyk probably doesn't take much more time than it would
> > take if someone would ask for it later)
> >
> uncompressed bitmaps i suppose, else we can use those ppm to whatever
> converters and you can write portable (hex encoded) temp files

Sure, I don't need any compression.

> > 1a) draw bitmap_image(3,2,"fffee200cc...") % perhaps something to
> > distinguish rgb, cmyk, grayscale
> > which would draw an image fron the data from the string
> >
> > 1b) Since strings probably have a limited size, something similar to
> > <<
> > fffee200cc ...
> > ...
> > >>
> > or
> > start_data
> > ....
> > stop_data
> > might be handy for large images (Taco said that this might be an
> > interesting challenge for Hans, but now that "mp.rb" is written it's
> > probably not that challenging any more - I don't know.)
> >
> so you want me to read the pdf spec ...

I sent a PostScript example last time (and can send it once more if
needed). I don't know how to prepare a PDF document though.

The point in "start_data/stop_data" was not in preparing the PDF file,
but in simple "parsing" that would convert the delimited content into
a string which would make it into the final PDF file (I assume that
metapost strings cannot be relly long, but images might soon become
large).

> how about using image instead of push/pop currentpicture :

Thanks, I didn't think (know?) about it.

> > So I would need something to be able to draw such patterns as the ones
> > in the attached file, but using "smooth shading" instead of (ugly)
> > boxes. I would provide fractions (from 0 to 1) and colors at those
> > fractions (for example: there is a "yellow" color at 4/10 of the box)
> > as input.
> >
> hm, beyond my math skills

I can prepare a hard-coded PostScript example (I don't know how to
make PDFs, but it should be almost the same). There's no special math
included at all, I just don't know thousands of steps needed, so that
some special metapost code & variables would land in a PDF document.

I would provide, say, ten colors and the fraction of the box where
this color should be placed and then a stitching function should be
used to color the box. Well ... that one might indeed need a look into
PS/PDF specification

Thanks a lot,

Mojca

Mojca Miklavec

unread,
May 8, 2006, 2:03:36 PM5/8/06
to gnuplot...@googlegroups.com
On 5/8/06, Hans Hagen wrote:
>
> Concerning bitmaps ... one cannot construct xobjects in pdftex so this
> has to happen outside. An option is to try to get ppmtopng/jpeg into
> pdftex ...

Why do you need an xobject (not that I know what that is, I just googled a bit)?
I suppose that it's possible to write a hex string to PDF directly (I
would send you an example if I knew how to construct the numbers at
the end of PDF file so that the file is valid. If I convert a simple
PS image into PDF, it gets compressed, so I can't show you that one
either.), although some proper image support would make it easier than
hacking around on your own.

I thought that this shouldn't be any more complex than transparent
colors and/or implementing cmyk colors. But I may be wrong.

Mojca

Hans Hagen

unread,
May 8, 2006, 2:38:00 PM5/8/06
to gnuplot...@googlegroups.com
Mojca Miklavec wrote:
> On 5/8/06, Hans Hagen wrote:
>
>> Concerning bitmaps ... one cannot construct xobjects in pdftex so this
>> has to happen outside. An option is to try to get ppmtopng/jpeg into
>> pdftex ...
>>
>
> Why do you need an xobject (not that I know what that is, I just googled a bit)?
> I suppose that it's possible to write a hex string to PDF directly (I
> would send you an example if I knew how to construct the numbers at
> the end of PDF file so that the file is valid. If I convert a simple
> PS image into PDF, it gets compressed, so I can't show you that one
> either.), although some proper image support would make it easier than
> hacking around on your own.
>
inline images have some limitations (no reuse for instance)

Hans Hagen

unread,
May 8, 2006, 2:39:24 PM5/8/06
to gnuplot...@googlegroups.com
Mojca Miklavec wrote:
> I can prepare a hard-coded PostScript example (I don't know how to
> make PDFs, but it should be almost the same). There's no special math
> included at all, I just don't know thousands of steps needed, so that
> some special metapost code & variables would land in a PDF document.
>
ok let's see how the ps looks

> I would provide, say, ten colors and the fraction of the box where
> this color should be placed and then a stitching function should be
> used to color the box. Well ... that one might indeed need a look into
> PS/PDF specification
>
>
indeed maybe patterns or so
Reply all
Reply to author
Forward
0 new messages