On Thu, 27 Feb 2003 15:55:41 +0100
Hans Hagen
At 02:09 PM 2/27/2003 +0100, you wrote:
- if i can draw a gradient/shading with two RGBA colors, for example, a gradient starting with red=1 and alpha=0.5 and ending with green=1 and alpha=0.7
in supp-mpe.tex seatch for:
CircularShade LinearShade DuotoneShade
i know linear_shade, circular_shade...; the question is how can i use them with transparency: \definecolor[sa][r=1,t=0.7,a=1] \definecolor[ea][g=1,t=0.5,a=1] \definecolor[s][r=1] \definecolor[e][g=1] \startMPgraphic path p ; p := unitsquare xscaled 5cm yscaled 5cm ; fill p shifted (4cm,4cm) withcolor .7white ; fill p shifted (-3cm,-3cm) withcolor .8white ; linear_shade(p,0,\MPcolor{s},\MPcolor{e}); \stopMPgraphic \loadcurrentMPgraphic\placeMPgraphic the code above draws a gradient for colors s and e but not for colors sa and ea. Is this because gradients _and_ transparency together are not supported or is it because i do it the wrong way.
- if it is possible to add some capabilities to texutil, or where else it is needed, so that externalfigure "somefile" scaled 2 ;
has the original figure-size scaled 2 and not unitsquare scaled 2
can you be a bit more explicit
for example, if i have a PNG graphic with width 216 pixels and height of 144 pixels, then the ratio of width/height is 3/2. If i scale this figure with factor 2 using \externalfigure in ConTeXt then the aspectratio is kept. Using the externalfigure("figurefile") scaled 2 in MetaPost results in figure with a size of unitsquare scaled 2 Neither the ratio of width and height nor the size of the original graphic are maintained or have any influence on the output. Thus, i would like to suggest something that: - assuming following MP code: externalfigure("mygraphic.png") scaled 2 ; externalfigure("anothergraphic.pdf"") scaled 5 ; - in a first metapost-run each "externalfigure" writes the name of the graphic file in a temporary file, for example <jobname>-extfigures.tmp - texutil, or something else, reads this file, determines the original size of the graphics and writes an input file (<jobname>-extfigures.mp) for the following MP run that contains for example: numeric numof_externalfigures, widthof_externalfigure[], heightof_externalfigure[] ; string nameof_externalfigure[] ; numof_externalfigures:=2 ; nameof_externalfigure[1] := "mygraphic.png" ; widthof_externalfigure[1] := 2cm ; heightof_externalfigure[1]:= 4cm ; nameof_externalfigure[2] := "anothergraphic.pdf" ; widthof_externalfigure[2] := 3cm ; heightof_externalfigure[2]:= 5cm ; - then the macro "doexternalfigure" could be : def doexternalfigure (expr filename) text transformation = begingroup ; save p, t ; picture p ; transform t ; %% here comes the part that writes the filename to %% <jobname>-extfigures.tmp %%>> added save w_, h_ ; numeric w_, h_ ; w_ := 1 ; h_ := 1 ; if (known numof_externalfigures): if (numof_externalfigures>0): for i=1 upto numof_externalfigures: if (nameof_externalfigure[i]=filename): w_ := widthof_externalfigure[i] ; h_ := heightof_externalfigure[i] ; fi; endfor; fi; fi; %%<< %%>> changed % % original: % % p := nullpicture ; t := identity transformation ; % p := nullpicture ; t := ( (identity xscaled w_) yscaled h_ ) transformation ; %%<< flush_special(10, 9, dddecimal (xxpart t, yxpart t, xypart t) & " " & dddecimal (yypart t, xpart t, ypart t) & " " & filename) ; addto p contour unitsquare scaled 0 ; setbounds p to unitsquare transformed t ; _color_counter_ := _color_counter_ + 1 ; draw p withcolor (_special_signal_/1000,_color_counter_/1000,_special_counter_/1000) ; endgroup ; enddef ; This should allow to maintain size and aspectratio of external figures, even in MP. The problem is, how can texutil determine the original size of the figures?! Is it possible to implement this? Best, Jens