* externalfigure and width/height scaling
@ 2006-03-12 12:44 nico
2006-03-12 19:02 ` Hans Hagen
0 siblings, 1 reply; 4+ messages in thread
From: nico @ 2006-03-12 12:44 UTC (permalink / raw)
Hello,
I am new to ConTeXt, so please be patient with my newbie questions.
Looking at the \externalfigure capabilities, I haven't found any option
allowing to scale only one dimension (or scale both dimensions in an
anamorphous way).
Am I right, and if so what is the best method to perform this?
I thought about using the \getfiguredimensions macro to get the natural
dimensions, and then use something like
width=0.2\imgwidth,height=0.8\imgheight, but it is a pity that the
externalfigure interface does not allow this directly (something like
wscale and hscale options).
Regards,
BG
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: externalfigure and width/height scaling
2006-03-12 12:44 externalfigure and width/height scaling nico
@ 2006-03-12 19:02 ` Hans Hagen
2006-03-12 22:57 ` nico
0 siblings, 1 reply; 4+ messages in thread
From: Hans Hagen @ 2006-03-12 19:02 UTC (permalink / raw)
nico wrote:
> Hello,
>
> I am new to ConTeXt, so please be patient with my newbie questions.
> Looking at the \externalfigure capabilities, I haven't found any option
> allowing to scale only one dimension (or scale both dimensions in an
> anamorphous way).
>
> Am I right, and if so what is the best method to perform this?
>
> I thought about using the \getfiguredimensions macro to get the natural
> dimensions, and then use something like
> width=0.2\imgwidth,height=0.8\imgheight, but it is a pity that the
> externalfigure interface does not allow this directly (something like
> wscale and hscale options).
>
there is indeed no xscale and yscale (although
\scale[sx=1.5,sy=2,3]{...} is available)
% put this in cont-new.tex
\unprotect
\let\@@efxscale\empty
\let\@@efyscale\empty
\def\setnaturalfiguresize
{\doifsomething\@@efwidth
{\global\figwid\@@efwidth}%
\doifsomething\@@efheight
{\global\fighei\@@efheight}%
\doifsomething\@@efscale
{\figxsca\@@efscale
\figysca\@@efscale}%
\doifsomething\@@efxscale
{\figxsca\@@efxscale}%
\doifsomething\@@efyscale
{\figxsca\@@efyscale}}
\def\setscalefiguresize
{\doifsomething{\@@efscale\@@efxscale\@@efxscale}
{\doapplyfigurescale\figwid\@@epw\figxsca\@@efxscale
\doapplyfigurescale\fighei\@@eph\figysca\@@efyscale
\global\figwid\zeropoint
\global\fighei\zeropoint
\doifelsenothing\@@efmaxwidth
{\doifsomething\@@efmaxheight
{\ifdim\@@eph>\@@efmaxheight
\global\fighei\@@efmaxheight
\fi}}
{\ifdim\@@epw>\@@efmaxwidth
\global\figwid\@@efmaxwidth
\fi}}}
\def\doapplyfigurescale#1#2#3#4%
{\ifcase0#4\relax % @@ef.scale kan empty zijn
\ifcase0\@@efscale\relax % @@efscale kan empty zijn
#3=\plusthousand
\else
#3=\@@efscale
\fi
\else
#3=#4%
\fi
\relax % important !
\global#1\ifnum#3=\plusthousand#2\else\dimexpr#3\dimexpr#2/\plusthousand\relax\relax\fi
\relax}
\def\setdimensionfiguresize
{\ifdim\figwid>\zeropoint\relax
\ifdim\fighei>\zeropoint\relax
\dosetdimensionfiguresize
{\docalculatefigurescale\fighei\@@eph\figysca
\docalculatefigurescale\figwid\@@epw\figxsca}%
{\docalculatefigurescale\fighei\@@eph\figysca
\docalculatefigurescale\figwid\@@epw\figxsca}%
{\docalculatefigurescale\fighei\@@eph\figysca
\docalculatefigurescale\figwid\@@epw\figxsca}%
\else
\dosetdimensionfiguresize
{\docalculatefigurescales\figwid\@@epw\fighei\@@eph}%
{\docalculatefigurescales\figwid\@@epw\fighei\@@eph}%
{\docalculatefigurescales\figwid\@@epw\fighei\@@eph}%
\fi
\else
\ifdim\fighei>\zeropoint\relax
\dosetdimensionfiguresize
{\docalculatefigurescales\fighei\@@eph\figwid\@@epw}%
{\docalculatefigurescales\fighei\@@eph\figwid\@@epw}%
{\docalculatefigurescales\fighei\@@eph\figwid\@@epw}%
\else
\dosetdimensionfiguresize
{\doapplyfigurescale\figwid\@@epw\figxsca\@@efxscale
\doapplyfigurescale\fighei\@@eph\figysca\@@efyscale}%
{\docalculatefigurescales\figwid\@@epw\fighei\@@eph}%
{\docalculatefigurescales\fighei\@@eph\figwid\@@epw}%
\fi
\fi}
\protect
% end of patch
\starttext
\externalfigure[cow][scale=1000]
\externalfigure[cow][scale=200]
\externalfigure[cow][yscale=200]
\externalfigure[cow][xscale=800,yscale=200]
\stoptext
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: externalfigure and width/height scaling
2006-03-12 19:02 ` Hans Hagen
@ 2006-03-12 22:57 ` nico
2006-03-13 8:24 ` Hans Hagen
0 siblings, 1 reply; 4+ messages in thread
From: nico @ 2006-03-12 22:57 UTC (permalink / raw)
On Sun, 12 Mar 2006 20:02:44 +0100, Hans Hagen <pragma@wxs.nl> wrote:
> nico wrote:
>> Looking at the \externalfigure capabilities, I haven't found any option
>> allowing to scale only one dimension (or scale both dimensions in an
>> anamorphous way).
>>
>> Am I right, and if so what is the best method to perform this?
>>
>> I thought about using the \getfiguredimensions macro to get the natural
>> dimensions, and then use something like
>> width=0.2\imgwidth,height=0.8\imgheight, but it is a pity that the
>> externalfigure interface does not allow this directly (something like
>> wscale and hscale options).
>>
> there is indeed no xscale and yscale (although
> \scale[sx=1.5,sy=2,3]{...} is available)
>
> % put this in cont-new.tex
Thanks very much for your quick patch, it works as expected. Do you plan
to include it in a next release?
Regards,
BG
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: externalfigure and width/height scaling
2006-03-12 22:57 ` nico
@ 2006-03-13 8:24 ` Hans Hagen
0 siblings, 0 replies; 4+ messages in thread
From: Hans Hagen @ 2006-03-13 8:24 UTC (permalink / raw)
nico wrote:
> On Sun, 12 Mar 2006 20:02:44 +0100, Hans Hagen <pragma@wxs.nl> wrote:
>
>
>> nico wrote:
>>
>>> Looking at the \externalfigure capabilities, I haven't found any option
>>> allowing to scale only one dimension (or scale both dimensions in an
>>> anamorphous way).
>>>
>>> Am I right, and if so what is the best method to perform this?
>>>
>>> I thought about using the \getfiguredimensions macro to get the natural
>>> dimensions, and then use something like
>>> width=0.2\imgwidth,height=0.8\imgheight, but it is a pity that the
>>> externalfigure interface does not allow this directly (something like
>>> wscale and hscale options).
>>>
>>>
>> there is indeed no xscale and yscale (although
>> \scale[sx=1.5,sy=2,3]{...} is available)
>>
>> % put this in cont-new.tex
>>
>
> Thanks very much for your quick patch, it works as expected. Do you plan
> to include it in a next release?
>
yes
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
-----------------------------------------------------------------
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-03-13 8:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-12 12:44 externalfigure and width/height scaling nico
2006-03-12 19:02 ` Hans Hagen
2006-03-12 22:57 ` nico
2006-03-13 8:24 ` Hans Hagen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).