Pensieve header: Making the “Knotted Candies” poster.

SetDirectory["C:\\drorbn\\AcademicPensieve\\2008-12"]

Switch[Online,
Online, ideal=Import["http://katlas.org/w/images/d/d2/Ideal.txt.gz", "String"],
Offline, ideal=Import["C:\\drorbn\\People\\Gilbert\\ideal.txt", "String"]
]

(* ideal1=Import["C:\\drorbn\\People\\Gilbert\\ideal.txt", "String"]
ideal="<data>"<>StringReplace[ideal1,"I="~~" "...~~ i:(DigitCharacter..) :> "I=\""<>i<>"\""]<>"</data>"; *)

data=Cases[ImportString[ideal, "XML"], XMLElement["AB", ab___] :> AB[ab], Infinity];

Length[data]

ProcessAB[ab_AB] := Module[
{Id, CS, L, n,c,k,K,coeffs},
{Id, CS, L} = {"Id", "Conway", "L"} /. ab[[1]];
{n,c,k} = ToExpression /@ StringSplit[Id, ":"];
If[n==10 && 161<k≤166, --k];
K=Knot[n,k];
coeffs=ab[[2]] /. XMLElement["Coeff", l_List, {}] :> {
ToExpression["I" /. l],
ToExpression["{"<>("A" /. l)<>"}"],
ToExpression["{"<>("B" /. l)<>"}"]
};
If[c == 1,
RopeLength[K] = ToExpression[L];
ConwayString[K] = CS;
IdealPresentationData[K] = coeffs;
K,
Print["Trouble in ", K]
]
];
IdealPresentation[K_Knot][t_] := Plus @@ (IdealPresentationData[K] /.
{i_,A_List,B_List} :> A Cos[i t] + B Sin[i t]
)

Ks = Union[ProcessAB /@ data];

Max[RopeLength /@ Ks]

RopeLength[Knot[0,1]]=N[Pi];
IdealPresentationData[Knot[0,1]] = {{1, {1,0,0}, {0,1,0}}};

(* ParametricPlot3D[IdealPresentation[Knot[3,1]][t], {t, 0, 2Pi}] *)

l=Length[Ks]

Clear[DrawKnot];
RandomUnitVector[] := (
v={1.15*Random[], Random[], Random[]};
v/Sqrt[v.v]
);
RandomColour[] := RGBColor@@RandomUnitVector[];
DrawKnot[K_Knot, opts___Rule] := DrawKnot[K,opts] = Module[
{background = Background /. {opts} /. Background -> Black},
ImageCrop[Rasterize[Graphics3D[{
Specularity[Random[], 20Random[]],
{X1,X2,X3}= Compile[{t}, #]& /@ IdealPresentation[K][t];
T =8RopeLength[K];
Tube[Table[{X1[2Pi k/T], X2[2Pi k/T], X3[2Pi k/T]}, {k, 0, T}], 0.1+0.4Random[]]
},
Boxed -> False, Background -> background, ImagePadding->None,
PlotRangePadding->0,
ViewPoint -> 10 RandomUnitVector[],
Lighting -> {
{"Directional", RandomColour[], RandomUnitVector[]},
{"Point", RandomColour[], 2RandomUnitVector[]}
}
]]]
];

SeedRandom[0];
im=Rasterize[GraphicsGrid[
Partition[
Join[
DrawKnot /@ {Knot[0,1]},
DrawKnot /@ Ks,
{Graphics[{Yellow, Text[Style[
Column[{
"Knotted Candies by Dror Bar-Natan (2008)",
"based on data by Brian Gilbert",
"http://www.math.toronto.edu/~drorbn/Gallery/KnottedObjects/Candies/"
}, Center
], 40
]]}]},
Table[SpanFromLeft, {5}]
], 16
],
Background -> Black, Spacings -> 0
], ImageSize -> 3200, RasterSize -> 3200, Background -> Black];
Show[ImageResize[im, 400]]

Export["C:/drorbn/AcademicPensieve/2008-12/KnottedCandies.png", im];
Export["C:/drorbn/AcademicPensieve/2008-12/KnottedCandies_720.png", ImageResize[im, 720]];

Export["C:/drorbn/AcademicPensieve/2008-12/KnottedCandies_120.png", ImageResize[ImageTake[im, -800, 800], 120]]

The white - background image wbim.

SeedRandom[0];
wbim=Rasterize[GraphicsGrid[
Partition[
Join[
DrawKnot[#,Background -> White]& /@ {Knot[0,1]},
DrawKnot[#,Background -> White]& /@ Ks,
{Graphics[{Red, Text[Style[
Column[{
"Knotted Candies by Dror Bar-Natan (2008)",
"based on data by Brian Gilbert",
"http://drorbn.net/ap/2008-12/"
}, Center
], 40
]]}]},
Table[SpanFromLeft, {5}]
], 16
],
Background -> White, Spacings -> 0, Frame -> None
], ImageSize -> 3200, RasterSize -> 3200, Background -> Black];
Show[ImageResize[wbim, 400]]

Export["C:/drorbn/AcademicPensieve/2008-12/KnottedCandies_WB_1600.png", ImageResize[wbim, 1600]];

The white - background up-to-8 image wbim8.

SeedRandom[0];
wbim8=Rasterize[GraphicsGrid[
Partition[
Join[
DrawKnot[#,Background -> White]& /@ {Knot[0,1]},
DrawKnot[#,Background -> White]& /@ Take[Ks,35]
], 9
],
Background -> White, Spacings -> 0, Frame -> None
], ImageSize -> 2400, RasterSize -> 2400, Background -> White];
Show[ImageResize[wbim8, 400]]

Export["C:/drorbn/AcademicPensieve/2008-12/KnottedCandiesTo8_WB_1600.png", ImageResize[wbim8, 1600]];

SeedRandom[0];
wbim8at5x7=Rasterize[GraphicsGrid[
Partition[DrawKnot[#,Background -> White]& /@ Take[Ks,35],7],
Background -> White, Spacings -> 0, Frame -> None
], ImageSize -> 2400, RasterSize -> 2400, Background -> White];
Show[ImageResize[wbim8at5x7, 400]]

Export["C:/drorbn/AcademicPensieve/2008-12/KnottedCandies@5x7_WB_800.png", ImageResize[wbim8at5x7, 800]];