Governance by those who do the work.

Thursday, February 7, 2019

Mathematical Marbling How-To

http://people.csail.mit.edu/jaffer/Marbling/How-To

Paint marbling is a process of dropping colored paints onto a liquid bath and raking (combing) them to create intricate designs.  Based on my mathematical theory of marbling, Jürgen Gilg, Manuel Luque, and I have created the pst-marble software to enable anyone with an internet browser to create their own digital marbled designs
Pst-marble (and documentation) is a CTAN package for the LaTeX document system.  If you have LaTeX and CTAN installed on your computing device, then you can create marblings locally.  https://www.latex-project.org/get/ has the downloads and instructions for installing LaTeX and CTAN on GNU/Linux, MacOS, and Windows.
For those with a web-browser, it is easy to create marblings online. Papeeria.com provides an online LaTeX workbench with free and paid accounts.  The marbling example files will render in less than one minute; so a free account is sufficient for exploring.  If you create more complicated designs, you can upgrade to a paid Papeeria account or install LaTeX and CTAN on a (larger) computing device.
  • Download pst-marble-v1.4.zip (15 kB) onto your computing device.
  • Go to http://Papeeria.com and create a free account for yourself and a "project" with whatever name you like.
  • From the top left pull-down select Upload Project, then Choose files and select pst-marble-v1.4.zip which you just downloaded.  Then click Open.
  • In the Project tab you should then see a list of filenames. The files with capitalized first letter and ending with .tex are the marbling example files.
  • Click on Nonpareil.tex and you will see lines of text which are a small marbling program.  Find the Papeeria Compile pull down and click on Nonpareil.tex.  In less than 30 seconds a colorful design will appear in the PDF tab (you may need to install a PDF viewer on your device).
nonpareil marbling
Low resolution rendering of Nonpareil.tex
Returning to the Nonpareil.tex code: After the \psMarble line there are several sections bounded by curly braces { and }. The colors= section accepts RGB colors in three formats.
[0.906 0.8 0.608]
Red, green, and blue color components between 0 and 1 in square brackets.
[231 204 155]
Red, green, and blue color components between 0 and 255 in square brackets.
(e7cc9b)
Red, green, and blue (RRGGBB) hexadecimal color components between 00 and fF in parentheses.
The percent symbol % is the comment character in .tex files.  Text to the right of % is ignored to the end-of-line.  Try commenting out some color lines, then click on Papeeria's Compile button; you should see fewer colors in the resulting marbling PDF.
The actions= section in Nonpareil.tex specifies the marbling design through a sequence of numbers (arguments) and commands separated by whitespace.  The system is a bit unusual in that the command is to the right of its arguments.  The leftmost two arguments to most of the commands are the x and y coordinates of the center of the marbling action.  0 0 for the first two arguments specifies the center of the design.  The visible x and y for a square image are from -500 to +500; but the virtual tank is infinite in size. 
Comment out four lines of the actions= section so that it looks like this; then Compile:
      0 0 48 colors 25 concentric-rings
%      90  [-150 450] 100 750 31 rake
%      -90 [-150 450] 100 750 31 rake
%      180 [ 25 50 0 tines ] 30 200 31 rake
%      0 230 shift
You should now see concentric colored rings in the PDF viewer. These are produced by concentric-rings command:
x y Ri [rgb ...] n concentric-rings
Places n rings in color sequence [rgb ...] centered at location x,y, each ring having thickness Ri.
These 25 rings are centered in the PDF and have a value of 48 for thickness. The colors argument refers to the color sequence from the colors= section. It can be replaced by a literal color sequence; for instance:
0 0 48 [(c28847) [231 204 155] [0.635 0.008 0.094]] 25 concentric-rings Next, uncomment the first two rake lines so that the actions= section looks like this; then Compile:
      0 0 48 colors 25 concentric-rings
      90  [-150 450] 100 750 31 rake
      -90 [-150 450] 100 750 31 rake
%      180 [ 25 50 0 tines ] 30 200 31 rake
%      0 230 shift
θ [R ...] V S D rake
Pulls tines of diameter D at θ degrees clockwise from the positive y-axis through the virtual tank at velocity V, moving fluid on the tine path a distance S.  The tine paths are spaced [R ...] from the tank center at their nearest points.
"90 [-150 450] 100 750 31 rake" rakes two tines from left to right.
"-90 [-150 450] 100 750 31 rake" rakes two tines from right to left. The tine tracks are distinct from the previous two because they are rotated 180 degrees. It is important to offset the tines so that rakes in opposite direction do not cancel each other out. You can see this cancellation by changing [-150 450] to [-300 300] in both lines.
Raking left and right increases the number of color bands. The next step will rake downward with 25 tines. While we could specify their positions as 25 numbers between brackets, pst-marble offers a utility for generating evenly spaced tines:
[n S Ω tines]
The tines command and its arguments are replaced by a sequence of n numbers. The difference between adjacent numbers is S and the center number is Ω when n is odd and S/2−Ω when n is even.
[2 600 -150 tines] is equivalent to [-150 450]. For the 25 tine rake, uncomment the rake line in actions= so that it looks like this; then Compile:
    0 0 48 colors 25 concentric-rings
    90  [-150 450] 100 750 31 rake
    -90 [-150 450] 100 750 31 rake
    180 [ 25 50 0 tines ] 30 200 31 rake
%    0 230 shift
The top quarter of the marbling is less densely threaded than the rest of the marbling. This is because, by raking downward without a compensating upward raking, the whole design has been moved downward. To recenter it pst-marble offers:
θ R shift
Shifts tank by R at θ degrees clockwise from vertical.
Uncommenting the shift line will center the nonpareil design; the value 230 was arrived at by trial and error:
    0 0 48 colors 25 concentric-rings
    90  [-150 450] 100 750 31 rake
    -90 [-150 450] 100 750 31 rake
    180 [ 25 50 0 tines ] 30 200 31 rake
    0 230 shift
The nonpareil design is common in marbling, and is the basis for more complicated designs as well. You can easily alter the appearance by changing the actions= code.
The pst-marble reference card gives brief descriptions of all the actions= commands. The next installment in this tutorial series explains how to rake curves.


Copyright © 2019 Aubrey Jaffer

Topological Computer Graphics
Go Figure!