Hi, i would like to know - 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 - 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 Best, Jens
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
- 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 Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
has the original figure-size scaled 2 and not unitsquare scaled 2
can you be a bit more explicit
I might be able to help since I had this problem with scaling external figures in mpost MetaFun. In ConTeXt \externalfigure[xxx.pdf] brings in a picture at the size of the picture. Scaling modifies that size. In mpost MetaFun externalfigure("xxx.jpg") brings in a figure at the size of unitsquare scaled 2 which then has to be scaled up by other values to get to a useable picture which involved me in quite a lot of trial and error. I did not try this with pdf. -- Nigel
At 07:05 PM 2/27/2003 +0000, you wrote:
has the original figure-size scaled 2 and not unitsquare scaled 2
can you be a bit more explicit
I might be able to help since I had this problem with scaling external figures in mpost MetaFun.
In ConTeXt \externalfigure[xxx.pdf] brings in a picture at the size of the picture. Scaling modifies that size.
how about scaled 2 xscaled 2 yscaled 5 xyscaled (2,5) and xsized 2cm ysized 4cm xysized (2cm,4cm) Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
has the original figure-size scaled 2 and not unitsquare scaled 2
can you be a bit more explicit
I might be able to help since I had this problem with scaling external figures in mpost MetaFun.
In ConTeXt \externalfigure[xxx.pdf] brings in a picture at the size of the picture. Scaling modifies that size.
how about
scaled 2 xscaled 2 yscaled 5 xyscaled (2,5)
and
xsized 2cm ysized 4cm xysized (2cm,4cm)
I think we understand that. The point is that whereas Context knows the size of the original picture, MetaFun does not. -- Nigel
At 09:17 AM 2/28/2003 +0000, Nigel King wrote:
has the original figure-size scaled 2 and not unitsquare scaled 2
can you be a bit more explicit
I might be able to help since I had this problem with scaling external figures in mpost MetaFun.
In ConTeXt \externalfigure[xxx.pdf] brings in a picture at the size of the picture. Scaling modifies that size.
how about
scaled 2 xscaled 2 yscaled 5 xyscaled (2,5)
and
xsized 2cm ysized 4cm xysized (2cm,4cm)
\getfiguredimensions[...] \let\MyFigWid\figurewidth \let\MyFigHei\figureheight .... xysized(\MyFigWid,\MyFigHei)
I think we understand that. The point is that whereas Context knows the size of the original picture, MetaFun does not.
see above or meta-fig.tex Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
On Thu, 06 Mar 2003 14:13:47 +0100
Hans Hagen
At 09:17 AM 2/28/2003 +0000, Nigel King wrote:
has the original figure-size scaled 2 and not unitsquare scaled 2
can you be a bit more explicit
I might be able to help since I had this problem with scaling external figures in mpost MetaFun.
In ConTeXt \externalfigure[xxx.pdf] brings in a picture at the size of the picture. Scaling modifies that size.
how about
scaled 2 xscaled 2 yscaled 5 xyscaled (2,5)
and
xsized 2cm ysized 4cm xysized (2cm,4cm)
\getfiguredimensions[...] \let\MyFigWid\figurewidth \let\MyFigHei\figureheight
....
xysized(\MyFigWid,\MyFigHei)
ahh, interesting. A plain metapost way as described in my other mail would be possible if i could run pdftex after the mpost run and run afterwards mpost again. How this could be done? Jens
At 06:16 PM 3/6/2003 +0100, you wrote:
xysized(\MyFigWid,\MyFigHei)
ahh, interesting. A plain metapost way as described in my other mail would be possible if i could run pdftex after the mpost run and run afterwards mpost again. How this could be done?
Currently we're making a bunch of tools that deal with graphics (a part of the example framework). It's not that hard to provide a mechanism that will write a file with data which is acceptable for metapost. anyhow, here's a solution: In cont-new.tex, add: \def\showexternalfigured {\bgroup \immediate\openout\scratchwrite=mpfigs.mp \def\presetfigure[##1][##2]% {\getfiguredimensionsonly[##1]% \pagefigure[##1]% \immediate\write\scratchwrite {registerfigure("##1",\figurewidth,\figureheight)}} \pushendofline \readjobfile\@@exfile\donothing\donothing \popendofline \immediate\closeout\scratchwrite \egroup} in texexec.pl, patch: [abc] into [abcd] now you can run (in advance!): texexec *.png --pdf --fig=d and get a file mpfigs.mp copy the following code to mp-figs.mp: pair figuredimensions[]; string figurenames[] ; numeric noffigures ; noffigures := 0 ; def registerfigure(expr name,width,height) = noffigures := noffigures + 1 ; figurenames[noffigures] := name ; figuredimensions[noffigures] := (width,height) ; enddef ; vardef figuredimensions(expr name) = save ok, i ; boolean ok ; numeric i ; i := 0 ; ok := false ; forever : i := i + 1 ; ok := (name = figurenames[i]) ; exitif ok ; endfor ; if ok : figuredimensions[i] else : origin fi enddef ; vardef figurewidth(expr name) = xpart figuredimensions(name) enddef ; vardef figureheight(expr name) = ypart figuredimensions(name) enddef ; end and now you can say: input mp-figs.mp ; input mpfigs.mp ; and voila: figurewidth("yourfig") returns the width of the graphic so: just one run in advance is needed [just for testing; i'll think this over before i freeze/add it to context] Hans Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
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
At 03:22 PM 2/28/2003 +0100, you wrote:
\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
i'll have a look at it; i'm not even sure if transparent shades are possible, since the shading vectors need color vectors (implementing shading and transparency took me quite some time to figure out from the fuzzy specs] (btw: \startMPcode \stopMPcode or \startMPpage \stopMPpage saves you some typing) Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
On Mon, 03 Mar 2003 22:10:27 +0100
Hans Hagen
At 03:22 PM 2/28/2003 +0100, you wrote:
\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
i'll have a look at it; i'm not even sure if transparent shades are possible, since the shading vectors need color vectors (implementing shading and transparency took me quite some time to figure out from the fuzzy specs]
i had a look in the spec today and it seems that it is impossible since transparency can only be applied to objects or groups but not to a color vector. So, we need to wait until PDF1.X supports this. If somebody has good connections to Adobe please ask for this very feature. Jens P.S. If somebody has access to Adobe Illustrator then i could help to know if it is possible there ;-)
participants (3)
-
Hans Hagen
-
Jens-Uwe Morawski
-
Nigel King