diff options
Diffstat (limited to 'Master/texmf-dist/source/luatex')
-rw-r--r-- | Master/texmf-dist/source/luatex/chickenize/chickenize.dtx | 110 |
1 files changed, 68 insertions, 42 deletions
diff --git a/Master/texmf-dist/source/luatex/chickenize/chickenize.dtx b/Master/texmf-dist/source/luatex/chickenize/chickenize.dtx index a8eff7dc491..d6705e348ba 100644 --- a/Master/texmf-dist/source/luatex/chickenize/chickenize.dtx +++ b/Master/texmf-dist/source/luatex/chickenize/chickenize.dtx @@ -12,7 +12,7 @@ To produce the package files, run lualatex on chickinize.dtx, wich should result chickenize.sty (LaTeX user interface) chickenize.lua (Lua package code) [does the actual work] -You need an up-to-date TeX Live (2011 or 2012, if possible) to use this package. Maybe a full MiKTeX will do, too. +You need an up-to-date TeX Live (2011 or 2012, if possible) to use this package. Maybe a full MiKTeX will do, too. (Not tested!) For any comments or suggestions, contact me: arno dot trautmann at gmx dot de @@ -37,11 +37,6 @@ ance status ‘author-maintained’. EXPERIMENTAL CODE -Do not distribute this file without also distributing the -source files specified above. - -Do not distribute a modified version of this file under the same name. - This package is copyright © 20012 Arno L. Trautmann. It may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3c of this license or (at your option) any later version. This work has the LPPL mainten- @@ -63,7 +58,10 @@ ance status ‘author-maintained’. \generate{\file{chickenize.lua}{\from{chickenize.dtx}{lua}}} \nopreamble\nopostamble -\generate{\file{README}{\from{chickenize.dtx}{readme}}} +\catcode`\@12 + +%\generate{\file{README.}{\from{chickenize.dtx}{readme}}} +% readme will not be generated until I figured out how to write a file without extension \ifx\fmtname\nameofplainTeX @@ -91,22 +89,31 @@ ance status ‘author-maintained’. filecolor=blue, urlcolor=blue } -%\geometry{a4paper} -\cfoot{\directlua{if math.random() > .5 then tex.print("chicken") else tex.print("Chicken") end} \pagemark} +\cfoot{chicken \pagemark} \ohead{} \pagestyle{scrheadings} -\setmainfont{TeX Gyre Pagella} +\setmainfont{Linux Libertine O} +\setsansfont{Linux Biolinum O} + +\usepackage{chickenize} +\chickenizesetup{ + rainbow_step=0.3 +} -\author{Arno Trautmann\\ \href{mailto:arno.trautmann@gmx.de}{arno.trautmann@gmx.de}} \begin{document} {\hfill \parbox{6.3cm}{{\fontspec{TeX Gyre Chorus}{\large »\,}The Monty Pythons, were they \TeX~users,\\\hspace*{.2em} could have written the chickenize macro.{\large \textit «}}\\[1ex] \hspace*{4cm}\small Paul Isambert}\kern-2.5cm } -\centerline{\fontsize{35}{0}\selectfont \fontspec[Letters=Random]{Punk Nova}chickenize} +\begin{center} +\rainbowcolor +\fontsize{55}{0}\selectfont \fontspec[Letters=Random]{Punk Nova} +chickenize +\end{center} + +\unrainbowcolor -\kern.5cm \centerline{v0.1} \centerline{\hspace*{2cm} Arno Trautmann} \centerline{\href{mailto:arno.trautmann@gmx.de}{arno.trautmann@gmx.de}} @@ -156,8 +163,9 @@ of this license or (at your option) any later version. This work has the LPPL ma \hyperref[sec:chickenize]{chickenize} & replaces every word with “chicken”\\ \hyperref[sec:guttenbergenize]{guttenbergenize} & deletes every quote and footnotes\\ \hyperref[sec:hammertime]{hammertime} & U can't touch this!\\ -\hyperref[sec:kernmanipulation]{kernmanipulation} & manipulates the kerning\\ +\hyperref[sec:kernmanipulation]{kernmanipulation} & manipulates the kerning (tbi)\\ \hyperref[sec:matrixize]{matrixize} & replaces every glyph by its ASCII value in binary code\\ +\hyperref[sec:randomerror]{randomerror} & just throws random (La)\TeX\ errors at random times\\ \hyperref[sec:randomfonts]{randomfonts} & changes the font randomly between every letter\\ \hyperref[sec:randomchars]{randomchars} & randomizes the (letters of the) whole input\\ \bottomrule @@ -188,16 +196,12 @@ The effect of the commands can be influenced, not with arguments, but only via t \command{dubstepenize} synomym for |\dubstepize| as I am not sure what is the better name. Both macros are just a special case of |chickenize| with a very special “zoo” … there is no |\undubstepize| – once you go dubstep, you cannot go back … \command{hammertime} STOP! —— Hammertime! \command{uppercasecolor} Makes every uppercase character in the input colored. At the moment, the color is randomized over the full rgb scale, but that will be adjustable once options are well implemented. +\command{randomerror} Just throws a random \TeX\ or \LaTeX\ error at a random time during the compilation. I have quite no idea what this could be used for. \command{randomuclc} Changes every character of the input into its uppercase or lowercase variant. Well, guess what the “random” means … \command{randomfonts} Changes the font randomly for every character. If no parameters are given, all fonts that have been loaded are used, especially including math fonts. \command{randomcolor} Does what its name says. \command{rainbowcolor} Instead of random colors, this command causes the text color to change gradually according to the colors of a rainbow. Do not mix this with |randomcolor|, as that doesn't make any sense. -\command{pancakenize} This is a dummy so far, as I have no idea what it should do. If you have suggestions, please tell me. - % \footnote{% Maybe just pretend that the absence of functionality is intentional... [phg] - % From an absurdist perspective, the |pancakenize| command can be perceived - % as a reminder to the user to email the package maintainer their own - % suggestions for further functionality. - % } +\command{pancakenize} This is a dummy command that does nothing. However, every time you use it, you owe a pancake to the package author. You can either send it via mail or bring it to some (local) \TeX\ user's group meeting. \command{tabularasa} Takes every glyph out of the document and replaces it by empty space of the same width. That could be useful if you want to hide some part of a text or similar. The |\text|-version is most likely more useful. \command{leetspeak} Translates the input into 1337 speak. If you don't understand that, lern it, n00b. \command{nyanize} A synonym for |rainbowcolor|. @@ -240,17 +244,11 @@ The following list tries to kind of keep track of the options and variables. The \item[\opt{chickenstring} = \arg{table}] The string that is printed when using |\chickenize|. In fact, |chickenstring| is a table which allows for some more random action. To specify the default string, say |chickenstring[1] = 'chicken'|. For more than one animal, just step the index: |chickenstring[2] = 'rabbit'|. All existing table entries will be used randomly. Remember that we are dealing with Lua strings here, so use |' '| to mark them. (|" "| can cause problems with |babel|.) \item[\opt{chickenizefraction} = \arg{float} \default{1}] Gives the fraction of words that get replaced by the |chickenstring|. The default means that every word is substituted. However, with a value of, say, |0.0001|, only one word in ten thousand will be |chickenstring|. |chickenizefraction| must be specified \emph{after} |\begin{document}|. No idea, why … \item[\opt{chickencount} = \arg{true}] Activates the counting of substituted words and prints the number at the end of the terminal output. -<<<<<<< HEAD \item[\opt{colorstretchnumbers} = \arg{true} \default{0}] If true, the amount of stretching or shrinking of each line is printed into the margin as a green, red or black number. \item[\opt{chickenkernamount} = \arg{int}] The amount the kerning is set to when using |\kernmanipulate|. \item[\opt{chickenkerninvert} = \arg{bool}] If set to true, the kerning is inverted (to be used with |\kernmanipulate|. \item[\opt{leettable} = \arg{table}] From this table, the substitution for 1337 is taken. If you want to add or change an entry, you have to provide the unicode numbers of the characters, e.\,g. |leettable[101] = 50| replaces every |e| (|101|) with the number |3| (|50|). \item[\opt{uclcratio} = \arg{float} \default{0.5}] Gives the fraction of uppercases to lowercases in the |\randomuclc| mode. A higher number (up to 1) gives more uppercase letters. Guess what a lower number does. -======= -\item[\opt{colorstretchnumbers} = \arg{true}] If true, the amount of stretching or shrinking of each line is printed into the margin as a green, red or black number. -\item[\opt{leettable} = \arg{table}] From this table, the substitution for 1337 is taken. If you want to add or change an entry, you have to provide the unicode code points of the characters, e.\,g. |leettable[101] = 50| replaces every |e| (|101|) with the number |3| (|50|). -\item[\opt{uclcratio} = \arg{float} \default{0.5}] Gives the fraction of uppercases to lowercases in the |\randomuclc| mode. A higher number (up to 1) will result in more uppercase letters. Guess what a lower number does. ->>>>>>> d9c88b6094abe878dd97cfd77f26e514b1d66c63 \item[\opt{randomcolor\_grey} = \arg{bool} \default{false}] For a printer-friendly version, this offers a grey scale instead of an rgb value for |\randomcolor|. \item[\opt{rainbow\_step} = \arg{float} \default{0.005}] This indicates the relative change of color using the rainbow functionality. A value of |1| changes the color in one step from red to yellow, while a value of |0.005| takes 200 letters for the transition to be completed. Useful values are below |0.05|, but it depends on the amount of text. The longer the text and the lower the |step|, the nicer your rainbow will be. \item[\opt{Rgb\_lower}, \opt{rGb\_upper} = \arg{int}] To specify the color space that is used for |\randomcolor|, you can specify six values, the upper and lower value for each color. The uppercase letter in the variable denotes the color, so |rGb_upper| gives the upper value for green etc. Possible values are between |1| and |254|. If you enter anything outside this range, your PDF will become invalid and break. For grey scale, use |grey_lower| and |grey_upper|, with values between |0| (black) and |1000| (white), included. Default is |0| to |900| to prevent white letters. @@ -353,9 +351,11 @@ The namespace of the chickenize package is \emph{not} consistent. Please don't t % This file is more-or-less a dummy file to offer a nice interface for the functions. Basically, every macro registers a function of the same name in the corresponding callback. The |un|-macros later remove these functions. Where it makes sense, there are |text|-variants that activate the function only in a certain area of the text, by means of Lua\TeX's attributes. % % For (un)registering, we use the |luatexbase| package. Then, the |.lua| file is loaded which does the actual work. Finally, the \TeX\ macros are defined as simple |\directlua| calls. +% +% The Lua file is not found by using a simple |dofile("chickenize.lua")| call, but we have to use kpse's |find_file|. % \begin{macrocode} \input{luatexbase.sty} -\directlua{dofile("chickenize.lua")} +\directlua{dofile(kpse.find_file("chickenize.lua"))} \def\chickenize{ \directlua{luatexbase.add_to_callback("pre_linebreak_filter",chickenize,"chickenize") @@ -469,15 +469,13 @@ The namespace of the chickenize package is \emph{not} consistent. Please don't t \def\unmatrixize{ \directlua{luatexbase.remove_from_callback("pre_linebreak_filter",matrixize)}} -\def\milkcow{ %% to be implemented +\def\milkcow{ %% FIXME %% to be implemented \directlua{}} \def\unmilkcow{ \directlua{}} -\def\pancakenize{ %% to be implemented - \directlua{}} -\def\unpancakenize{ - \directlua{}} +\def\pancakenize{ + \directlua{luatexbase.add_to_callback("stop_run",pancaketext,"pancaketext")}} \def\rainbowcolor{ \directlua{luatexbase.add_to_callback("post_linebreak_filter",randomcolor,"rainbowcolor") @@ -493,6 +491,11 @@ The namespace of the chickenize package is \emph{not} consistent. Please don't t \def\unrandomcolor{ \directlua{luatexbase.remove_from_callback("post_linebreak_filter","randomcolor")}} +\def\randomerror{ %% FIXME + \directlua{luatexbase.add_to_callback("post_linebreak_filter",randomcolor,"randomcolor")}} +\def\unrandomerror{ %% FIXME + \directlua{luatexbase.remove_from_callback("post_linebreak_filter","randomcolor")}} + \def\randomfonts{ \directlua{luatexbase.add_to_callback("post_linebreak_filter",randomfonts,"randomfonts")}} \def\unrandomfonts{ @@ -535,6 +538,7 @@ The namespace of the chickenize package is \emph{not} consistent. Please don't t \newluatexattribute\randfontsattr \newluatexattribute\randuclcattr \newluatexattribute\tabularasaattr +\newluatexattribute\uppercasecolorattr \long\def\textleetspeak#1% {\setluatexattribute\leetattr{42}#1\unsetluatexattribute\leetattr} @@ -548,6 +552,8 @@ The namespace of the chickenize package is \emph{not} consistent. Please don't t {\setluatexattribute\randuclcattr{42}#1\unsetluatexattribute\randuclcattr} \long\def\texttabularasa#1% {\setluatexattribute\tabularasaattr{42}#1\unsetluatexattribute\tabularasaattr} +\long\def\textuppercasecolor#1% + {\setluatexattribute\uppercasecolorattr{42}#1\unsetluatexattribute\uppercasecolorattr} % \end{macrocode} % Finally, a macro to control the setup. So far, it's only a wrapper that allows \TeX-style comments to make the user feel more at home. % \begin{macrocode} @@ -744,7 +750,7 @@ chickenize = function(head) return head end -local separator = string.rep("=", 28) +local separator = string.rep("=", 28) local texiowrite_nl = texio.write_nl nicetext = function() texiowrite_nl("Output written on "..tex.jobname..".pdf ("..status.total_pages.." chicken,".." eggs).") @@ -969,8 +975,20 @@ matrixize = function(head) end % \end{macrocode} % \subsection{pancakenize}\label{sec:pancakenize} -% Not yet completely decided what this should do, but it might come down to inserting a cooking recipe for a … well, guess what. Possible implementations are: Substitute a whole sentence, from full-stop to full-stop. OR: Substitute word-by-word at a random place. OR (expert-freak-1337-level): Substitute the n-th word of each page to a word of the recipe. That would be totally awesome!! % \begin{macrocode} +local separator = string.rep("=", 28) +local texiowrite_nl = texio.write_nl +pancaketext = function() + texiowrite_nl("Output written on "..tex.jobname..".pdf ("..status.total_pages.." chicken,".." eggs).") + texiowrite_nl(" ") + texiowrite_nl(separator) + texiowrite_nl("Soo ... you decided to use \\pancakenize.") + texiowrite_nl("That means you owe me a pancake!") + texiowrite_nl(" ") + texiowrite_nl("(This goes by document, not compilation.)") + texiowrite_nl(separator.."\n\n") + texiowrite_nl("Looking forward for my pancake! :)") +end % \end{macrocode} % \subsection{randomfonts}\label{sec:randomfonts} % Traverses the output and substitutes fonts randomly. A check is done so that the font number is existing. @@ -1100,6 +1118,10 @@ randomcolor = function(head) return head end % \end{macrocode} +% \subsection{randomerror}\label{sec:randomerror} +% \begin{macrocode} +% +% \end{macrocode} % \subsection{rickroll}\label{sec:rickroll} % Another tribute to pop culture. Either: substitute word-by-word as in pancake. OR: substitute each link to a youtube-rickroll … % \begin{macrocode} @@ -1112,7 +1134,7 @@ tabularasa_onlytext = false tabularasa = function(head) local s = nodenew(nodeid"kern") for line in nodetraverseid(nodeid"hlist",head) do - for n in nodetraverseid(nodeid"glyph",line.list) do + for n in nodetraverseid(nodeid"glyph",line.head) do if not(tabularasa_onlytext) or node.has_attribute(n,luatexbase.attributes.tabularasaattr) then s.kern = n.width nodeinsertafter(line.list,n,nodecopy(s)) @@ -1126,14 +1148,18 @@ end % \subsection{uppercasecolor}\label{sec:uppercasecolor} % Loop through all the nodes and checking whether it is uppercase. If so (and also for small caps), color it. % \begin{macrocode} +uppercasecolor_onlytext = false + uppercasecolor = function (head) for line in nodetraverseid(Hhead,head) do for upper in nodetraverseid(GLYPH,line.head) do - if (((upper.char > 64) and (upper.char < 91)) or - ((upper.char > 57424) and (upper.char < 57451))) then -- for small caps! nice ☺ - color_push.data = randomcolorstring() -- color or grey string - line.head = nodeinsertbefore(line.head,upper,nodecopy(color_push)) - nodeinsertafter(line.head,upper,nodecopy(color_pop)) + if not(uppercasecolor_onlytext) or node.has_attribute(upper,luatexbase.attributes.uppercasecolorattr) then + if (((upper.char > 64) and (upper.char < 91)) or + ((upper.char > 57424) and (upper.char < 57451))) then -- for small caps! nice ☺ + color_push.data = randomcolorstring() -- color or grey string + line.head = nodeinsertbefore(line.head,upper,nodecopy(color_push)) + nodeinsertafter(line.head,upper,nodecopy(color_pop)) + end end end end @@ -1260,13 +1286,13 @@ colorstretch = function (head) return head end % \end{macrocode} -% \subsection*{dubstepize} +% \subsection*{dubstepize} %% FIXME – Isn't that already implemented above? % BROOOAR WOBWOBWOB BROOOOAR WOBWOBWOB BROOOOAR WOB WOB WOB … % \begin{macrocode} % \end{macrocode} % \subsection*{scorpionize} -% These functions intentionally not documented. +% This function's intentionally not documented. In memoriam scorpionem. %% FIXME % \begin{macrocode} function scorpionize_color(head) color_push.data = ".35 .55 .75 rg" |