Skip to content

Instantly share code, notes, and snippets.

@wrtlprnft
Last active May 7, 2016 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wrtlprnft/4cc8fe07f114449f0d8748fe60af39e9 to your computer and use it in GitHub Desktop.
Save wrtlprnft/4cc8fe07f114449f0d8748fe60af39e9 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
\documentclass{article}
%\usepackage{luatextra}
\usepackage[text={1.2in,3in}]{geometry}
\usepackage[none]{hyphenat}
\directlua{
PDF_LITERAL = node.subtype("pdf_literal")
WS = node.id("whatsit")
GLUE = node.id("glue")
add_image = function(line, n, width, height, name)
local sni = img.node{filename=name}
sni.height = height
sni.width = width
return node.insert_before(line,n,sni)
end
add_snake = function(line, n, width, height)
local segments_middle = 0;
local segments_wave = 0;
local unstretched_width = height * (1.0 + 1.5)
while unstretched_width + height * 1.5 < width do
unstretched_width = unstretched_width + height * 1.5
segments_wave = segments_wave + 1
end
while unstretched_width + height * 0.5 < width do
unstretched_width = unstretched_width + height * 0.5
segments_middle = segments_middle + 1
end
local stretch = width / unstretched_width
line = add_image(line, n, height * 1.0 * stretch, height, "snake_tail.pdf")
for i = 1, segments_wave do
line = add_image(line, n, height * 1.5 * stretch, height, "snake_wave.pdf")
end
for i = 1, segments_middle do
line = add_image(line, n, height * 0.5 * stretch, height, "snake_middle.pdf")
end
line = add_image(line, n, height * 1.5 * stretch, height, "snake_head.pdf")
return line
end
local w = 1250000 % remove when effective_glue works!
snakefill = function(head)
for line in node.traverse_id(0,head) do
for n in node.traverse_id(GLUE,line.head) do
if n.subtype == 9 then
%local w = node.effective_glue(n,line) / 65536
w = w * 1.1 % remove when effective_glue works!
local h = 500000
line = add_snake(line, n, w, 500000)
end
end
end
return head
end
}
\def\snakefill{%
\directlua{
luatexbase.add_to_callback("post_linebreak_filter",snakefill,"snake fill")
}%
}
\def\offsnakefill{%
\directlua{
luatexbase.remove_from_callback("post_linebreak_filter","snake fill")
}%
}
\begin{document}
\raggedright
\snakefill
\noindent Their famous paper on the relationship between deindustrialization and the growth of ecological\ldots\par
\noindent Their famous paper on the relationship between deindustrialization and the growth of ecological\ldots\par
\noindent Their famous paper on the relationship between deindustrialization and the growth of ecological\ldots\par
\end{document}
@nanmu42
Copy link

nanmu42 commented May 7, 2016

Lovely work, bro!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment