PageRenderTime 58ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/groff/contrib/mom/momdoc/color.html

https://github.com/okuoku/freebsd-head
HTML | 338 lines | 312 code | 23 blank | 3 comment | 0 complexity | d25ec6870a79f814bd3d1ca8cf078e14 MD5 | raw file
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
  5. <title>Mom -- Colour</title>
  6. </head>
  7. <body bgcolor="#dfdfdf">
  8. <!====================================================================>
  9. <a href="docprocessing.html#TOP">Next</a>&nbsp;&nbsp;
  10. <a href="inlines.html#TOP">Prev</a>&nbsp;&nbsp;
  11. <a href="toc.html">Back to Table of Contents</a>
  12. <a name="TOP"></a>
  13. <h1 align="center">
  14. <a name="COLOR_INTRO"><u>Coloured text</u></a>
  15. </h1>
  16. <p>
  17. <a href="#INTRO_COLOR">Introduction to coloured text</a>
  18. <br>
  19. <a href="#MACROS_COLOR">Index of colour macros</a>
  20. <p>
  21. <a name="INTRO_COLOR">
  22. <h2><u>Introduction to coloured text</u></h2>
  23. </a>
  24. <strong>Mom</strong>'s support for coloured text is straightforward.
  25. You begin by telling <strong>mom</strong> about the colours you want
  26. with
  27. <a href="#NEWCOLOR">NEWCOLOR</a>
  28. or
  29. <a href="#XCOLOR">XCOLOR</a>.
  30. Afterward, any time you want text to be coloured, you either colour
  31. it with an
  32. <a href="definitions.html#TERMS_INLINES">inline escape</a>
  33. that contains the colour name (e.g. <kbd>\*[red]</kbd> or
  34. <kbd>\*[blue]</kbd>) or invoke the macro,
  35. <a href="#COLOR">COLOR</a>,
  36. with the name of the colour you want.
  37. <a name="COLOR_EXAMPLE"></a>
  38. <p>
  39. For example, say you want to have the name &quot;Jack&quot; in the
  40. sentence &quot;All work and no play makes Jack a dull boy&quot;
  41. appear in yellow. You'd begin by telling <strong>mom</strong> about
  42. the colour, yellow. There are two ways of doing this; see
  43. <a href="#NEWCOLOR">NEWCOLOR</a>
  44. and
  45. <a href="#XCOLOR">XCOLOR</a>
  46. for a full explanation of the difference between the two. If you
  47. use <strong>XCOLOR</strong>, you'd enter this:
  48. <p>
  49. <pre>
  50. .XCOLOR yellow
  51. </pre>
  52. If you use <strong>NEWCOLOR</strong>, you might enter
  53. <p>
  54. <pre>
  55. .NEWCOLOR yellow RGB #FFFF00
  56. </pre>
  57. <a name="COLOR_EXAMPLE2"></a>
  58. After &quot;defining&quot; (or &quot;initializing&quot;) the colour
  59. &quot;yellow&quot;, you'd colourize the name, Jack, either with an
  60. inline escape
  61. <p>
  62. <pre>
  63. All work and no play makes \*[yellow]Jack\*[black] a dull boy.
  64. </pre>
  65. or with the <strong>COLOR</strong> macro
  66. <p>
  67. <pre>
  68. All work and no play makes
  69. .COLOR yellow
  70. Jack
  71. .COLOR black
  72. a dull boy.
  73. </pre>
  74. Notice, in both examples, that a) you have to set the colour back to
  75. black after &quot;Jack&quot;, and b) you don't have to define or
  76. intialize the colour, black. <strong>Mom</strong> predefines
  77. &quot;black&quot;, &quot;BLACK&quot;, &quot;white&quot; and
  78. &quot;WHITE&quot; for you.
  79. <p>
  80. For information on using colour during
  81. <a href="docprocessing.html#INTRO_MACROS_DOCPROCESSING">document processing</a>,
  82. see
  83. <a href="docprocessing.html#COLOR">Colour support in document processing</a>.
  84. <p>
  85. <strong>Please note: Mom</strong>'s colour support is for text only.
  86. She doesn't support &quot;fill&quot; (or &quot;background&quot;)
  87. colour for drawn objects. Please also note that if you're
  88. accustomed to using groff's <kbd>.defcolor</kbd> to define colours,
  89. and groff's inline <kbd>\m[&lt;colorname&gt;]</kbd> to call them, you may
  90. continue to do so without confusing <strong>mom</strong>.
  91. <p>
  92. <a name="MACROS_COLOR"><h3><u>Index of colour macros</u></h3></a>
  93. <ul>
  94. <li><a href="#NEWCOLOR">NEWCOLOR</a>
  95. <li><a href="#XCOLOR">XCOLOR</a>
  96. <li><a href="#COLOR">COLOR</a>
  97. <li><a href="#COLOR_INLINE">\*[&lt;colorname&gt;]</a> inline escape
  98. </ul>
  99. <p>
  100. <!---NEWCOLOR--->
  101. <hr width="66%" align="left">
  102. <a name="NEWCOLOR"><h3><u>Creating (initializing) a colour with NEWCOLOR</u></h3></a>
  103. <br>
  104. <nobr>Macro: <strong>NEWCOLOR</strong> &lt;colour name&gt; [&lt;colour scheme&gt;] &lt;colour components&gt;</nobr>
  105. <p>
  106. <strong>NEWCOLOR</strong> lets you create a colour, rather like an
  107. artist mixing paint on a palette. The colour isn't used
  108. immediately; <strong>NEWCOLOR</strong> merely tells
  109. <strong>mom</strong> how to mix the colour when you need it. If
  110. you haven't invoked <strong>NEWCOLOR</strong> (or
  111. <a href="#XCOLOR">XCOLOR</a>),
  112. <strong>mom</strong> doesn't have a clue what you mean when you
  113. reference a colour (with
  114. <a href="#COLOR">COLOR</a>
  115. or
  116. <a href="#COLOR_INLINE">\*[&lt;color name&gt;]</a>).
  117. <p>
  118. The first argument to <strong>NEWCOLOR</strong> is a name for your
  119. colour. It can be anything you like--provided it's just one word
  120. long--and can be caps, lower case, or any combination of the two.
  121. <p>
  122. The second argument, which is entirely optional, is the &quot;colour
  123. scheme&quot; you want <strong>mom</strong> to use when mixing the
  124. colour. Valid arguments are <strong>RGB</strong> (3 components,
  125. red green blue), <strong>CYM</strong> (3 components cyan yellow
  126. magenta), <strong>CMYK</strong> (4 components cyan magenta yellow
  127. black) or <strong>GRAY</strong> (1 component). If you omit the
  128. second argument, <strong>mom</strong> assumes you want RGB.
  129. <p>
  130. The final argument is the components of your colour. This can be
  131. hexadecimal string starting with a pound sign (#) (for colour values
  132. in the 0-255 range) or two pound signs (##) (for colour values
  133. in the 0-65535 range), or it can be a series of decimal digits,
  134. separated by spaces, one digit per component, with the argument
  135. enclosed in double quotes. (If this is all gibberish to you, see
  136. <a href="#COLOR_TIP">Tips for newbies</a>.)
  137. <p>
  138. Thus, to tell <strong>mom</strong> about a colour named
  139. &quot;YELLOW&quot;, you could enter one of the following:
  140. <p>
  141. <pre>
  142. .NEWCOLOR YELLOW #FFFF00 \"or ##FFFFFFFF0000 or "1 1 0"
  143. .NEWCOLOR YELLOW RGB #FFFF00 \"or ##FFFFFFFF0000 or "1 1 0"
  144. .NEWCOLOR YELLOW CYM #00FF00 \"or ##0000FFFF0000 or "0 1 0"
  145. .NEWCOLOR YELLOW CYMK #00FF0000 \"or ##0000FFFF00000000 or "1 1 0"
  146. </pre>
  147. After you've told <strong>mom</strong> about a colour, you can then get
  148. her to set text in that colour either with the inline escape
  149. <a href="#COLOR_INLINE">\*[&lt;colorname&gt;]</a>
  150. or the macro
  151. <a href="#COLOR">COLOR</a>.
  152. (See the
  153. <a href="#COLOR_EXAMPLE">example</a>,
  154. above.)
  155. <br>
  156. <h3><u>Tips for newbies</u></h3>
  157. Colour manipulation can be tremendously confusing if you don't have
  158. a background in graphic arts or computing. My advice, if color
  159. intimidates you, is to stick to using <strong>mom</strong>'s
  160. default RGB colour scheme, and to fire up a color chooser that
  161. gives you the RGB values you want for the colour you select. Plug
  162. those values into the components argument to
  163. <strong>NEWCOLOR</strong>, and you'll get the colour you want.
  164. Both the KDE and gnome desktops have colour selectors that provide
  165. you with the shorter RGB hexadecimal string. If you're not running
  166. KDE or gnome, the X utility, xcolorsel, provides you with a similar
  167. functionality, although it only provides RGB values for 256
  168. pre-defined colours. If you use xcolorsel, be sure to click the
  169. button &quot;Display format&quot; and select &quot;8 bit truncated
  170. rgb&quot;.
  171. <p>
  172. Alternatively, you can use <strong>mom</strong>'s simpler
  173. <a href="#XCOLOR">XCOLOR</a>
  174. macro to initialize one of the 256 pre-defined X colours by
  175. supplying the name of the color as an argument.
  176. <br>
  177. <!---XCOLOR--->
  178. <hr width="33%" align="left">
  179. <a name="XCOLOR"><h3><u>Initializing a colour with XCOLOR</u></h3>
  180. <br>
  181. <nobr>Macro: <strong>XCOLOR</strong> &lt;X color name&gt; [&lt;alias&gt;]</nobr>
  182. <br>
  183. <em>*&lt;X color name&gt; must be all one word, all lower case.
  184. <br>
  185. (See
  186. <a href="#XCOLOR_NAMES">Finding X color names</a>
  187. for how to get a list of valid colour names.)
  188. </em>
  189. <p>
  190. <strong>XCOLOR</strong> is similar to <strong>NEWCOLOR</strong> in
  191. that it tells <strong>mom</strong> to initialize a colour, but it's
  192. easier to use. All you have to do is pass it, as an argument, the
  193. legal name of one of the 256 pre-defined X colours. The name must
  194. be all one word, and, breaking with <strong>mom</strong> policy, it
  195. must be entered in lower case.
  196. <p>
  197. For example, if you want to intialize the X colour, coral, all you
  198. have to do is enter
  199. <br>
  200. <pre>
  201. .XCOLOR coral
  202. </pre>
  203. Afterwards
  204. <p>
  205. <pre>
  206. .COLOR coral
  207. </pre>
  208. will colourize subsequent text coral until you instruct
  209. <strong>mom</strong> to return to black, or some other pre-defined
  210. initialized colour. (The
  211. <a href="definitions.html#TERMS_INLINES">inline escape</a>
  212. <kbd>\*[coral]</kbd> will equally colourize text coral after you've
  213. initialized the colour with <strong>XCOLOR</strong>.)
  214. <p>
  215. The downside of <strong>XCOLOR</strong> is that you can't create
  216. custom colours. This restriction, however, is mitigated by the
  217. fact that for many users, 256 colours is more than enough to play
  218. around with.
  219. <p>
  220. While some X colours have fanciful names (peachpuff, papayawhip,
  221. thistle, snow), many are self-explanatory and self-descriptive in
  222. ordinary colour terms. &quot;blue&quot; is pure (rgb) blue,
  223. &quot;green&quot; is pure (rgb) green, and so on. Furthermore, for
  224. many X colors, there exist four variants, each representing
  225. increasingly darker shades of the same colour. For example,
  226. &quot;blue&quot; (and &quot;blue1&quot;) are the brightest forms of
  227. (rgb) blue; &quot;blue2&quot;, &quot;blue3&quot; and &quot;blue4&quot;
  228. are increasingly darker shades of the same blue. For that reason,
  229. you may find <strong>XCOLOR</strong> is a better choice than
  230. <strong>NEWCOLOR</strong> when it comes to initializing common
  231. colors.
  232. <p>
  233. The whimsical nature of X colour names sometimes makes for names
  234. that are long to type in, e.g. &quot;mediumspringgreen&quot;.
  235. The optional second argument to <strong>XCOLOR</strong> allows you
  236. to come up with more convenient name by which to reference the
  237. colour. For example, you could enter
  238. <p>
  239. <pre>
  240. .XCOLOR mediumspringgreen mygreen
  241. or
  242. .XCOLOR mediumspringgreen MYGREEN
  243. </pre>
  244. so that whenever you want text mediumspringgreen-ed, you can use
  245. either <kbd>.COLOR mygreen</kbd> (or <kbd>.COLOR MYGREEN</kbd>) or
  246. the inline escape <kbd>\*[mygreen]</kbd> (or
  247. <kbd>\*[MYGREEN]</kbd>.)
  248. <p>
  249. <a name="XCOLOR_NAMES"><h3><u>Finding X color names</u></h3></a>
  250. <br>
  251. There are two ways of finding the names of the pre-defined X
  252. colours. One is to consult the file, rgb.txt, included with
  253. all X11 installations. The location of the file on a Debian
  254. GNU/Linux distribution is typically /etc/X11/rgb.txt. Other
  255. distributions and other X installations may have the file in
  256. another location. The file lists the colour names, but doesn't
  257. show you what the colours actually look like.
  258. <p>
  259. A better way to get the colour names, as well as to see what the
  260. colours look like, is to fire up a colour chooser (like xcolorsel)
  261. that both lists the colour names and shows a swatch of the colour
  262. as well.
  263. <p>
  264. Whichever method you use to find X color names, remember that the
  265. names, passed as arguments to <strong>XCOLOR</strong>, <em>must</em>
  266. be all one word, all in lower case.
  267. <br>
  268. <!---COLOR--->
  269. <hr width="33%" align="left">
  270. <a name="COLOR"><h3><u>Invoking a color</u></h3>
  271. <br>
  272. <nobr>Macro: <strong>COLOR</strong> &lt;colorname&gt;</nobr>
  273. <br>
  274. <a name="COLOR_INLINE">Inline: <strong>\*[&lt;colorname&gt;]</strong></a>
  275. <p>
  276. <a name="COLOR_INLINE"></a>
  277. Once you've told <strong>mom</strong> about a colour (via
  278. <strong>NEWCOLOR</strong> or <strong>XCOLOR</strong>), you use either
  279. the macro, <strong>COLOR</strong>, or the
  280. <a href="definitions.html#TERMS_INLINES">inline escape</a>,
  281. <kbd>\*[&lt;colorname&gt;]</kbd>, to cause <strong>mom</strong> to
  282. set subsequent text in that colour. See the
  283. <a href="#COLOR_EXAMPLE2">example</a>,
  284. above, which shows both in action.
  285. <p>
  286. <strong>NOTE:</strong> You can use the
  287. <kbd>\*[&lt;colorname&gt;]</kbd> inline escape in any
  288. <a href="docprocessing.html#TOP">document processing</a>
  289. macro that takes a
  290. <a href="definitions.html#TERMS_STRINGARGUMENT">string argument</a>.
  291. However, you must remember to reset the colour at the end of the
  292. argument (typically with <kbd>\*[black]</kbd>) unless you want all
  293. subsequent invocations of that particular macro to be colourized.
  294. <p>
  295. Furthermore, if you use <kbd>\*[&lt;colorname&gt;]</kbd> in the
  296. string argument passed to
  297. <a href="docelement.html#HEAD">.HEAD</a>,
  298. <a href="docelement.html#SUBHEAD">.SUBHEAD</a>
  299. or
  300. <a href="docelement.html#PARAHEAD">.PARAHEAD</a>,
  301. and you've requested that any of these types of heads be numbered,
  302. the numbers themselves will not be coloured, only the text you
  303. passed the macro. If you wish the numbers to be colourized as
  304. well, you must explicitly tell <strong>mom</strong> that you wish
  305. all of the head(s), subhead(s) or parahead(s), including the
  306. numbers, colourized by invoking the appropriate
  307. <a href="docelement.html#DOCELEMENT_CONTROL">control macro</a>.
  308. <br>
  309. <hr>
  310. <a href="docprocessing.html#TOP">Next</a>&nbsp;&nbsp;
  311. <a href="inlines.html#TOP">Prev</a>&nbsp;&nbsp;
  312. <a href="#TOP">Top</a>&nbsp;&nbsp;
  313. <a href="toc.html">Back to Table of Contents</a>
  314. </body>
  315. </html>