From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/11155 Path: main.gmane.org!not-for-mail From: Jens-Uwe Morawski Newsgroups: gmane.comp.tex.context Subject: Re: MetaFun questions Date: Fri, 28 Feb 2003 15:22:56 +0100 Sender: ntg-context-admin@ntg.nl Message-ID: <20030228152256.02da080c.morawski@gmx.net> References: <20030227140929.20dd563d.morawski@gmx.net> <5.1.0.14.1.20030227155333.02435320@server-1> Reply-To: ntg-context@ntg.nl NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1046444232 16194 80.91.224.249 (28 Feb 2003 14:57:12 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 28 Feb 2003 14:57:12 +0000 (UTC) Return-path: Original-Received: from ref.vet.uu.nl ([131.211.172.13] helo=ref.ntg.nl) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18olwk-0004Cm-00 for ; Fri, 28 Feb 2003 15:57:10 +0100 Original-Received: from ref.ntg.nl (localhost.localdomain [127.0.0.1]) by ref.ntg.nl (Postfix) with ESMTP id 79F7510AF1; Fri, 28 Feb 2003 15:57:27 +0100 (MET) Original-Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by ref.ntg.nl (Postfix) with SMTP id EC04C10AEF for ; Fri, 28 Feb 2003 15:55:35 +0100 (MET) Original-Received: (qmail 6325 invoked by uid 0); 28 Feb 2003 14:55:34 -0000 Original-Received: from port1415.fra.ginko.net (HELO melior.localdomain) (212.202.67.145) by mail.gmx.net (mp019-rz3) with SMTP; 28 Feb 2003 14:55:34 -0000 Original-To: ntg-context@ntg.nl In-Reply-To: <5.1.0.14.1.20030227155333.02435320@server-1> X-Mailer: Sylpheed version 0.8.9 (GTK+ 1.2.10; i586-pc-linux-gnu) Errors-To: ntg-context-admin@ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.0.13 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.comp.tex.context:11155 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:11155 On Thu, 27 Feb 2003 15:55:41 +0100 Hans Hagen wrote: > 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 -extfigures.tmp - texutil, or something else, reads this file, determines the original size of the graphics and writes an input file (-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 %% -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