Difference between revisions of "Scaling Rotating Mirroring Clipping"

From Wiki
Jump to navigation Jump to search
m (Text replacement - "</cmd>" to "}}")
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
In [http://source.contextgarden.net/tex/context/base/core-mis.mkii core-mis.mkii] ([http://source.contextgarden.net/tex/context/base/core-mis.mkiv core-mis.mkiv] for MkIV) there are some handy commands for graphical text manipulation defined.
+
You can use the commands for text, but also for graphics or other “building blocks”.
  
This page’s title is misleading, since you can use the commands also for graphics and other “building blocks”.
+
=Scaling=
 
 
== \scale ==
 
  
 
You can insert symbols at a reduced size in the text flow.
 
You can insert symbols at a reduced size in the text flow.
Line 11: Line 9:
 
</context>
 
</context>
  
== \mirror ==
+
= Mirroring =
 
<context source=yes>
 
<context source=yes>
 
There is a \mirror{\sl mirorred} {\sl word} in this sentence.
 
There is a \mirror{\sl mirorred} {\sl word} in this sentence.
Line 24: Line 22:
 
</context>
 
</context>
  
== \rotate ==
+
= Rotating =
  
 
You can rotate something by an arbitrary angle by saying something like  
 
You can rotate something by an arbitrary angle by saying something like  
Line 38: Line 36:
 
</context>
 
</context>
  
=== location parameter ===
+
==Location parameter==
  
 
An example by Hans Hagen showing the influence of <code>location=</code> argument at different angles:
 
An example by Hans Hagen showing the influence of <code>location=</code> argument at different angles:
Line 59: Line 57:
 
You can rotate a long paragraph as well.
 
You can rotate a long paragraph as well.
  
=== in a box ===
+
==In a box==
  
 
Depending on the usage you will sometimes probably want to include the content of what you wish to rotate into a box. Compare the following two examples:
 
Depending on the usage you will sometimes probably want to include the content of what you wish to rotate into a box. Compare the following two examples:
Line 71: Line 69:
 
</context>
 
</context>
  
=== page dependent landscape figures ===
+
==Page dependent landscape figures==
  
Sometimes, in a double-sided portrait document, you may wish to rotate a landscape figure so that the top is towards the spine of the book – no matter whether it's on an odd or even page. In this case the <cmd>doifoddpageelse</cmd> command can help:
+
Sometimes, in a double-sided portrait document, you may wish to rotate a landscape figure so that the top is towards the spine of the book – no matter whether it's on an odd or even page. In this case the {{cmd|doifoddpageelse}} command can help:
  
 
<texcode>
 
<texcode>
Line 81: Line 79:
 
This example is by Wolfgang, from [http://www.ntg.nl/pipermail/ntg-context/2011/059834.html the thread starting here]. The thread contains other solutions to the problem.
 
This example is by Wolfgang, from [http://www.ntg.nl/pipermail/ntg-context/2011/059834.html the thread starting here]. The thread contains other solutions to the problem.
  
== \clip ==
+
=Clipping=
  
 
You can adjust the size of an element by cropping/clipping its borders:
 
You can adjust the size of an element by cropping/clipping its borders:
Line 100: Line 98:
 
</context>
 
</context>
  
see also <cmd>setupclipping</cmd> and <cmd>clip</cmd>
+
see also {{cmd|setupclipping}} and {{cmd|clip}}
 +
 
 +
=Further reading=
 +
 
 +
In [https://source.contextgarden.net/tex/context/base/mkii/core-mis.mkii core-mis.mkii] (for MkII), there are some handy commands for graphical text manipulation defined.
 +
{{todo|What is the equivalent for mkiv ?}}
  
{{Getting started navbox}}
+
[[Category:Basics]]
 +
[[Category:Graphics]]

Revision as of 13:23, 9 August 2020

You can use the commands for text, but also for graphics or other “building blocks”.

Scaling

You can insert symbols at a reduced size in the text flow.

\getscaledglyph{.5}{Serif}{a} a \getscaledglyph{2}{Serif}{a}

Mirroring

There is a \mirror{\sl mirorred} {\sl word} in this sentence.

\mirror makes a \hbox and mirrors the contents. If you want to have a longer paragraph mirrored, you have to make a \vbox manually.

\mirror{\vbox{Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: 
once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, `and 
what is the use of a book,' thought Alice `without pictures or conversation?'}}

Rotating

You can rotate something by an arbitrary angle by saying something like

\rotate[rotation=42]{the ultimate answer}

The rotation angle and the location (which determines around which point the content is rotated) are optional and can also be set by

\setuprotate[rotation=42,location=normal] % normal is the default
\rotate{the ultimate answer}

Location parameter

An example by Hans Hagen showing the influence of location= argument at different angles:

\dostepwiserecurse{0}{359}{45}
   {\startlinecorrection[blank]
    \hbox
      {\expanded{\setuprotate[rotation=\recurselevel]}%
       \traceboxplacementtrue
       \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=depth] {\ruledhbox{\bfb  (depth)}}}}%
       \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=fit]   {\ruledhbox{\bfb    (fit)}}}}%
       \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=broad] {\ruledhbox{\bfb  (broad)}}}}%
       \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=normal]{\ruledhbox{\bfb (normal)}}}}%
       \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=high]  {\ruledhbox{\bfb   (high)}}}}}
    \stoplinecorrection}


You can rotate a long paragraph as well.

In a box

Depending on the usage you will sometimes probably want to include the content of what you wish to rotate into a box. Compare the following two examples:

\setuplayout[width=3cm]
\setuprotate[rotation=180,location=broad]

a\rotate{e}i\par
a\rotate{\hbox{e}}i

Page dependent landscape figures

Sometimes, in a double-sided portrait document, you may wish to rotate a landscape figure so that the top is towards the spine of the book – no matter whether it's on an odd or even page. In this case the \doifoddpageelse command can help:

\rotate[rotation=\doifoddpageelse{90}{270}]{\externalfigure[cow]}

This example is by Wolfgang, from the thread starting here. The thread contains other solutions to the problem.

Clipping

You can adjust the size of an element by cropping/clipping its borders:

\clip[nx=3,ny=3,x=1,y=1]{\externalfigure[cow]}

\setupcolors[state=start]
\definedfont[SansBold at 20mm]
\baselineskip 0pt % switch off the space between the stripes
\lineskip 0pt
\def\MyLogo{\vbox{\hbox{\CONTEXT}\null}} % null is necessary for the whole bounding box
\clip[ny=3,y=1]{\color[yellow]\MyLogo}
\clip[ny=3,y=2]{\color[orange]\MyLogo}
\clip[ny=3,y=3]{\color[red]\MyLogo}

see also \setupclipping and \clip

Further reading

In core-mis.mkii (for MkII), there are some handy commands for graphical text manipulation defined.


TODO: What is the equivalent for mkiv ? (See: To-Do List)