%% tikzpizza.sty -- pizzas for fraction problems, drawn with TikZ %% Version 0.2, 2026/11/04 %% %% Copyright (C) 2026 Vernon Merrick Fanning %% %% This work 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. %% The latest version of this license is in %% https://www.latex-project.org/lppl.txt %% and version 1.3c or later is part of all distributions of LaTeX %% version 2008 or later. %% %% This work has the LPPL maintenance status `maintained'. %% %% The Current Maintainer of this work is Vernon Merrick Fanning. %% %% This work consists of the files tikzpizza.sty, tikzpizza-doc.tex %% and README.md, and the derived file tikzpizza-doc.pdf. %% %% All drawings in this work are original. They were made from scratch %% with TikZ paths for this package; none is traced from or based on a %% photograph or on anyone else's artwork. \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{tikzpizza}[2026/11/04 v0.2 Pizzas for fraction problems with TikZ] \RequirePackage{tikz} %% ================================================================== %% Colours %% ================================================================== \definecolor{pizzacrust}{HTML}{E9AF5E} \definecolor{pizzacrustdark}{HTML}{B9772F} \definecolor{pizzacrustlight}{HTML}{F8DFA9} \definecolor{pizzaline}{HTML}{7E4A22} \definecolor{pizzadough}{HTML}{F4DBA5} \definecolor{pizzatomato}{HTML}{D8402A} \definecolor{pizzapesto}{HTML}{6E9F3E} \definecolor{pizzawhite}{HTML}{F6EEDB} \definecolor{pizzabbq}{HTML}{7C3A1D} \definecolor{pizzamozzarella}{HTML}{FFD65E} \definecolor{pizzafreshmozz}{HTML}{FFF6DF} \definecolor{pizzacheddar}{HTML}{F6A33A} \definecolor{pizzapepperoni}{HTML}{C9362B} \definecolor{pizzamushroom}{HTML}{E4D3B8} \definecolor{pizzaolive}{HTML}{2F2A2C} \definecolor{pizzagreenpepper}{HTML}{4FA84A} \definecolor{pizzaonion}{HTML}{A9488F} \definecolor{pizzaham}{HTML}{F2A19D} \definecolor{pizzapineapple}{HTML}{FFF2A6} \definecolor{pizzasausage}{HTML}{8A573A} \definecolor{pizzatomatoslice}{HTML}{E5463A} \definecolor{pizzabasil}{HTML}{3F8F3B} \definecolor{pizzajalapeno}{HTML}{3D9A3D} \definecolor{pizzashrimp}{HTML}{F3896A} \definecolor{pizzaspinach}{HTML}{2F6B33} \definecolor{pizzamozzslice}{HTML}{FFFDF5} \definecolor{pizzaseed}{HTML}{F6E3B0} \definecolor{pizzatray}{HTML}{D7DCE2} \definecolor{pizzaboard}{HTML}{CB8E52} % the colours actually used; keys change these \colorlet{pizza@c@crust}{pizzacrust} \colorlet{pizza@c@crustdark}{pizzacrustdark} \colorlet{pizza@c@crustlight}{pizzacrustlight} \colorlet{pizza@c@line}{pizzaline} \colorlet{pizza@c@dough}{pizzadough} \colorlet{pizza@c@tray}{pizzatray} \colorlet{pizzatopping}{pizzapepperoni} \tikzset{ pizza label/.style={circle, fill=white, fill opacity=0.92, text opacity=1, draw=pizzaline, line width=0.4pt, inner sep=1.3pt, minimum size=1.15em, font=\sffamily\scriptsize\bfseries, text=pizzaline}, pizza ghost/.style={draw=pizzaline!80, opacity=0.75}, } %% ================================================================== %% Small tools %% ================================================================== % per-item data: \pizza@@{name}{index} reads, \pizza@set writes \def\pizza@@#1#2{\csname pizza@#1@#2\endcsname} \def\pizza@set#1#2#3{\expandafter\edef\csname pizza@#1@#2\endcsname{#3}} % \pizza@append{csname}{tokens}: add expanded tokens to a list \def\pizza@append#1#2{% \expandafter\edef\csname #1\endcsname{% \unexpanded\expandafter\expandafter\expandafter{\csname #1\endcsname}#2}} % \pizza@for\counter{from}{to}{body}: a loop that does not group, so the % body can define things. Loops with different counters nest. \newcount\pizza@ci \newcount\pizza@cj \newcount\pizza@ck \newcount\pizza@cl \newcount\pizza@cm \newcount\pizza@cr \long\def\pizza@for#1#2#3#4{% #1=\numexpr#2\relax \expandafter\def\csname pizza@fb\string#1\endcsname{#4}% \expandafter\edef\csname pizza@fe\string#1\endcsname{\the\numexpr#3\relax}% \pizza@fori#1} \def\pizza@fori#1{% \ifnum#1>\csname pizza@fe\string#1\endcsname\relax\else \csname pizza@fb\string#1\endcsname \advance#1 1 \expandafter\pizza@fori\expandafter#1% \fi} % A cheap deterministic "random" number (as in tikzfins). % \pizza@ihash{a}{b} sets \pizza@hC to 0..996; \pizza@rand sets % \pizza@h to a decimal in [0,1). \def\pizza@mod#1#2{% \count@=\numexpr#2\relax \count@=\numexpr\count@-(\count@/997)*997\relax \ifnum\count@<0 \advance\count@ 997 \fi \edef#1{\the\count@}} \def\pizza@ihash#1#2{% \pizza@mod\pizza@hA{#1}\pizza@mod\pizza@hB{#2}% \pizza@mod\pizza@hC{\pizza@hA*\pizza@hA}% \pizza@mod\pizza@hC{\pizza@hC*547+\pizza@hA*1453+\pizza@hB*9973+1013}% \pizza@mod\pizza@hC{\pizza@hC*\pizza@hC+\pizza@hB*31}} \def\pizza@rand#1#2{% \pizza@ihash{#1}{#2}\edef\pizza@h{\strip@pt\dimexpr\pizza@hC pt/997\relax}} % Points spread evenly over the pizza's bounding box: the R2 sequence % (a two-dimensional golden-ratio sequence), shifted by a seed. Toppings % placed this way never bunch up the way random points do. \def\pizza@modN#1{% \count@=\numexpr\count@-(\count@/#1)*#1\relax \ifnum\count@<0 \advance\count@ #1\relax\fi} \def\pizza@rtwo#1#2{% index, seed -> \pizza@px, \pizza@py \pizza@ihash{#2}{17}% \count@=\numexpr\pizza@hC*65+(#1)*49471\relax \pizza@modN{65536}% \edef\pizza@px{\strip@pt\dimexpr\pizza@minx pt+\pizza@bw pt*\count@/65536\relax}% \pizza@ihash{#2}{29}% \count@=\numexpr\pizza@hC*65+(#1)*37345\relax \pizza@modN{65536}% \edef\pizza@py{\strip@pt\dimexpr\pizza@miny pt+\pizza@bh pt*\count@/65536\relax}} % Read a TikZ coordinate into two numbers (in cm). \def\pizza@gotpoint#1{\pgf@process{#1}% \edef\pizza@ptx{\pgf@sys@tonumber\pgf@x}\edef\pizza@pty{\pgf@sys@tonumber\pgf@y}} \def\pizza@readpoint#1#2#3{% \expandafter\tikz@scan@one@point\expandafter\pizza@gotpoint#1\relax \pgfmathsetmacro#2{\pizza@ptx/28.45274}\pgfmathsetmacro#3{\pizza@pty/28.45274}} % Clip without letting a huge clip path grow the picture (as in tikzfins). \def\pizza@savebb{% \edef\pizza@restorebb{% \global\pgf@picminx=\the\pgf@picminx\relax\global\pgf@picmaxx=\the\pgf@picmaxx\relax \global\pgf@picminy=\the\pgf@picminy\relax\global\pgf@picmaxy=\the\pgf@picmaxy\relax}} \def\pizza@bigclip#1{% \pizza@savebb \ifpgf@relevantforpicturesize\def\pizza@recount{\pgf@relevantforpicturesizetrue}% \else\let\pizza@recount\relax\fi \clip #1;% \pizza@restorebb \pizza@recount} %% ------------------------------------------------------------------ %% Lists of pieces: 1,3,5 2-6 4-last all none odd even first last %% \pizza@resolve{spec}\macro makes \macro = ",1,3,5," %% ------------------------------------------------------------------ \def\pizza@kw@all{all}\def\pizza@kw@none{none}\def\pizza@kw@odd{odd} \def\pizza@kw@even{even}\def\pizza@kw@first{first}\def\pizza@kw@last{last} \def\pizza@none{none} \def\pizza@resolve#1#2{% \def\pizza@res{,}% \edef\pizza@spec{#1}% \@for\pizza@it:=\pizza@spec\do{\pizza@resitem}% \let#2\pizza@res} \def\pizza@addrange#1#2{% \pizza@for\pizza@cr{#1}{#2}{% \ifnum\pizza@cr>0 \ifnum\pizza@cr>\pizza@n\relax\else \edef\pizza@res{\pizza@res\the\pizza@cr,}\fi\fi}} \def\pizza@addodd{\pizza@for\pizza@cr{1}{\pizza@n}{% \ifodd\pizza@cr \edef\pizza@res{\pizza@res\the\pizza@cr,}\fi}} \def\pizza@addeven{\pizza@for\pizza@cr{1}{\pizza@n}{% \ifodd\pizza@cr\else \edef\pizza@res{\pizza@res\the\pizza@cr,}\fi}} \def\pizza@number#1#2{% word or number -> integer \edef\pizza@tmpn{#2}% \ifx\pizza@tmpn\pizza@kw@last\edef#1{\pizza@n}% \else\ifx\pizza@tmpn\pizza@kw@first\def#1{1}% \else\pgfmathtruncatemacro#1{#2}\fi\fi} \def\pizza@splitrange#1-#2\relax{% \pizza@number\pizza@ra{#1}\pizza@number\pizza@rb{#2}% \pizza@addrange{\pizza@ra}{\pizza@rb}} \def\pizza@resitem{% \edef\pizza@it{\expandafter\pizza@zap\expandafter{\pizza@it}}% \ifx\pizza@it\pgfutil@empty\else \ifx\pizza@it\pizza@kw@all \pizza@addrange{1}{\pizza@n}\else \ifx\pizza@it\pizza@kw@none\else \ifx\pizza@it\pizza@kw@odd \pizza@addodd\else \ifx\pizza@it\pizza@kw@even \pizza@addeven\else \expandafter\in@\expandafter-\expandafter{\pizza@it}% \ifin@ \expandafter\pizza@splitrange\pizza@it\relax \else \pizza@number\pizza@ra{\pizza@it}\pizza@addrange{\pizza@ra}{\pizza@ra}\fi \fi\fi\fi\fi\fi} \def\pizza@zap#1{\zap@space#1 \@empty} \def\pizza@ifin#1#2{% \edef\pizza@tmpin{\noexpand\in@{,#1,}{#2}}\pizza@tmpin \ifin@\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi} %% ================================================================== %% Keys %% ================================================================== \newif\ifpizza@grid \newif\ifpizza@cutlines \pizza@cutlinestrue \newif\ifpizza@ghost \newif\ifpizza@numbers \newif\ifpizza@tray \newif\ifpizza@shadowon \newif\ifpizza@ok \def\pizza@setgrid#1{\pizza@gridtrue\pizza@splitgrid#1x#1x\relax} \def\pizza@splitgrid#1x#2x#3\relax{\def\pizza@cols{#1}\def\pizza@rows{#2}} \def\pizza@sides{5} \def\pizza@cols{2}\def\pizza@rows{2} \pgfkeys{ /pizza/.is family, /pizza/.cd, % placement at/.store in=\pizza@at, at={(0,0)}, scale/.store in=\pizza@scale, scale=1, rotate/.store in=\pizza@rotate, rotate=0, line width/.store in=\pizza@linew, line width=1, % shape shape/.is choice, shape/circle/.code={\def\pizza@shape{0}}, shape/round/.code={\def\pizza@shape{0}}, shape/triangle/.code={\def\pizza@shape{1}\def\pizza@sides{3}}, shape/square/.code={\def\pizza@shape{1}\def\pizza@sides{4}}, shape/pentagon/.code={\def\pizza@shape{1}\def\pizza@sides{5}}, shape/hexagon/.code={\def\pizza@shape{1}\def\pizza@sides{6}}, shape/octagon/.code={\def\pizza@shape{1}\def\pizza@sides{8}}, shape/polygon/.code={\def\pizza@shape{1}}, shape/rectangle/.code={\def\pizza@shape{2}}, shape=circle, sides/.code={\def\pizza@shape{1}\def\pizza@sides{#1}}, radius/.store in=\pizza@radius, radius=2, side/.store in=\pizza@side, side=, width/.store in=\pizza@width, width=4.6, height/.store in=\pizza@height, height=3.2, corner radius/.store in=\pizza@corner, corner radius=0.3, % cutting slices/.code={\pizza@gridfalse\def\pizza@slicespec{#1}}, slices=8, grid/.code={\pizza@setgrid{#1}}, strips/.code={\pizza@gridtrue\def\pizza@cols{#1}\def\pizza@rows{1}}, start/.store in=\pizza@start, start=90, hub/.store in=\pizza@hub, hub={(0,0)}, cut by/.is choice, cut by/area/.code={\def\pizza@cutby{0}}, cut by/angle/.code={\def\pizza@cutby{1}}, cut by=area, sloppy/.store in=\pizza@sloppy, sloppy/.default=0.6, sloppy=0, seed/.store in=\pizza@seed, seed=1, cut lines/.is if=pizza@cutlines, % pieces eaten/.store in=\pizza@eaten, eaten=none, missing/.store in=\pizza@eaten, removed/.store in=\pizza@eaten, ghost/.is if=pizza@ghost, separate/.store in=\pizza@separate, separate/.default=0.15, separate=0, pull/.store in=\pizza@pull, pull=none, pull distance/.store in=\pizza@pulld, pull distance=0.8, numbers/.is if=pizza@numbers, labels/.store in=\pizza@labels, labels=, % bites bites/.store in=\pizza@bites, bites/.default=1, bites=0, bite on/.store in=\pizza@biteon, bite on=all, bite from/.is choice, bite from/edge/.code={\def\pizza@bitetip{0}}, bite from/tip/.code={\def\pizza@bitetip{1}}, bite from=edge, bite size/.store in=\pizza@bitesize, bite size=0.42, % tray tray/.code={\pizza@traytrue\def\pizza@traytype{#1}}, tray/.default=auto, no tray/.code={\pizza@trayfalse}, tray color/.code={\colorlet{pizza@c@tray}{#1}}, crumbs/.store in=\pizza@crumbs, crumbs=1, shadow/.store in=\pizza@shadow, shadow/.default=true, shadow=auto, % crust, sauce and cheese crust/.code={\colorlet{pizza@c@crust}{#1}% \colorlet{pizza@c@crustdark}{#1!80!black}% \colorlet{pizza@c@crustlight}{#1!45!white}}, crust width/.store in=\pizza@crustw, crust width=0.3, dough/.code={\colorlet{pizza@c@dough}{#1}}, outline/.code={\colorlet{pizza@c@line}{#1}}, sauce/.code={\pizza@addspread{sauce}{#1}}, sauce/.default=default, cheese/.code={\pizza@addspread{cheese}{#1}}, cheese/.default=default, } \def\pizza@traytype{auto} % options of one sauce, cheese or topping \pgfkeys{ /pizza/layer/.is family, /pizza/layer/.cd, on/.store in=\pizza@l@on, density/.store in=\pizza@l@density, count/.store in=\pizza@l@count, size/.store in=\pizza@l@size, color/.store in=\pizza@l@color, colour/.store in=\pizza@l@color, seed/.store in=\pizza@l@seed, .unknown/.code={\let\pizza@l@kind\pgfkeyscurrentname}, } \def\pizza@readlayer#1{% \def\pizza@l@on{all}\def\pizza@l@density{1}\def\pizza@l@count{}% \def\pizza@l@size{1}\def\pizza@l@color{}\def\pizza@l@seed{0}\def\pizza@l@kind{}% \pgfkeys{/pizza/layer/.cd,#1}} % Toppings are numbered layers: {type}{on}{density}{count}{size}{colour}{seed} \newcount\pizza@nlayers \def\pizza@addlayer#1#2{% \begingroup \pizza@readlayer{#2}% \ifx\pizza@l@kind\pgfutil@empty\else \PackageWarning{tikzpizza}{Unknown option `\pizza@l@kind' for #1 ignored}\fi \xdef\pizza@tmpl{{#1}{\pizza@l@on}{\pizza@l@density}{\pizza@l@count}% {\pizza@l@size}{\pizza@l@color}{\pizza@l@seed}}% \endgroup \advance\pizza@nlayers 1 \expandafter\let\csname pizza@layer@\the\pizza@nlayers\endcsname\pizza@tmpl} \def\pizza@unpack#1#2#3#4#5#6#7{% \def\pizza@L@type{#1}\def\pizza@L@on{#2}\def\pizza@L@density{#3}% \def\pizza@L@count{#4}\def\pizza@L@size{#5}\def\pizza@L@color{#6}\def\pizza@L@seed{#7}} \def\pizza@getlayer#1{% \expandafter\expandafter\expandafter\pizza@unpack\csname pizza@layer@#1\endcsname} % Sauces and cheeses are spread, not scattered: {kind}{on}{colour}. % Later ones win on the pieces they cover. \newcount\pizza@nsauce \newcount\pizza@ncheese \def\pizza@addspread#1#2{% \begingroup \pizza@readlayer{#2}% \ifx\pizza@l@kind\pgfutil@empty\def\pizza@l@kind{default}\fi \xdef\pizza@tmpl{{\pizza@l@kind}{\pizza@l@on}{\pizza@l@color}}% \endgroup \global\advance\csname pizza@n#1\endcsname 1 \expandafter\let\csname pizza@rec#1@\the\csname pizza@n#1\endcsname\endcsname\pizza@tmpl} \def\pizza@sauce@default{pizzatomato}\def\pizza@sauce@tomato{pizzatomato} \def\pizza@sauce@pesto{pizzapesto}\def\pizza@sauce@white{pizzawhite} \def\pizza@sauce@bbq{pizzabbq}\def\pizza@sauce@none{none} \def\pizza@cheese@default{pizzamozzarella}\def\pizza@cheese@mozzarella{pizzamozzarella} \def\pizza@cheese@white{pizzafreshmozz}\def\pizza@cheese@cheddar{pizzacheddar} \def\pizza@cheese@none{none} \def\pizza@spreadcolor#1#2#3#4{% sauce|cheese, kind, on, colour -> \pizza@sc \edef\pizza@tmpk{#2}% \ifx\pizza@tmpk\pizza@none \def\pizza@sc{none}% \else \edef\pizza@tmpc{#4}% \ifx\pizza@tmpc\pgfutil@empty \ifcsname pizza@#1@#2\endcsname \edef\pizza@sc{\csname pizza@#1@#2\endcsname}% \else \PackageError{tikzpizza}{Unknown #1 `#2'}{Sauces: tomato, pesto, white, bbq, none. Cheeses: mozzarella, white, cheddar, none.}% \def\pizza@sc{none}% \fi \else\def\pizza@sc{#4}\fi \fi} %% ================================================================== %% The user commands %% ================================================================== \def\pizza@presets{} \newcommand\pizzaset[1]{% \edef\pizza@presets{\unexpanded\expandafter{\pizza@presets},\unexpanded{#1}}} \newcommand\pizza[1][]{% \begingroup \pizza@nlayers=0 \global\pizza@nsauce=0 \global\pizza@ncheese=0 \pizza@addspread{sauce}{default}\pizza@addspread{cheese}{default}% \edef\pizza@tmp{\noexpand\pgfkeys{/pizza/.cd,% \unexpanded\expandafter{\pizza@presets},\unexpanded{#1}}}% \pizza@tmp \pizza@build \endgroup} \newcommand\pizzatray[1][]{\pizza[tray,#1]} \newcommand\pizzapic[1][]{% \tikz[baseline={([yshift=-0.6ex]current bounding box.center)}]{\pizza[#1]}} % \pizzanewtopping{name}{radius}{density}{colour}{drawing} \newcommand\pizzanewtopping[5]{% \expandafter\def\csname pizza@top@#1\endcsname{#5}% \expandafter\def\csname pizza@topr@#1\endcsname{#2}% \expandafter\def\csname pizza@topd@#1\endcsname{#3}% \expandafter\def\csname pizza@topc@#1\endcsname{#4}% \pgfkeys{/pizza/#1/.code={\pizza@addlayer{#1}{##1}}, /pizza/#1/.default={}}} \def\pizza@build{% \pgfmathsetlengthmacro\pizza@lw{0.55pt*\pizza@scale*\pizza@linew}% \pgfmathsetlengthmacro\pizzalw{0.42pt*\pizza@scale*\pizza@linew}% \pgfmathsetlengthmacro\pizza@rc{\pizza@corner*\pizza@scale*1cm}% \pgfmathsetlengthmacro\pizza@dA{2.6pt*\pizza@scale}% \pgfmathsetlengthmacro\pizza@dB{2pt*\pizza@scale}% \pizza@setupshape \ifpizza@grid\pizza@setupgrid\else\pizza@setupradial\fi \pizza@setuppieces \pizza@setupspreads \pizza@setuptoppings \pizza@setupbites \pizza@draw} %% ================================================================== %% Shapes %% A circle (kind 0) or a convex polygon (kind 1), centred on (0,0). %% Polygons keep their corners in \pizza@vx@j, \pizza@vy@j, \pizza@vt@j %% (angle), counter-clockwise from j=0, and their edges in \pizza@edges %% as \pizza@edge{nx}{ny}{o}: outward normal n, and n.p <= o inside. %% ================================================================== \def\pizza@setupshape{% \ifcase\pizza@shape\relax \def\pizza@kind{0}\def\pizza@nv{0}% \pgfmathsetmacro\pizza@R{\pizza@radius}% \let\pizza@outR\pizza@R \pgfmathsetmacro\pizza@minx{-\pizza@R}\let\pizza@maxx\pizza@R \let\pizza@miny\pizza@minx\let\pizza@maxy\pizza@R \edef\pizza@shapepath{(0,0) circle [radius=\pizza@R]}% \let\pizza@roundpath\pizza@shapepath \or \def\pizza@kind{1}% \pgfmathtruncatemacro\pizza@nv{max(3,\pizza@sides)}% \ifx\pizza@side\pgfutil@empty % as much pizza as a round one of this radius \pgfmathsetmacro\pizza@R{\pizza@radius*sqrt(2*pi/(\pizza@nv*sin(360/\pizza@nv)))}% \else \pgfmathsetmacro\pizza@R{\pizza@side/(2*sin(180/\pizza@nv))}\fi \ifodd\pizza@nv \def\pizza@azero{90}% \else \pgfmathsetmacro\pizza@azero{90+180/\pizza@nv}\fi \pizza@for\pizza@ci{0}{\pizza@nv-1}{% \pgfmathsetmacro\pizza@ta{Mod(\pizza@azero+360*\the\pizza@ci/\pizza@nv,360)}% \pgfmathsetmacro\pizza@tx{\pizza@R*cos(\pizza@ta)}% \pgfmathsetmacro\pizza@ty{\pizza@R*sin(\pizza@ta)}% \pizza@set{vt}{\the\pizza@ci}{\pizza@ta}% \pizza@set{vx}{\the\pizza@ci}{\pizza@tx}\pizza@set{vy}{\the\pizza@ci}{\pizza@ty}}% \let\pizza@outR\pizza@R \pizza@polysetup \or \def\pizza@kind{1}\def\pizza@nv{4}% \pgfmathsetmacro\pizza@hw{\pizza@width/2}\pgfmathsetmacro\pizza@hh{\pizza@height/2}% \pizza@set{vx}{0}{\pizza@hw}\pizza@set{vy}{0}{\pizza@hh}% \pizza@set{vx}{1}{-\pizza@hw}\pizza@set{vy}{1}{\pizza@hh}% \pizza@set{vx}{2}{-\pizza@hw}\pizza@set{vy}{2}{-\pizza@hh}% \pizza@set{vx}{3}{\pizza@hw}\pizza@set{vy}{3}{-\pizza@hh}% \pizza@for\pizza@ci{0}{3}{% \pgfmathsetmacro\pizza@ta{Mod(atan2(\pizza@@{vy}{\the\pizza@ci},\pizza@@{vx}{\the\pizza@ci}),360)}% \pizza@set{vt}{\the\pizza@ci}{\pizza@ta}}% \pgfmathsetmacro\pizza@outR{veclen(\pizza@hw,\pizza@hh)}% \pizza@polysetup \fi \pgfmathsetmacro\pizza@bw{\pizza@maxx-(\pizza@minx)}% \pgfmathsetmacro\pizza@bh{\pizza@maxy-(\pizza@miny)}% \pgfmathsetmacro\pizza@barea{\pizza@bw*\pizza@bh}} \def\pizza@polysetup{% \def\pizza@edges{}% \def\pizza@minx{1000}\def\pizza@maxx{-1000}\def\pizza@miny{1000}\def\pizza@maxy{-1000}% \def\pizza@shapepath{}\def\pizza@roundpath{}% \pizza@for\pizza@ci{0}{\pizza@nv-1}{% \edef\pizza@nj{\the\numexpr\pizza@ci+1\relax}% \ifnum\pizza@nj=\pizza@nv\relax\def\pizza@nj{0}\fi \edef\pizza@Ax{\pizza@@{vx}{\the\pizza@ci}}\edef\pizza@Ay{\pizza@@{vy}{\the\pizza@ci}}% \edef\pizza@Bx{\pizza@@{vx}{\pizza@nj}}\edef\pizza@By{\pizza@@{vy}{\pizza@nj}}% \pgfmathsetmacro\pizza@el{veclen((\pizza@Bx)-(\pizza@Ax),(\pizza@By)-(\pizza@Ay))}% \pgfmathsetmacro\pizza@enx{((\pizza@By)-(\pizza@Ay))/\pizza@el}% \pgfmathsetmacro\pizza@eny{((\pizza@Ax)-(\pizza@Bx))/\pizza@el}% \pgfmathsetmacro\pizza@eo{\pizza@enx*(\pizza@Ax)+\pizza@eny*(\pizza@Ay)}% \edef\pizza@edges{\unexpanded\expandafter{\pizza@edges}\noexpand\pizza@edge{\pizza@enx}{\pizza@eny}{\pizza@eo}}% \ifdim\pizza@Ax pt<\pizza@minx pt \let\pizza@minx\pizza@Ax\fi \ifdim\pizza@Ax pt>\pizza@maxx pt \let\pizza@maxx\pizza@Ax\fi \ifdim\pizza@Ay pt<\pizza@miny pt \let\pizza@miny\pizza@Ay\fi \ifdim\pizza@Ay pt>\pizza@maxy pt \let\pizza@maxy\pizza@Ay\fi \edef\pizza@shapepath{\pizza@shapepath(\pizza@Ax,\pizza@Ay) -- }% \edef\pizza@roundpath{\pizza@roundpath -- (\pizza@Ax,\pizza@Ay)}}% \edef\pizza@shapepath{\pizza@shapepath cycle}% % start the rounded outline half way along an edge, so that every % corner gets rounded \edef\pizza@Lx{\pizza@@{vx}{\the\numexpr\pizza@nv-1\relax}}% \edef\pizza@Ly{\pizza@@{vy}{\the\numexpr\pizza@nv-1\relax}}% \pgfmathsetmacro\pizza@Mx{((\pizza@Lx)+(\pizza@@{vx}{0}))/2}% \pgfmathsetmacro\pizza@My{((\pizza@Ly)+(\pizza@@{vy}{0}))/2}% \edef\pizza@roundpath{[rounded corners=\pizza@rc] (\pizza@Mx,\pizza@My) \pizza@roundpath -- cycle}} % inside distance of (#1,#2) from the edge -> \pizza@d \def\pizza@dist#1#2{% \ifnum\pizza@kind=0 \pgfmathsetmacro\pizza@d{\pizza@R-veclen(#1,#2)}% \else \def\pizza@d{1000}% \def\pizza@edge##1##2##3{% \pgfmathsetmacro\pizza@t{(##3)-(##1)*(#1)-(##2)*(#2)}% \ifdim\pizza@t pt<\pizza@d pt \let\pizza@d\pizza@t\fi}% \pizza@edges \fi} % distance from the centre to the edge at angle #1, moved in by #2 -> \pizza@r \def\pizza@rho#1#2{% \ifnum\pizza@kind=0 \pgfmathsetmacro\pizza@r{\pizza@R-(#2)}% \else \pgfmathsetmacro\pizza@ux{cos(#1)}\pgfmathsetmacro\pizza@uy{sin(#1)}% \def\pizza@r{1000}% \def\pizza@edge##1##2##3{% \pgfmathsetmacro\pizza@c{(##1)*\pizza@ux+(##2)*\pizza@uy}% \ifdim\pizza@c pt>0.01pt \pgfmathsetmacro\pizza@t{((##3)-(#2))/\pizza@c}% \ifdim\pizza@t pt<\pizza@r pt \let\pizza@r\pizza@t\fi \fi}% \pizza@edges \fi} % the point of the edge at angle #1 -> \pizza@bx, \pizza@by \def\pizza@bpoint#1{% \pizza@rho{#1}{0}% \pgfmathsetmacro\pizza@bx{\pizza@r*cos(#1)}\pgfmathsetmacro\pizza@by{\pizza@r*sin(#1)}} % from (#1,#2) in direction #3: distance to the edge -> \pizza@t \def\pizza@rayexit#1#2#3{% \pgfmathsetmacro\pizza@ux{cos(#3)}\pgfmathsetmacro\pizza@uy{sin(#3)}% \ifnum\pizza@kind=0 \pgfmathsetmacro\pizza@b{(#1)*\pizza@ux+(#2)*\pizza@uy}% \pgfmathsetmacro\pizza@t{0-(\pizza@b)+sqrt(max(0,(\pizza@b)*(\pizza@b)-(#1)*(#1)-(#2)*(#2)+\pizza@R*\pizza@R))}% \else \def\pizza@tt{1000}% \def\pizza@edge##1##2##3{% \pgfmathsetmacro\pizza@c{(##1)*\pizza@ux+(##2)*\pizza@uy}% \ifdim\pizza@c pt>0.01pt \pgfmathsetmacro\pizza@t{((##3)-(##1)*(#1)-(##2)*(#2))/\pizza@c}% \ifdim\pizza@t pt<\pizza@tt pt \let\pizza@tt\pizza@t\fi \fi}% \pizza@edges \let\pizza@t\pizza@tt \fi} % the polygon corner that comes first clockwise after angle #1 -> \pizza@vs \def\pizza@firstvertex#1{% \def\pizza@best{1000}\def\pizza@vs{0}% \pizza@for\pizza@cj{0}{\pizza@nv-1}{% \pgfmathsetmacro\pizza@tmpd{Mod((#1)-\pizza@@{vt}{\the\pizza@cj},360)}% \ifdim\pizza@tmpd pt>0.001pt \ifdim\pizza@tmpd pt<\pizza@best pt \let\pizza@best\pizza@tmpd \edef\pizza@vs{\the\pizza@cj}\fi\fi}} %% ------------------------------------------------------------------ %% Fast tests in plain TeX arithmetic (pgfmath is twenty times slower) %% Numbers are cm, written as pt inside \dimexpr. %% ------------------------------------------------------------------ \newif\ifpizza@in % is (#1,#2) at least #3 inside the edge? \def\pizza@isin#1#2#3{% \pizza@intrue \ifnum\pizza@kind=0 \count@=\numexpr\dimexpr\pizza@R pt-#3pt\relax/64\relax \ifnum\count@<0 \pizza@infalse\else \ifnum\numexpr(\dimexpr#1pt\relax/64)*(\dimexpr#1pt\relax/64) +(\dimexpr#2pt\relax/64)*(\dimexpr#2pt\relax/64)\relax>\numexpr\count@*\count@\relax \pizza@infalse\fi \fi \else \def\pizza@edge##1##2##3{% \ifdim\dimexpr##3pt-##1\dimexpr#1pt\relax-##2\dimexpr#2pt\relax\relax<#3pt \pizza@infalse\fi}% \pizza@edges \fi} % distance from the centre to the edge, moved in by #3, in the direction % (#1,#2) (a unit vector) -> \pizza@r \def\pizza@frho#1#2#3{% \ifnum\pizza@kind=0 \edef\pizza@r{\strip@pt\dimexpr\pizza@R pt-#3pt\relax}% \else \dimen@=1000pt \def\pizza@edge##1##2##3{% \dimen@i=\dimexpr##1\dimexpr#1pt\relax+##2\dimexpr#2pt\relax\relax \ifdim\dimen@i>0.01pt \dimen@ii=\dimexpr\dimexpr##3pt-#3pt\relax*65536/\number\dimen@i\relax \ifdim\dimen@ii<\dimen@ \dimen@=\dimen@ii\fi \fi}% \pizza@edges \edef\pizza@r{\strip@pt\dimen@}% \fi} % cos and sin every 7.5 degrees, and every 30 degrees \pizza@for\pizza@ci{0}{47}{% \pgfmathsetmacro\pizza@tmp{cos(7.5*\the\pizza@ci)}% \expandafter\let\csname pizza@cos@\the\pizza@ci\endcsname\pizza@tmp \pgfmathsetmacro\pizza@tmp{sin(7.5*\the\pizza@ci)}% \expandafter\let\csname pizza@sin@\the\pizza@ci\endcsname\pizza@tmp} \pizza@for\pizza@ci{0}{11}{% \expandafter\edef\csname pizza@ccos@\the\pizza@ci\endcsname {\csname pizza@cos@\the\numexpr4*\pizza@ci\relax\endcsname}% \expandafter\edef\csname pizza@csin@\the\pizza@ci\endcsname {\csname pizza@sin@\the\numexpr4*\pizza@ci\relax\endcsname}} % A smooth closed curve through the 48 points \pizza@<#1>x@i, \pizza@<#1>y@i % (dimensions, already in pt), written once as pgf path commands into % \pizza@P#1, so that it costs nothing to draw again. \def\pizza@smooth#1{% \def\pizza@sacc{}% \pizza@for\pizza@cr{0}{47}{% \edef\pizza@ia{\the\numexpr\ifnum\pizza@cr=0 47\else\pizza@cr-1\fi\relax}% \edef\pizza@ib{\the\numexpr\ifnum\pizza@cr=47 0\else\pizza@cr+1\fi\relax}% \edef\pizza@ic{\the\numexpr\ifnum\pizza@ib=47 0\else\pizza@ib+1\fi\relax}% \edef\pizza@sacc{\unexpanded\expandafter{\pizza@sacc}% \noexpand\pgfpathcurveto {\noexpand\pgfqpoint {\the\dimexpr\pizza@@{#1x}{\the\pizza@cr}+0.17\dimexpr\pizza@@{#1x}{\pizza@ib}-\pizza@@{#1x}{\pizza@ia}\relax\relax}% {\the\dimexpr\pizza@@{#1y}{\the\pizza@cr}+0.17\dimexpr\pizza@@{#1y}{\pizza@ib}-\pizza@@{#1y}{\pizza@ia}\relax\relax}}% {\noexpand\pgfqpoint {\the\dimexpr\pizza@@{#1x}{\pizza@ib}-0.17\dimexpr\pizza@@{#1x}{\pizza@ic}-\pizza@@{#1x}{\the\pizza@cr}\relax\relax}% {\the\dimexpr\pizza@@{#1y}{\pizza@ib}-0.17\dimexpr\pizza@@{#1y}{\pizza@ic}-\pizza@@{#1y}{\the\pizza@cr}\relax\relax}}% {\noexpand\pgfqpoint{\pizza@@{#1x}{\pizza@ib}}{\pizza@@{#1y}{\pizza@ib}}}}}% \expandafter\edef\csname pizza@P#1\endcsname{% \noexpand\pgfpathmoveto{\noexpand\pgfqpoint{\pizza@@{#1x}{0}}{\pizza@@{#1y}{0}}}% \unexpanded\expandafter{\pizza@sacc}\noexpand\pgfpathclose}} %% ================================================================== %% Cutting into slices (from a hub, centred by default) %% Cut i (i = 0..n-1) runs from the hub to the edge point \pizza@Px@i; %% slice k lies clockwise between cut k-1 and cut k. %% ================================================================== \def\pizza@parseweights{% \expandafter\in@\expandafter,\expandafter{\pizza@slicespec}% \ifin@ \pizza@ci=0 \def\pizza@wsum{0}% \@for\pizza@it:=\pizza@slicespec\do{% \advance\pizza@ci 1 \pgfmathsetmacro\pizza@tmpw{max(0.0001,\pizza@it)}% \pizza@set{w}{\the\pizza@ci}{\pizza@tmpw}% \pgfmathsetmacro\pizza@wsum{\pizza@wsum+\pizza@tmpw}}% \edef\pizza@n{\the\pizza@ci}% \else \pgfmathtruncatemacro\pizza@n{max(1,\pizza@slicespec)}% \pizza@for\pizza@ci{1}{\pizza@n}{\pizza@set{w}{\the\pizza@ci}{1}}% \edef\pizza@wsum{\pizza@n}% \fi} \newcount\pizza@nq \def\pizza@addq#1#2{% add a point of the outline, keeping the area swept from the hub \edef\pizza@qpx{\pizza@@{Qx}{\the\pizza@nq}}\edef\pizza@qpy{\pizza@@{Qy}{\the\pizza@nq}}% \pgfmathsetmacro\pizza@tmpa{\pizza@@{Qa}{\the\pizza@nq}+0.5*(((#1)-\pizza@hx)*((\pizza@qpy)-\pizza@hy)-((#2)-\pizza@hy)*((\pizza@qpx)-\pizza@hx))}% \advance\pizza@nq 1 \pizza@set{Qx}{\the\pizza@nq}{#1}\pizza@set{Qy}{\the\pizza@nq}{#2}% \pizza@set{Qa}{\the\pizza@nq}{\pizza@tmpa}} % the outline, clockwise from the start of the first cut \def\pizza@ring{% \pizza@bpoint{\pizza@start}% \let\pizza@Sx\pizza@bx\let\pizza@Sy\pizza@by \pizza@nq=0 \pizza@set{Qx}{0}{\pizza@Sx}\pizza@set{Qy}{0}{\pizza@Sy}\pizza@set{Qa}{0}{0}% \ifnum\pizza@kind=0 \pizza@for\pizza@cj{1}{119}{% \pgfmathsetmacro\pizza@ta{\pizza@start-3*\the\pizza@cj}% \pgfmathsetmacro\pizza@tx{\pizza@R*cos(\pizza@ta)}% \pgfmathsetmacro\pizza@ty{\pizza@R*sin(\pizza@ta)}% \pizza@addq{\pizza@tx}{\pizza@ty}}% \else \pizza@firstvertex{\pizza@start}% \pizza@for\pizza@cj{0}{\pizza@nv-1}{% \pgfmathtruncatemacro\pizza@vi{Mod(\pizza@vs-\the\pizza@cj,\pizza@nv)}% \pgfmathsetmacro\pizza@tmpd{Mod(\pizza@start-\pizza@@{vt}{\pizza@vi},360)}% \ifdim\pizza@tmpd pt>0.001pt \ifdim\pizza@tmpd pt<359.999pt \pizza@addq{\pizza@@{vx}{\pizza@vi}}{\pizza@@{vy}{\pizza@vi}}\fi\fi}% \fi \pizza@addq{\pizza@Sx}{\pizza@Sy}} \def\pizza@seek{% \let\pizza@next\relax \ifnum\pizza@cj<\numexpr\pizza@nq-1\relax \ifdim\pizza@@{Qa}{\the\numexpr\pizza@cj+1\relax}pt<\pizza@target pt \advance\pizza@cj 1 \let\pizza@next\pizza@seek \fi \fi \pizza@next} \def\pizza@setupradial{% \pizza@parseweights \def\pizza@cum{0}% \pizza@for\pizza@ci{1}{\pizza@n}{% \pizza@set{cf}{\the\numexpr\pizza@ci-1\relax}{\pizza@cum}% \pgfmathsetmacro\pizza@cum{\pizza@cum+\pizza@@{w}{\the\pizza@ci}/\pizza@wsum}}% % sloppy: nudge every cut but the first, never past its neighbours \ifdim\pizza@sloppy pt>0pt \pizza@for\pizza@ci{1}{\pizza@n-1}{% \pizza@rand{\pizza@ci*7+3}{\pizza@seed+101}% \pgfmathsetmacro\pizza@tmpw{\pizza@@{cf}{\the\pizza@ci}+min(1,\pizza@sloppy)*(\pizza@h-0.5)*0.85% *min(\pizza@@{w}{\the\pizza@ci},\pizza@@{w}{\the\numexpr\pizza@ci+1\relax})/\pizza@wsum}% \pizza@set{cf}{\the\pizza@ci}{\pizza@tmpw}}% \fi % the hub \pizza@readpoint{\pizza@hub}\pizza@hx\pizza@hy \pizza@dist{\pizza@hx}{\pizza@hy}% \ifdim\pizza@d pt<0.1pt \PackageError{tikzpizza}{The hub \pizza@hub\space is not inside the pizza}% {The cuts must meet inside the pizza; the centre is used instead.}% \def\pizza@hx{0}\def\pizza@hy{0}% \fi \pgfmathsetmacro\pizza@hoff{veclen(\pizza@hx,\pizza@hy)}% \def\pizza@method{2}% 2 = by area along the outline \ifdim\pizza@hoff pt<0.001pt \ifnum\pizza@kind=0 \def\pizza@method{0}\fi % centred circle: equal angles \ifnum\pizza@cutby=1 \def\pizza@method{0}\fi \else \ifnum\pizza@cutby=1 \def\pizza@method{1}\fi % angles from an off-centre hub \fi \ifnum\pizza@method=2 \pizza@ring \pgfmathsetmacro\pizza@total{\pizza@@{Qa}{\the\pizza@nq}}\pizza@cj=0 \fi % the cuts \pizza@for\pizza@ci{0}{\pizza@n-1}{% \pgfmathsetmacro\pizza@phi{\pizza@start-360*\pizza@@{cf}{\the\pizza@ci}}% \ifcase\pizza@method\relax \pizza@bpoint{\pizza@phi}% \let\pizza@cx\pizza@bx\let\pizza@cy\pizza@by \or \pizza@rayexit{\pizza@hx}{\pizza@hy}{\pizza@phi}% \pgfmathsetmacro\pizza@cx{\pizza@hx+\pizza@t*cos(\pizza@phi)}% \pgfmathsetmacro\pizza@cy{\pizza@hy+\pizza@t*sin(\pizza@phi)}% \or \pgfmathsetmacro\pizza@target{\pizza@@{cf}{\the\pizza@ci}*\pizza@total}% \pizza@seek \edef\pizza@cjn{\the\numexpr\pizza@cj+1\relax}% \pgfmathsetmacro\pizza@f{(\pizza@@{Qa}{\pizza@cjn}-\pizza@@{Qa}{\the\pizza@cj})}% \ifdim\pizza@f pt>0.00001pt \pgfmathsetmacro\pizza@f{max(0,min(1,(\pizza@target-\pizza@@{Qa}{\the\pizza@cj})/\pizza@f))}% \else\def\pizza@f{0}\fi \pgfmathsetmacro\pizza@cx{\pizza@@{Qx}{\the\pizza@cj}+\pizza@f*(\pizza@@{Qx}{\pizza@cjn}-(\pizza@@{Qx}{\the\pizza@cj}))}% \pgfmathsetmacro\pizza@cy{\pizza@@{Qy}{\the\pizza@cj}+\pizza@f*(\pizza@@{Qy}{\pizza@cjn}-(\pizza@@{Qy}{\the\pizza@cj}))}% \ifnum\pizza@kind=0 % back onto the circle \pgfmathsetmacro\pizza@tmpd{\pizza@R/veclen(\pizza@cx,\pizza@cy)}% \pgfmathsetmacro\pizza@cx{\pizza@cx*\pizza@tmpd}% \pgfmathsetmacro\pizza@cy{\pizza@cy*\pizza@tmpd}% \fi \fi \pizza@set{Px}{\the\pizza@ci}{\pizza@cx}\pizza@set{Py}{\the\pizza@ci}{\pizza@cy}% \pgfmathsetmacro\pizza@tmpa{atan2(\pizza@cy,\pizza@cx)}% \pizza@set{psi}{\the\pizza@ci}{\pizza@tmpa}% \pgfmathsetmacro\pizza@tmpa{atan2((\pizza@cy)-\pizza@hy,(\pizza@cx)-\pizza@hx)}% \pizza@set{eta}{\the\pizza@ci}{\pizza@tmpa}}% % the slices \pizza@for\pizza@ck{1}{\pizza@n}{% \edef\pizza@ia{\the\numexpr\pizza@ck-1\relax}% \edef\pizza@ib{\the\numexpr\pizza@ck\relax}% \ifnum\pizza@ib=\pizza@n\relax\def\pizza@ib{0}\fi \pizza@set{void}{\the\pizza@ck}{0}% \pizza@set{pa}{\the\pizza@ck}{\pizza@@{psi}{\pizza@ia}}% \pizza@set{ea}{\the\pizza@ck}{\pizza@@{eta}{\pizza@ia}}% \pizza@set{eb}{\the\pizza@ck}{\pizza@@{eta}{\pizza@ib}}% \pgfmathsetmacro\pizza@tx{cos(\pizza@@{eta}{\pizza@ia})}\pizza@set{ca}{\the\pizza@ck}{\pizza@tx}% \pgfmathsetmacro\pizza@tx{sin(\pizza@@{eta}{\pizza@ia})}\pizza@set{sa}{\the\pizza@ck}{\pizza@tx}% \pgfmathsetmacro\pizza@tx{cos(\pizza@@{eta}{\pizza@ib})}\pizza@set{cb}{\the\pizza@ck}{\pizza@tx}% \pgfmathsetmacro\pizza@tx{sin(\pizza@@{eta}{\pizza@ib})}\pizza@set{sb}{\the\pizza@ck}{\pizza@tx}% \ifnum\pizza@n=1 \def\pizza@dpsi{360}\def\pizza@span{360}% \else \pgfmathsetmacro\pizza@dpsi{Mod(\pizza@@{psi}{\pizza@ia}-\pizza@@{psi}{\pizza@ib},360)}% \pgfmathsetmacro\pizza@span{Mod(\pizza@@{eta}{\pizza@ia}-\pizza@@{eta}{\pizza@ib},360)}% \fi \pizza@set{dpsi}{\the\pizza@ck}{\pizza@dpsi}\pizza@set{span}{\the\pizza@ck}{\pizza@span}% % its outline \ifnum\pizza@n=1 \pizza@set{pp}{\the\pizza@ck}{\unexpanded\expandafter{\pizza@shapepath}}% \else\ifnum\pizza@kind=0 \pizza@set{pp}{\the\pizza@ck}{(\pizza@hx,\pizza@hy) -- (\pizza@@{Px}{\pizza@ia},\pizza@@{Py}{\pizza@ia}) arc [start angle=\pizza@@{psi}{\pizza@ia}, delta angle=-\pizza@dpsi, radius=\pizza@R] -- cycle}% \else \edef\pizza@tmpp{(\pizza@hx,\pizza@hy) -- (\pizza@@{Px}{\pizza@ia},\pizza@@{Py}{\pizza@ia})}% \pizza@firstvertex{\pizza@@{psi}{\pizza@ia}}% \pizza@for\pizza@cj{0}{\pizza@nv-1}{% \pgfmathtruncatemacro\pizza@vi{Mod(\pizza@vs-\the\pizza@cj,\pizza@nv)}% \pgfmathsetmacro\pizza@tmpd{Mod(\pizza@@{psi}{\pizza@ia}-\pizza@@{vt}{\pizza@vi},360)}% \ifdim\pizza@tmpd pt>0.001pt \ifdim\pizza@tmpd pt<\dimexpr\pizza@dpsi pt-0.001pt\relax \edef\pizza@tmpp{\pizza@tmpp -- (\pizza@@{vx}{\pizza@vi},\pizza@@{vy}{\pizza@vi})}\fi\fi}% \pizza@set{pp}{\the\pizza@ck}{\pizza@tmpp -- (\pizza@@{Px}{\pizza@ib},\pizza@@{Py}{\pizza@ib}) -- cycle}% \fi\fi % where it points, and where its label goes \pgfmathsetmacro\pizza@tmpa{\pizza@@{psi}{\pizza@ia}-\pizza@dpsi/2}% \pizza@bpoint{\pizza@tmpa}% \ifnum\pizza@n=1 \pizza@set{dir}{\the\pizza@ck}{90}% \pizza@set{lx}{\the\pizza@ck}{0}\pizza@set{ly}{\the\pizza@ck}{0}% \else \pgfmathsetmacro\pizza@tmpa{atan2(\pizza@by-\pizza@hy,\pizza@bx-\pizza@hx)}% \pizza@set{dir}{\the\pizza@ck}{\pizza@tmpa}% \pgfmathsetmacro\pizza@tx{\pizza@hx+0.6*(\pizza@bx-\pizza@hx)}% \pgfmathsetmacro\pizza@ty{\pizza@hy+0.6*(\pizza@by-\pizza@hy)}% \pizza@set{lx}{\the\pizza@ck}{\pizza@tx}\pizza@set{ly}{\the\pizza@ck}{\pizza@ty}% \fi}} %% ================================================================== %% Cutting into a grid (square or tavern cut) %% Pieces are numbered row by row from the top left. A cell that misses %% the pizza altogether (the corners of a round pizza cut very finely) %% is `void': it keeps its number but is never drawn. %% ================================================================== \def\pizza@setupgrid{% \pgfmathtruncatemacro\pizza@nc{max(1,\pizza@cols)}% \pgfmathtruncatemacro\pizza@nr{max(1,\pizza@rows)}% \edef\pizza@n{\the\numexpr\pizza@nc*\pizza@nr\relax}% \pgfmathsetmacro\pizza@cw{\pizza@bw/\pizza@nc}% \pgfmathsetmacro\pizza@rh{\pizza@bh/\pizza@nr}% \def\pizza@hx{0}\def\pizza@hy{0}% \pizza@for\pizza@ci{0}{\pizza@nr-1}{% rows, from the top \pizza@for\pizza@cj{0}{\pizza@nc-1}{% columns, from the left \edef\pizza@k{\the\numexpr\pizza@ci*\pizza@nc+\pizza@cj+1\relax}% \pgfmathsetmacro\pizza@xa{\pizza@minx+\the\pizza@cj*\pizza@cw}% \pgfmathsetmacro\pizza@xb{\pizza@xa+\pizza@cw}% \pgfmathsetmacro\pizza@yb{\pizza@maxy-\the\pizza@ci*\pizza@rh}% \pgfmathsetmacro\pizza@ya{\pizza@yb-\pizza@rh}% \pizza@set{gi}{\pizza@k}{\the\pizza@cj}\pizza@set{gj}{\pizza@k}{\the\pizza@ci}% \pizza@set{xa}{\pizza@k}{\pizza@xa}\pizza@set{xb}{\pizza@k}{\pizza@xb}% \pizza@set{ya}{\pizza@k}{\pizza@ya}\pizza@set{yb}{\pizza@k}{\pizza@yb}% \pizza@set{pp}{\pizza@k}{(\pizza@xa,\pizza@ya) rectangle (\pizza@xb,\pizza@yb)}% % does the cell touch the pizza? \pgfmathsetmacro\pizza@tx{max(\pizza@xa,min(0,\pizza@xb))}% \pgfmathsetmacro\pizza@ty{max(\pizza@ya,min(0,\pizza@yb))}% \pizza@dist{\pizza@tx}{\pizza@ty}% \ifdim\pizza@d pt>0.03pt \pizza@set{void}{\pizza@k}{0}\else\pizza@set{void}{\pizza@k}{1}\fi % the label goes at the middle of the part of the cell on the pizza \def\pizza@sx{0}\def\pizza@sy{0}\pizza@cm=0 \pizza@for\pizza@cl{0}{4}{% \pizza@for\pizza@cr{0}{4}{% \pgfmathsetmacro\pizza@tx{\pizza@xa+(\the\pizza@cl+0.5)*\pizza@cw/5}% \pgfmathsetmacro\pizza@ty{\pizza@ya+(\the\pizza@cr+0.5)*\pizza@rh/5}% \pizza@dist{\pizza@tx}{\pizza@ty}% \ifdim\pizza@d pt>0.12pt \advance\pizza@cm 1 \pgfmathsetmacro\pizza@sx{\pizza@sx+\pizza@tx}\pgfmathsetmacro\pizza@sy{\pizza@sy+\pizza@ty}% \fi}}% \ifnum\pizza@cm=0 % a sliver too thin for a label \pizza@set{nolabel}{\pizza@k}{1}% \pgfmathsetmacro\pizza@sx{(\pizza@xa+\pizza@xb)/2}\pgfmathsetmacro\pizza@sy{(\pizza@ya+\pizza@yb)/2}% \else \pgfmathsetmacro\pizza@sx{\pizza@sx/\the\pizza@cm}\pgfmathsetmacro\pizza@sy{\pizza@sy/\the\pizza@cm}% \fi \pizza@set{lx}{\pizza@k}{\pizza@sx}\pizza@set{ly}{\pizza@k}{\pizza@sy}% \pgfmathsetmacro\pizza@tmpd{veclen(\pizza@sx,\pizza@sy)}% \ifdim\pizza@tmpd pt<0.05pt \pizza@set{dir}{\pizza@k}{90}% \else\pgfmathsetmacro\pizza@tmpa{atan2(\pizza@sy,\pizza@sx)}\pizza@set{dir}{\pizza@k}{\pizza@tmpa}\fi }}} %% ================================================================== %% Which piece is a point on? %% \pizza@classify{x}{y}{margin from the cuts}{margin from the edge} %% sets \pizza@cls to the piece, or 0. %% ================================================================== \def\pizza@classify#1#2#3#4{% \def\pizza@cls{0}% \pizza@isin{#1}{#2}{#4}% \ifpizza@in \ifpizza@grid \pizza@classgrid{#1}{#2}{#3}% \else\ifnum\pizza@n=1 \def\pizza@cls{1}% \else \pizza@classradial{#1}{#2}{#3}\fi\fi \fi} \def\pizza@classradial#1#2#3{% \edef\pizza@vx{\strip@pt\dimexpr#1pt-\pizza@hx pt\relax}% \edef\pizza@vy{\strip@pt\dimexpr#2pt-\pizza@hy pt\relax}% \pgfmathsetmacro\pizza@al{atan2(\pizza@vy,\pizza@vx)}% \pizza@for\pizza@cm{1}{\pizza@n}{% \ifnum\pizza@cls=0 \dimen@=\dimexpr\pizza@@{ea}{\the\pizza@cm}pt-\pizza@al pt\relax \ifdim\dimen@<0pt \advance\dimen@ 360pt\relax\fi \ifdim\dimen@<\pizza@@{span}{\the\pizza@cm}pt \edef\pizza@cls{\the\pizza@cm}\fi \fi}% \ifnum\pizza@cls>0 \ifdim#3pt>0pt \pizza@nearcut{ca}{sa}{#3}% \ifnum\pizza@cls>0 \pizza@nearcut{cb}{sb}{#3}\fi \fi\fi} % is the point (\pizza@vx,\pizza@vy) from the hub closer than #3 to the % cut of piece \pizza@cls whose direction is (#1,#2)? then it is off. \def\pizza@nearcut#1#2#3{% \dimen@=\dimexpr\pizza@@{#1}{\pizza@cls}\dimexpr\pizza@vx pt\relax +\pizza@@{#2}{\pizza@cls}\dimexpr\pizza@vy pt\relax\relax \ifdim\dimen@>0pt \dimen@=\dimexpr\pizza@@{#1}{\pizza@cls}\dimexpr\pizza@vy pt\relax -\pizza@@{#2}{\pizza@cls}\dimexpr\pizza@vx pt\relax\relax \ifdim\dimen@<0pt \dimen@=-\dimen@\fi \ifdim\dimen@<#3pt \def\pizza@cls{0}\fi \else \ifnum\numexpr(\dimexpr\pizza@vx pt\relax/64)*(\dimexpr\pizza@vx pt\relax/64) +(\dimexpr\pizza@vy pt\relax/64)*(\dimexpr\pizza@vy pt\relax/64)\relax <\numexpr(\dimexpr#3pt\relax/64)*(\dimexpr#3pt\relax/64)\relax \def\pizza@cls{0}\fi \fi} \def\pizza@classgrid#1#2#3{% \dimen@=\dimexpr#1pt-\pizza@minx pt\relax \dimen@i=\pizza@cw pt \edef\pizza@gi{\the\numexpr(2*\dimen@-\dimen@i)/(2*\dimen@i)\relax}% \dimen@=\dimexpr\pizza@maxy pt-#2pt\relax \dimen@i=\pizza@rh pt \edef\pizza@gj{\the\numexpr(2*\dimen@-\dimen@i)/(2*\dimen@i)\relax}% \ifnum\pizza@gi<0 \else\ifnum\pizza@gi<\pizza@nc\relax \ifnum\pizza@gj<0 \else\ifnum\pizza@gj<\pizza@nr\relax \edef\pizza@kk{\the\numexpr\pizza@gj*\pizza@nc+\pizza@gi+1\relax}% \ifnum\pizza@@{void}{\pizza@kk}=0 \let\pizza@cls\pizza@kk \ifdim\dimexpr#1pt-\pizza@@{xa}{\pizza@kk}pt\relax<#3pt \def\pizza@cls{0}\fi \ifdim\dimexpr\pizza@@{xb}{\pizza@kk}pt-#1pt\relax<#3pt \def\pizza@cls{0}\fi \ifdim\dimexpr#2pt-\pizza@@{ya}{\pizza@kk}pt\relax<#3pt \def\pizza@cls{0}\fi \ifdim\dimexpr\pizza@@{yb}{\pizza@kk}pt-#2pt\relax<#3pt \def\pizza@cls{0}\fi \fi \fi\fi\fi\fi} %% ================================================================== %% Eaten, pulled and separated pieces %% ================================================================== \def\pizza@setuppieces{% \pizza@resolve{\pizza@eaten}\pizza@eatset \pizza@resolve{\pizza@pull}\pizza@pullset \def\pizza@ordA{}\def\pizza@ordB{}\def\pizza@anypulled{0}% \ifnum\pizza@n=1 \def\pizza@sep{0}\else\let\pizza@sep\pizza@separate\fi \pizza@for\pizza@ck{1}{\pizza@n}{% \pizza@ifin{\the\pizza@ck}{\pizza@eatset}% {\pizza@set{eaten}{\the\pizza@ck}{1}}{\pizza@set{eaten}{\the\pizza@ck}{0}}% \pizza@ifin{\the\pizza@ck}{\pizza@pullset}{\def\pizza@pl{1}}{\def\pizza@pl{0}}% \edef\pizza@dir{\pizza@@{dir}{\the\pizza@ck}}% \ifpizza@grid \pgfmathsetmacro\pizza@tx{\pizza@sep*(\pizza@@{gi}{\the\pizza@ck}-(\pizza@nc-1)/2)+\pizza@pl*\pizza@pulld*cos(\pizza@dir)}% \pgfmathsetmacro\pizza@ty{\pizza@sep*((\pizza@nr-1)/2-\pizza@@{gj}{\the\pizza@ck})+\pizza@pl*\pizza@pulld*sin(\pizza@dir)}% \else \pgfmathsetmacro\pizza@tmpd{\pizza@sep+\pizza@pl*\pizza@pulld}% \pgfmathsetmacro\pizza@tx{\pizza@tmpd*cos(\pizza@dir)}% \pgfmathsetmacro\pizza@ty{\pizza@tmpd*sin(\pizza@dir)}% \fi \pizza@set{sx}{\the\pizza@ck}{\pizza@tx}\pizza@set{sy}{\the\pizza@ck}{\pizza@ty}% \ifnum\pizza@@{eaten}{\the\pizza@ck}=0 \ifnum\pizza@@{void}{\the\pizza@ck}=0 \ifnum\pizza@pl=1 \def\pizza@anypulled{1}% \ifx\pizza@ordB\pgfutil@empty\edef\pizza@ordB{\the\pizza@ck}% \else\edef\pizza@ordB{\pizza@ordB,\the\pizza@ck}\fi \else \ifx\pizza@ordA\pgfutil@empty\edef\pizza@ordA{\the\pizza@ck}% \else\edef\pizza@ordA{\pizza@ordA,\the\pizza@ck}\fi \fi \fi\fi}% \def\pizza@allpresent{}% \pizza@for\pizza@ck{1}{\pizza@n}{% \ifnum\pizza@@{eaten}{\the\pizza@ck}=0 \ifnum\pizza@@{void}{\the\pizza@ck}=0 \expandafter\let\expandafter\pizza@tmpp\csname pizza@pp@\the\pizza@ck\endcsname \edef\pizza@allpresent{\pizza@allpresent\space\pizza@tmpp}% \fi\fi}% % labels: one per piece, in order \pizza@ci=0 \@for\pizza@it:=\pizza@labels\do{% \advance\pizza@ci 1 \expandafter\let\csname pizza@lab@\the\pizza@ci\endcsname\pizza@it}% \edef\pizza@nlabels{\the\pizza@ci}} %% ================================================================== %% Sauce, cheese and the outlines they fill %% ================================================================== \def\pizza@unpackspread#1#2#3{\def\pizza@S@kind{#1}\def\pizza@S@on{#2}\def\pizza@S@color{#3}} \def\pizza@spreadlayer#1{% sauce|cheese: the colour of every piece \pizza@for\pizza@ck{1}{\pizza@n}{\pizza@set{p#1}{\the\pizza@ck}{none}}% \pizza@for\pizza@ci{1}{\the\csname pizza@n#1\endcsname}{% \expandafter\expandafter\expandafter\pizza@unpackspread \csname pizza@rec#1@\the\pizza@ci\endcsname \pizza@spreadcolor{#1}{\pizza@S@kind}{\pizza@S@on}{\pizza@S@color}% \pizza@resolve{\pizza@S@on}\pizza@onset \pizza@for\pizza@ck{1}{\pizza@n}{% \pizza@ifin{\the\pizza@ck}{\pizza@onset}{\pizza@set{p#1}{\the\pizza@ck}{\pizza@sc}}{}}}} \def\pizza@setupspreads{% \pizza@spreadlayer{sauce}\pizza@spreadlayer{cheese}% % the sauce, the melted cheese and the light on the crust, as smooth % curves through 48 points \edef\pizza@cheesein{\strip@pt\dimexpr\pizza@crustw pt+0.06pt\relax}% \edef\pizza@lightin{\strip@pt\dimexpr0.42\dimexpr\pizza@crustw pt\relax\relax}% \pizza@for\pizza@ci{0}{47}{% \edef\pizza@cc{\csname pizza@cos@\the\pizza@ci\endcsname}% \edef\pizza@cn{\csname pizza@sin@\the\pizza@ci\endcsname}% % sauce \pizza@frho{\pizza@cc}{\pizza@cn}{\pizza@crustw}% \pizza@ihash{\pizza@ci}{\pizza@seed+5}% \dimen@=\dimexpr\pizza@r pt+0.016pt*(\pizza@hC-498)/997\relax \pizza@set{spx}{\the\pizza@ci}{\the\dimexpr28.45274\dimexpr\pizza@cc\dimen@\relax\relax}% \pizza@set{spy}{\the\pizza@ci}{\the\dimexpr28.45274\dimexpr\pizza@cn\dimen@\relax\relax}% % cheese, bumpy where it melts towards the crust \pizza@frho{\pizza@cc}{\pizza@cn}{\pizza@cheesein}% \pizza@ihash{\pizza@ci+300}{\pizza@seed+5}% \ifodd\pizza@ci \dimen@i=0.065pt \else \dimen@i=0.025pt \fi \dimen@=\dimexpr\pizza@r pt-\dimen@i*\pizza@hC/997\relax \pizza@set{cpx}{\the\pizza@ci}{\the\dimexpr28.45274\dimexpr\pizza@cc\dimen@\relax\relax}% \pizza@set{cpy}{\the\pizza@ci}{\the\dimexpr28.45274\dimexpr\pizza@cn\dimen@\relax\relax}% % light on the crust \pizza@frho{\pizza@cc}{\pizza@cn}{\pizza@lightin}% \dimen@=\pizza@r pt \pizza@set{hpx}{\the\pizza@ci}{\the\dimexpr28.45274\dimexpr\pizza@cc\dimen@\relax\relax}% \pizza@set{hpy}{\the\pizza@ci}{\the\dimexpr28.45274\dimexpr\pizza@cn\dimen@\relax\relax}}% \pizza@smooth{sp}\pizza@smooth{cp}\pizza@smooth{hp}% \def\pizza@saucepath{\pgfextra{\pizza@Psp}}% \def\pizza@cheesepath{\pgfextra{\pizza@Pcp}}% \def\pizza@highlight{\pgfextra{\pizza@Php}}% % melted spots in the cheese \def\pizza@spotsL{}\def\pizza@spotsD{}% \pgfmathtruncatemacro\pizza@K{2.6*\pizza@barea}% \edef\pizza@ms{\strip@pt\dimexpr\pizza@crustw pt+0.17pt\relax}% \pizza@for\pizza@ci{1}{\pizza@K}{% \pizza@rtwo{\pizza@ci}{\pizza@seed+3001}% \pizza@isin{\pizza@px}{\pizza@py}{\pizza@ms}% \ifpizza@in \pizza@ihash{\pizza@ci}{\pizza@seed+3003}% \dimen@=\dimexpr0.035pt+0.045pt*\pizza@hC/997\relax \pizza@ihash{\pizza@ci}{\pizza@seed+3005}% \dimen@i=\dimexpr\dimen@*(550+300*\pizza@hC/997)/1000\relax \edef\pizza@tmpp{\noexpand\pgfpathellipse {\noexpand\pgfqpoint{\the\dimexpr28.45274\dimexpr\pizza@px pt\relax\relax}% {\the\dimexpr28.45274\dimexpr\pizza@py pt\relax\relax}}}% \ifnum\pizza@hC<620 \pizza@append{pizza@spotsL}{\unexpanded\expandafter{\pizza@tmpp}% {\noexpand\pgfqpoint{\the\dimexpr28.45274\dimen@\relax}{0pt}}% {\noexpand\pgfqpoint{0pt}{\the\dimexpr28.45274\dimen@i\relax}}}% \else \pizza@append{pizza@spotsD}{\unexpanded\expandafter{\pizza@tmpp}% {\noexpand\pgfqpoint{\the\dimexpr28.45274\dimen@i\relax}{0pt}}% {\noexpand\pgfqpoint{0pt}{\the\dimexpr22.76219\dimen@i\relax}}}% \fi \fi}% % baked flecks on the crust \def\pizza@specks{}% \pgfmathtruncatemacro\pizza@K{7*\pizza@barea}% \edef\pizza@ms{\strip@pt\dimexpr\pizza@crustw pt-0.07pt\relax}% \pizza@for\pizza@ci{1}{\pizza@K}{% \pizza@rtwo{\pizza@ci}{\pizza@seed+3011}% \pizza@isin{\pizza@px}{\pizza@py}{0.07}% \ifpizza@in \pizza@isin{\pizza@px}{\pizza@py}{\pizza@ms}% \ifpizza@in\else \pizza@ihash{\pizza@ci}{\pizza@seed+3013}% \pizza@append{pizza@specks}{\noexpand\pgfpathcircle {\noexpand\pgfqpoint{\the\dimexpr28.45274\dimexpr\pizza@px pt\relax\relax}% {\the\dimexpr28.45274\dimexpr\pizza@py pt\relax\relax}}% {\the\dimexpr28.45274\dimexpr0.012pt+0.022pt*\pizza@hC/997\relax\relax}}% \fi \fi}% \edef\pizza@spotsL{\noexpand\pgfextra{\unexpanded\expandafter{\pizza@spotsL}}}% \edef\pizza@spotsD{\noexpand\pgfextra{\unexpanded\expandafter{\pizza@spotsD}}}% \edef\pizza@specks{\noexpand\pgfextra{\unexpanded\expandafter{\pizza@specks}}}} %% ================================================================== %% Toppings %% In the default (density) mode, toppings are scattered evenly and may %% run over a cut, where the cut slices them like a real pizza. With %% count=, every chosen piece gets exactly n, whole and apart, so %% they can be counted. %% ================================================================== \newcount\pizza@acc \newcount\pizza@ti \newcount\pizza@fails \def\pizza@setuptoppings{% \pizza@for\pizza@cl{1}{\pizza@nlayers}{% \pizza@getlayer{\the\pizza@cl}% \pizza@resolve{\pizza@L@on}\pizza@onset \pgfmathsetmacro\pizza@ir{\csname pizza@topr@\pizza@L@type\endcsname*\pizza@L@size}% \pgfmathtruncatemacro\pizza@lseed{\pizza@seed*31+\the\pizza@cl*7+\pizza@L@seed}% \pizza@for\pizza@ck{1}{\pizza@n}{\pizza@set{it\the\pizza@cl}{\the\pizza@ck}{}}% \pgfmathsetmacro\pizza@ms{\pizza@crustw+0.55*\pizza@ir}% \ifx\pizza@L@count\pgfutil@empty \ifpizza@cutlines\pgfmathsetmacro\pizza@mc{0.3*\pizza@ir}\else\def\pizza@mc{0}\fi \pgfmathtruncatemacro\pizza@K{round(\pizza@L@density*\csname pizza@topd@\pizza@L@type\endcsname*\pizza@barea)}% \ifnum\pizza@K>0 \pizza@for\pizza@ci{1}{\pizza@K}{% \pizza@rtwo{\pizza@ci}{\pizza@lseed}% \pizza@classify{\pizza@px}{\pizza@py}{\pizza@mc}{\pizza@ms}% \ifnum\pizza@cls>0 \pizza@ifin{\pizza@cls}{\pizza@onset}{\pizza@additem{\pizza@cls}}{}% \fi}% \fi \else \pgfmathsetmacro\pizza@mc{\pizza@ir+0.03}% \pgfmathtruncatemacro\pizza@N{\pizza@L@count}% \pizza@for\pizza@ck{1}{\pizza@n}{% \pizza@ifin{\the\pizza@ck}{\pizza@onset}{% \ifnum\pizza@@{void}{\the\pizza@ck}=0 \pizza@placecount\fi}{}}% \fi}} \def\pizza@additem#1{% add the point \pizza@px,\pizza@py to piece #1 \pizza@rand{\pizza@ci*3+\pizza@ti}{\pizza@lseed+5}% \pgfmathsetmacro\pizza@rot{360*\pizza@h}% \pizza@rand{\pizza@ci*5+\pizza@ti}{\pizza@lseed+9}% \pgfmathsetmacro\pizza@sc{\pizza@L@size*(0.88+0.24*\pizza@h)}% \pizza@append{pizza@it\the\pizza@cl @#1}% {\noexpand\pizza@item{\pizza@px}{\pizza@py}{\pizza@rot}{\pizza@sc}}} \def\pizza@placecount{% \pizza@acc=0 \pizza@ti=0 \pizza@fails=0 \pizza@ci=0 \pgfmathsetmacro\pizza@dmin{2.15*\pizza@ir}\pizza@setdmin \def\pizza@accpts{}% \ifnum\pizza@N>0 \pizza@placeloop\fi \ifnum\pizza@acc<\pizza@N\relax \PackageWarning{tikzpizza}{Only \the\pizza@acc\space of \pizza@N\space \pizza@L@type\space fit on piece \the\pizza@ck\space without touching; try a smaller `size' or a bigger pizza}% \fi} \def\pizza@setdmin{% \count@=\numexpr\dimexpr\pizza@dmin pt\relax/64\relax \edef\pizza@dminsq{\the\numexpr\count@*\count@\relax}} \def\pizza@pt#1#2{% \ifnum\numexpr(\dimexpr#1pt-\pizza@px pt\relax/64)*(\dimexpr#1pt-\pizza@px pt\relax/64) +(\dimexpr#2pt-\pizza@py pt\relax/64)*(\dimexpr#2pt-\pizza@py pt\relax/64)\relax <\pizza@dminsq\relax \pizza@okfalse\fi} \def\pizza@placeloop{% \let\pizza@next\relax \ifnum\pizza@acc<\pizza@N\relax \ifnum\pizza@ti<1500\relax \advance\pizza@ti 1 \pizza@rtwo{\pizza@ti}{\pizza@lseed}% \pizza@classify{\pizza@px}{\pizza@py}{\pizza@mc}{\pizza@ms}% \ifnum\pizza@cls=\pizza@ck \pizza@oktrue \pizza@accpts \ifpizza@ok \advance\pizza@acc 1 \pizza@fails=0 \edef\pizza@accpts{\unexpanded\expandafter{\pizza@accpts}% \noexpand\pizza@pt{\pizza@px}{\pizza@py}}% \pizza@additem{\the\pizza@ck}% \else \advance\pizza@fails 1 \ifnum\pizza@fails>25 \pgfmathsetmacro\pizza@dmin{0.82*\pizza@dmin}\pizza@setdmin\pizza@fails=0 \fi \fi \fi \let\pizza@next\pizza@placeloop \fi\fi \pizza@next} \def\pizza@item#1#2#3#4{% \begin{scope}[shift={(#1,#2)}, rotate=#3, scale=#4]\pizza@itemdraw\end{scope}} %% ================================================================== %% Bites %% A bite is a ring of seven overlapping tooth marks, drawn as one %% scalloped outline so that bites can be cut out by clipping. %% ================================================================== \def\pizza@makecloud#1#2#3{% centre x, y, turn -> \pizza@cloud \pgfmathsetmacro\pizza@ra{0.45*\pizza@bitesize}% \pgfmathsetmacro\pizza@tx{(#1)+0.87705*\pizza@bitesize*cos((#3)-25.714)}% \pgfmathsetmacro\pizza@ty{(#2)+0.87705*\pizza@bitesize*sin((#3)-25.714)}% \edef\pizza@cloud{(\pizza@tx,\pizza@ty)}% \pizza@for\pizza@cr{0}{6}{% \pgfmathsetmacro\pizza@aA{(#3)+51.4286*\the\pizza@cr-57.74}% \pgfmathsetmacro\pizza@aB{\pizza@aA+115.48}% \edef\pizza@cloud{\pizza@cloud arc [start angle=\pizza@aA, end angle=\pizza@aB, radius=\pizza@ra]}}% \edef\pizza@cloud{\pizza@cloud -- cycle}} \def\pizza@setupbites{% \pizza@for\pizza@ck{1}{\pizza@n}{% \pizza@set{bl}{\the\pizza@ck}{}\pizza@set{bc}{\the\pizza@ck}{}\pizza@set{nb}{\the\pizza@ck}{0}}% \pgfmathtruncatemacro\pizza@NB{\pizza@bites}% \ifnum\pizza@NB>0 \pizza@resolve{\pizza@biteon}\pizza@bset \pizza@cm=0 \pizza@for\pizza@ck{1}{\pizza@n}{% \ifnum\pizza@@{eaten}{\the\pizza@ck}=0 \ifnum\pizza@@{void}{\the\pizza@ck}=0 \pizza@ifin{\the\pizza@ck}{\pizza@bset}{% \advance\pizza@cm 1 \pizza@set{el}{\the\pizza@cm}{\the\pizza@ck}}{}% \fi\fi}% \edef\pizza@ne{\the\pizza@cm}% \ifnum\pizza@ne>0 % share the bites out, spread evenly around the pizza \pizza@for\pizza@ci{0}{\pizza@NB-1}{% \ifnum\pizza@NB>\pizza@ne\relax \pgfmathtruncatemacro\pizza@tmpi{Mod(\the\pizza@ci,\pizza@ne)+1}% \else \pgfmathtruncatemacro\pizza@tmpi{floor(\the\pizza@ci*\pizza@ne/\pizza@NB)+1}% \fi \edef\pizza@kk{\pizza@@{el}{\pizza@tmpi}}% \pizza@set{nb}{\pizza@kk}{\the\numexpr\pizza@@{nb}{\pizza@kk}+1\relax}}% \pizza@for\pizza@ck{1}{\pizza@n}{% \ifnum\pizza@@{nb}{\the\pizza@ck}>0 \pizza@placebites\fi}% \fi \fi} \def\pizza@placebites{% \edef\pizza@m{\pizza@@{nb}{\the\pizza@ck}}% \edef\pizza@dir{\pizza@@{dir}{\the\pizza@ck}}% \pizza@for\pizza@cj{0}{\pizza@m-1}{% \ifpizza@grid % from the middle of the cell, out towards the crust \pgfmathsetmacro\pizza@ta{\pizza@dir+(\the\pizza@cj-(\pizza@m-1)/2)*32}% \edef\pizza@lx{\pizza@@{lx}{\the\pizza@ck}}\edef\pizza@ly{\pizza@@{ly}{\the\pizza@ck}}% \pizza@rayexit{\pizza@lx}{\pizza@ly}{\pizza@ta}% \let\pizza@tA\pizza@t \ifdim\pizza@ux pt>0.001pt \pgfmathsetmacro\pizza@tB{(\pizza@@{xb}{\the\pizza@ck}-(\pizza@lx))/\pizza@ux}% \else\ifdim\pizza@ux pt<-0.001pt \pgfmathsetmacro\pizza@tB{(\pizza@@{xa}{\the\pizza@ck}-(\pizza@lx))/\pizza@ux}% \else\def\pizza@tB{1000}\fi\fi \ifdim\pizza@uy pt>0.001pt \pgfmathsetmacro\pizza@tC{(\pizza@@{yb}{\the\pizza@ck}-(\pizza@ly))/\pizza@uy}% \else\ifdim\pizza@uy pt<-0.001pt \pgfmathsetmacro\pizza@tC{(\pizza@@{ya}{\the\pizza@ck}-(\pizza@ly))/\pizza@uy}% \else\def\pizza@tC{1000}\fi\fi \pgfmathsetmacro\pizza@tmpd{min(\pizza@tA,\pizza@tB,\pizza@tC)+0.15*\pizza@bitesize}% \pgfmathsetmacro\pizza@cx{\pizza@lx+\pizza@tmpd*\pizza@ux}% \pgfmathsetmacro\pizza@cy{\pizza@ly+\pizza@tmpd*\pizza@uy}% \else \ifnum\pizza@bitetip=1 \ifnum\pizza@n>1 \def\pizza@tipbite{1}\else\def\pizza@tipbite{0}\fi \else\def\pizza@tipbite{0}\fi \ifnum\pizza@tipbite=1 % from the point of the slice, working towards the crust \ifodd\pizza@cj\def\pizza@tmpw{-1}\else\def\pizza@tmpw{1}\fi \pgfmathsetmacro\pizza@tmpd{(0.18+0.8*\the\pizza@cj)*\pizza@bitesize}% \pgfmathsetmacro\pizza@cx{\pizza@hx+\pizza@tmpd*cos(\pizza@dir)-\pizza@tmpw*0.12*\pizza@bitesize*sin(\pizza@dir)}% \pgfmathsetmacro\pizza@cy{\pizza@hy+\pizza@tmpd*sin(\pizza@dir)+\pizza@tmpw*0.12*\pizza@bitesize*cos(\pizza@dir)}% \else % along the crust \pgfmathsetmacro\pizza@ta{\pizza@@{pa}{\the\pizza@ck}-\pizza@@{dpsi}{\the\pizza@ck}*(\the\pizza@cj+0.5)/\pizza@m}% \pizza@bpoint{\pizza@ta}% \pgfmathsetmacro\pizza@cx{\pizza@bx+0.15*\pizza@bitesize*cos(\pizza@ta)}% \pgfmathsetmacro\pizza@cy{\pizza@by+0.15*\pizza@bitesize*sin(\pizza@ta)}% \fi \fi \pizza@rand{\pizza@ck*13+\pizza@cj}{\pizza@seed+71}% \pgfmathsetmacro\pizza@tmpa{360*\pizza@h}% \pizza@makecloud{\pizza@cx}{\pizza@cy}{\pizza@tmpa}% \pizza@append{pizza@bl@\the\pizza@ck}{\noexpand\pizza@bite{\pizza@cloud}}% \pizza@append{pizza@bc@\the\pizza@ck}{\noexpand\pizza@bitec{\pizza@cx}{\pizza@cy}}}} %% ================================================================== %% Drawing %% ================================================================== \def\pizza@draw{% \expandafter\pizza@openscope\expandafter{\pizza@at}% \pizza@shadowonfalse \def\pizza@tmp{auto}% \ifx\pizza@shadow\pizza@tmp \ifpizza@tray\pizza@shadowontrue\fi \ifdim\pizza@sep pt>0pt \pizza@shadowontrue\fi \ifnum\pizza@anypulled=1 \pizza@shadowontrue\fi \else\def\pizza@tmp{true}\ifx\pizza@shadow\pizza@tmp\pizza@shadowontrue\fi\fi \ifpizza@tray \pizza@drawtray \pizza@drawcrumbs \fi \ifpizza@ghost \pizza@for\pizza@ck{1}{\pizza@n}{% \ifnum\pizza@@{eaten}{\the\pizza@ck}=1 \ifnum\pizza@@{void}{\the\pizza@ck}=0 \pizza@drawghost{\the\pizza@ck}\fi\fi}% \fi \let\pizza@list\pizza@ordA \pizza@drawgroup \let\pizza@list\pizza@ordB \pizza@drawgroup \pizza@drawlabels \end{scope}} \def\pizza@openscope#1{\begin{scope}[shift={#1}, scale=\pizza@scale, rotate=\pizza@rotate]} % Pieces that sit in the same place, with the same sauce and cheese and % no bites of their own, are drawn together, clipped to all of them at % once: group g has the pieces \pizza@gl@g (a list) and the outline % \pizza@gp@g. Toppings that run over a cut inside a group stay whole, % with the cut drawn across them, like on a real pizza. \newcount\pizza@gN \newcount\pizza@cg \def\pizza@makegroups{% \pizza@gN=0 \@for\pizza@k:=\pizza@list\do{% \edef\pizza@key{\pizza@@{sx}{\pizza@k}/\pizza@@{sy}{\pizza@k}/% \pizza@@{psauce}{\pizza@k}/\pizza@@{pcheese}{\pizza@k}}% \def\pizza@found{0}% \ifpizza@cutlines\ifnum\pizza@@{nb}{\pizza@k}>0 \def\pizza@found{-1}\fi\fi \ifnum\pizza@found=0 \pizza@for\pizza@cr{1}{\pizza@gN}{% \ifnum\pizza@found=0 \edef\pizza@tmpk{\pizza@@{gk}{\the\pizza@cr}}% \ifx\pizza@tmpk\pizza@key \edef\pizza@found{\the\pizza@cr}\fi \fi}% \fi \expandafter\let\expandafter\pizza@tmpp\csname pizza@pp@\pizza@k\endcsname \ifnum\pizza@found>0 \pizza@set{gl}{\pizza@found}{\pizza@@{gl}{\pizza@found},\pizza@k}% \pizza@set{gp}{\pizza@found}{\pizza@@{gp}{\pizza@found} \pizza@tmpp}% \else \advance\pizza@gN 1 \pizza@set{gl}{\the\pizza@gN}{\pizza@k}% \pizza@set{gp}{\the\pizza@gN}{\pizza@tmpp}% \ifnum\pizza@found=-1 \pizza@set{gk}{\the\pizza@gN}{bitten}% \else\pizza@set{gk}{\the\pizza@gN}{\pizza@key}\fi \fi}} \def\pizza@drawgroup{% \ifx\pizza@list\pgfutil@empty\else \pizza@makegroups \ifpizza@shadowon\pizza@for\pizza@cg{1}{\pizza@gN}{\pizza@drawshadow{\the\pizza@cg}}\fi \pizza@for\pizza@cg{1}{\pizza@gN}{\pizza@drawbase{\the\pizza@cg}}% \pizza@for\pizza@cg{1}{\pizza@gN}{\pizza@drawtops{\the\pizza@cg}}% \pizza@for\pizza@cg{1}{\pizza@gN}{\pizza@drawedges{\the\pizza@cg}}% \fi} \def\pizza@clipshape{\clip \pizza@roundpath;} \def\pizza@getpath#1{\expandafter\let\expandafter\pizza@pp\csname pizza@pp@#1\endcsname} \def\pizza@firstitem#1,#2\relax{#1} % open a group: move it with its pieces, and take its bites out \def\pizza@opengroup#1#2{% group, extra drop (for shadows) \edef\pizza@gfirst{\pizza@@{gl}{#1}}% \edef\pizza@gfirst{\expandafter\pizza@firstitem\pizza@gfirst,\relax}% \begin{scope}[shift={(\pizza@@{sx}{\pizza@gfirst}+#2,\pizza@@{sy}{\pizza@gfirst}-#2)}]% \expandafter\let\expandafter\pizza@pp\csname pizza@gp@#1\endcsname % everything but the bite: a big square clockwise around the % counter-clockwise bite outline (nonzero rule) \def\pizza@bite##1{\pizza@bigclip{(-90,-90) -- (-90,90) -- (90,90) -- (90,-90) -- cycle ##1}}% \pizza@thebites{\pizza@gfirst}} \def\pizza@closegroup{\end{scope}} % the bites of a piece; on a pizza whose cuts are hidden, every bite % cuts through everything \def\pizza@thebites#1{% \ifpizza@cutlines \csname pizza@bl@#1\endcsname \else \pizza@for\pizza@cr{1}{\pizza@n}{\csname pizza@bl@\the\pizza@cr\endcsname}\fi} \def\pizza@drawshadow#1{% \pizza@opengroup{#1}{0.07}% \begin{scope}\pizza@clipshape\fill[black, opacity=0.17] \pizza@pp;\end{scope}% \pizza@closegroup} \def\pizza@drawbase#1{% \pizza@opengroup{#1}{0}% \begin{scope} \pizza@clipshape \clip \pizza@pp; % crust \fill[pizza@c@crust] \pizza@roundpath; \draw[pizza@c@crustdark, opacity=0.4, line width=3.2*\pizza@lw] \pizza@roundpath; \fill[pizza@c@crustdark, opacity=0.45] \pizza@specks; \draw[pizza@c@crustlight, line width=2*\pizza@lw, opacity=0.85] \pizza@highlight; % sauce, or bare dough \edef\pizza@tmpc{\pizza@@{psauce}{\pizza@gfirst}}% \ifx\pizza@tmpc\pizza@none\colorlet{pizza@c@s}{pizza@c@dough}\else\colorlet{pizza@c@s}{\pizza@tmpc}\fi \fill[pizza@c@s] \pizza@saucepath; \draw[pizza@c@crustdark, opacity=0.6, line width=0.8*\pizza@lw] \pizza@saucepath; % cheese \edef\pizza@tmpc{\pizza@@{pcheese}{\pizza@gfirst}}% \ifx\pizza@tmpc\pizza@none\else \colorlet{pizza@c@c}{\pizza@tmpc}% \fill[pizza@c@c] \pizza@cheesepath; \begin{scope} \clip \pizza@cheesepath; \fill[pizza@c@c!50!white] \pizza@spotsL; \fill[pizza@c@c!75!orange!85!black, opacity=0.45] \pizza@spotsD; \end{scope} \draw[pizza@c@c!75!orange!80!black, opacity=0.55, line width=0.6*\pizza@lw] \pizza@cheesepath; \fi \end{scope} \pizza@closegroup} \def\pizza@drawtops#1{% % anything to draw? \def\pizza@tmpi{0}% \edef\pizza@glist{\csname pizza@gl@#1\endcsname}% \@for\pizza@kk:=\pizza@glist\do{% \pizza@for\pizza@cl{1}{\pizza@nlayers}{% \expandafter\ifx\csname pizza@it\the\pizza@cl @\pizza@kk\endcsname\pgfutil@empty \else\def\pizza@tmpi{1}\fi}}% \ifnum\pizza@tmpi=1 \pizza@drawtopsi{#1}\fi} \def\pizza@drawtopsi#1{% \pizza@opengroup{#1}{0}% \begin{scope} \pizza@clipshape \ifpizza@cutlines % each piece's toppings are cut off at its own cuts \@for\pizza@kk:=\pizza@glist\do{% \begin{scope} \expandafter\let\expandafter\pizza@tmpp\csname pizza@pp@\pizza@kk\endcsname \clip \pizza@tmpp; \pizza@toppingsof{\pizza@kk}% \end{scope}}% \else % the cuts are hidden, so toppings run across them \ifdim\pizza@@{sx}{\pizza@gfirst}pt=0pt \ifdim\pizza@@{sy}{\pizza@gfirst}pt=0pt \clip \pizza@allpresent;\else\clip \pizza@pp;\fi\else\clip \pizza@pp;\fi \@for\pizza@kk:=\pizza@glist\do{\pizza@toppingsof{\pizza@kk}}% \fi \end{scope} \pizza@closegroup} \def\pizza@toppingsof#1{% all toppings of piece #1, layer by layer \pizza@for\pizza@cl{1}{\pizza@nlayers}{% \expandafter\ifx\csname pizza@it\the\pizza@cl @#1\endcsname\pgfutil@empty\else \pizza@getlayer{\the\pizza@cl}% \ifx\pizza@L@color\pgfutil@empty \colorlet{pizzatopping}{\csname pizza@topc@\pizza@L@type\endcsname}% \else\colorlet{pizzatopping}{\pizza@L@color}\fi \expandafter\let\expandafter\pizza@itemdraw\csname pizza@top@\pizza@L@type\endcsname \csname pizza@it\the\pizza@cl @#1\endcsname \fi}} \def\pizza@drawedges#1{% \pizza@opengroup{#1}{0}% % the bitten edges show the bread \begin{scope} \pizza@clipshape \clip \pizza@pp; \def\pizza@bite##1{% \draw[pizza@c@crustlight, line width=3.6*\pizza@lw] ##1;% \draw[pizza@c@line, line width=0.9*\pizza@lw] ##1;}% \pizza@thebites{\pizza@gfirst}% \end{scope} % the crust's edge, then the cuts \begin{scope}\clip \pizza@pp; \draw[pizza@c@line, line width=2*\pizza@lw] \pizza@roundpath;\end{scope} \ifpizza@cutlines \begin{scope}\pizza@clipshape \draw[pizza@c@line, line width=0.85*\pizza@lw, line join=round] \pizza@pp;\end{scope} \fi \pizza@closegroup} \def\pizza@drawghost#1{% \begin{scope}[shift={(\pizza@@{sx}{#1},\pizza@@{sy}{#1})}] \pizza@getpath{#1}% \begin{scope}\pizza@clipshape \draw[pizza ghost, line width=0.85*\pizza@lw, dash pattern=on \pizza@dA off \pizza@dB] \pizza@pp; \end{scope} \begin{scope}\clip \pizza@pp; \draw[pizza ghost, line width=1.7*\pizza@lw, dash pattern=on \pizza@dA off \pizza@dB] \pizza@roundpath; \end{scope} \end{scope}} \def\pizza@drawlabels{% \pizza@for\pizza@ck{1}{\pizza@n}{% \ifnum\pizza@@{void}{\the\pizza@ck}=0 \expandafter\ifx\csname pizza@nolabel@\the\pizza@ck\endcsname\relax \let\pizza@labtext\relax \ifpizza@numbers\edef\pizza@labtext{\the\pizza@ck}\fi \ifnum\pizza@ck>\pizza@nlabels\relax\else \expandafter\let\expandafter\pizza@labtext\csname pizza@lab@\the\pizza@ck\endcsname \fi \ifx\pizza@labtext\pgfutil@empty\let\pizza@labtext\relax\fi \ifx\pizza@labtext\relax\else \node[pizza label] at (\pizza@@{lx}{\the\pizza@ck}+\pizza@@{sx}{\the\pizza@ck}, \pizza@@{ly}{\the\pizza@ck}+\pizza@@{sy}{\the\pizza@ck}) {\pizza@labtext}; \fi \fi\fi}} %% ------------------------------------------------------------------ %% The tray and what is left on it %% ------------------------------------------------------------------ \def\pizza@drawtray{% \pgfmathsetmacro\pizza@tm{0.42+\pizza@sep}% \def\pizza@tmp{auto}% \ifx\pizza@traytype\pizza@tmp \def\pizza@traytype{round}% \ifnum\pizza@shape=2 \def\pizza@traytype{sheet}\fi \ifnum\pizza@kind=1 \ifnum\pizza@nv=4 \def\pizza@traytype{sheet}\fi\fi \fi \ifcsname pizza@tray@\pizza@traytype\endcsname \csname pizza@tray@\pizza@traytype\endcsname \else \PackageError{tikzpizza}{Unknown tray `\pizza@traytype'}{Trays: round, sheet, board.}% \fi} \def\pizza@tray@round{% \pgfmathsetmacro\pizza@TR{\pizza@outR+\pizza@tm}% \fill[pizza@c@tray!72!black] (0,0) circle [radius=\pizza@TR]; \fill[pizza@c@tray] (0,0) circle [radius=\pizza@TR-0.13]; \draw[pizza@c@tray!65!black, opacity=0.6, line width=0.8*\pizza@lw] (0,0) circle [radius=\pizza@TR-0.13]; \draw[white, opacity=0.65, line width=2.6*\pizza@lw, line cap=round] (125:\pizza@TR-0.065) arc [start angle=125, end angle=168, radius=\pizza@TR-0.065]; \draw[white, opacity=0.4, line width=2*\pizza@lw, line cap=round] (-58:\pizza@TR-0.065) arc [start angle=-58, end angle=-38, radius=\pizza@TR-0.065]; \draw[pizza@c@tray!45!black, line width=\pizza@lw] (0,0) circle [radius=\pizza@TR];} \def\pizza@tray@sheet{% \pgfmathsetmacro\pizza@xa{\pizza@minx-\pizza@tm}\pgfmathsetmacro\pizza@xb{\pizza@maxx+\pizza@tm}% \pgfmathsetmacro\pizza@ya{\pizza@miny-\pizza@tm}\pgfmathsetmacro\pizza@yb{\pizza@maxy+\pizza@tm}% \pgfmathsetlengthmacro\pizza@tmpd{7pt*\pizza@scale}% \fill[pizza@c@tray!72!black, rounded corners=\pizza@tmpd] (\pizza@xa,\pizza@ya) rectangle (\pizza@xb,\pizza@yb); \pgfmathsetlengthmacro\pizza@tmpd{4.5pt*\pizza@scale}% \fill[pizza@c@tray, rounded corners=\pizza@tmpd] (\pizza@xa+0.13,\pizza@ya+0.13) rectangle (\pizza@xb-0.13,\pizza@yb-0.13); \draw[pizza@c@tray!65!black, opacity=0.6, line width=0.8*\pizza@lw, rounded corners=\pizza@tmpd] (\pizza@xa+0.13,\pizza@ya+0.13) rectangle (\pizza@xb-0.13,\pizza@yb-0.13); \draw[white, opacity=0.65, line width=2.6*\pizza@lw, line cap=round] (\pizza@xa+0.065,\pizza@yb-0.5) -- (\pizza@xa+0.065,\pizza@ya+0.6); \pgfmathsetlengthmacro\pizza@tmpd{7pt*\pizza@scale}% \draw[pizza@c@tray!45!black, line width=\pizza@lw, rounded corners=\pizza@tmpd] (\pizza@xa,\pizza@ya) rectangle (\pizza@xb,\pizza@yb);} \def\pizza@tray@board{% \colorlet{pizza@c@wood}{pizzaboard}% \ifnum\pizza@kind=0 \def\pizza@tmpw{0}\else\ifnum\pizza@nv=4 \def\pizza@tmpw{1}\else \ifnum\pizza@shape=2 \def\pizza@tmpw{1}\else\def\pizza@tmpw{0}\fi\fi\fi \ifnum\pizza@tmpw=0 \pgfmathsetmacro\pizza@TR{\pizza@outR+\pizza@tm}% \pgfmathsetmacro\pizza@xb{\pizza@TR}\def\pizza@ya{0}% \edef\pizza@boardpath{(0,0) circle [radius=\pizza@TR]}% \else \pgfmathsetmacro\pizza@xa{\pizza@minx-\pizza@tm}\pgfmathsetmacro\pizza@xb{\pizza@maxx+\pizza@tm}% \pgfmathsetmacro\pizza@ya{\pizza@miny-\pizza@tm}\pgfmathsetmacro\pizza@yb{\pizza@maxy+\pizza@tm}% \pgfmathsetlengthmacro\pizza@tmpd{9pt*\pizza@scale}% \edef\pizza@boardpath{[rounded corners=\pizza@tmpd] (\pizza@xa,\pizza@ya) rectangle (\pizza@xb,\pizza@yb)}% \def\pizza@ya{0}% \fi % the handle \pgfmathsetlengthmacro\pizza@tmpd{5pt*\pizza@scale}% \filldraw[fill=pizza@c@wood, draw=pizza@c@wood!45!black, line width=\pizza@lw, rounded corners=\pizza@tmpd] (\pizza@xb-0.3,-0.3) rectangle (\pizza@xb+1.0,0.3); \filldraw[fill=white, draw=pizza@c@wood!45!black, line width=\pizza@lw] (\pizza@xb+0.68,0) circle [radius=0.1]; % the board, with its grain \fill[pizza@c@wood] \pizza@boardpath; \begin{scope} \clip \pizza@boardpath; \pizza@for\pizza@ci{0}{14}{% \pgfmathsetmacro\pizza@ty{\pizza@miny-0.6+\the\pizza@ci*(\pizza@bh+1.2)/14}% \pizza@rand{\pizza@ci}{\pizza@seed+211}% \draw[pizza@c@wood!75!black, opacity=0.35, line width=0.7*\pizza@lw] (\pizza@minx-1,\pizza@ty) .. controls (\pizza@minx+0.6*\pizza@bw*\pizza@h,\pizza@ty+0.25) and (\pizza@maxx-0.5,\pizza@ty-0.2) .. (\pizza@maxx+1.4,\pizza@ty+0.05);}% \end{scope} \draw[pizza@c@wood!45!black, line width=\pizza@lw] \pizza@boardpath;} % Crumbs are gathered into three paths, one per colour, written as pgf % path commands. #1 and #2 are the centre as dimension expressions % (cm written as pt). \def\pizza@cv#1#2{\noexpand\pgfqpoint {\the\dimexpr28.45274\dimexpr\pizza@cxx+#1\dimen@-#2\dimen@i\relax\relax}% {\the\dimexpr28.45274\dimexpr\pizza@cyy+#1\dimen@i+#2\dimen@\relax\relax}} \def\pizza@crumb#1#2#3{% x, y, number \edef\pizza@cxx{\the\dimexpr#1\relax}\edef\pizza@cyy{\the\dimexpr#2\relax}% \pizza@ihash{#3}{\pizza@seed+31}% \edef\pizza@cs{\strip@pt\dimexpr0.022pt+0.04pt*\pizza@hC/997\relax}% \pizza@ihash{#3}{\pizza@seed+37}\count@=\pizza@hC \pizza@modN{12}% \dimen@=\pizza@cs\dimexpr\csname pizza@ccos@\the\count@\endcsname pt\relax \dimen@i=\pizza@cs\dimexpr\csname pizza@csin@\the\count@\endcsname pt\relax \pizza@ihash{#3}{\pizza@seed+41}\count@=\pizza@hC \pizza@modN{3}% \edef\pizza@tmpp{\noexpand\pgfpathmoveto{\pizza@cv{1}{0}}% \noexpand\pgfpathlineto{\pizza@cv{0.207}{0.773}}\noexpand\pgfpathlineto{\pizza@cv{-0.953}{0.55}}% \noexpand\pgfpathlineto{\pizza@cv{-0.536}{-0.45}}\noexpand\pgfpathlineto{\pizza@cv{0.325}{-0.893}}% \noexpand\pgfpathclose}% \pizza@append{pizza@crumbs\the\count@}{\unexpanded\expandafter{\pizza@tmpp}}} \def\pizza@flushcrumbs{% \pizza@for\pizza@cr{0}{2}{% \ifcase\pizza@cr \colorlet{pizza@c@k}{pizza@c@crust}% \or\colorlet{pizza@c@k}{pizza@c@crustdark}\else\colorlet{pizza@c@k}{pizza@c@crustlight}\fi \expandafter\ifx\csname pizza@crumbs\the\pizza@cr\endcsname\pgfutil@empty\else \filldraw[fill=pizza@c@k, draw=pizza@c@k!70!black, line width=0.25*\pizza@lw, line join=round] \pgfextra{\csname pizza@crumbs\the\pizza@cr\endcsname}; \fi}} \def\pizza@drawcrumbs{% % where pieces were taken: grease, a smear of sauce, and crumbs \pizza@for\pizza@ck{1}{\pizza@n}{% \ifnum\pizza@@{eaten}{\the\pizza@ck}=1 \ifnum\pizza@@{void}{\the\pizza@ck}=0 \pgfmathsetmacro\pizza@tx{\pizza@@{lx}{\the\pizza@ck}+\pizza@@{sx}{\the\pizza@ck}}% \pgfmathsetmacro\pizza@ty{\pizza@@{ly}{\the\pizza@ck}+\pizza@@{sy}{\the\pizza@ck}}% \pizza@rand{\the\pizza@ck}{\pizza@seed+51}\pgfmathsetmacro\pizza@ta{360*\pizza@h}% \fill[orange!60!pizza@c@crust, opacity=0.16, shift={(\pizza@tx,\pizza@ty)}, rotate=\pizza@ta] (0.1,0.05) ellipse [x radius=0.3, y radius=0.17]; \edef\pizza@tmpc{\pizza@@{psauce}{\the\pizza@ck}}% \ifx\pizza@tmpc\pizza@none\else \fill[\pizza@tmpc, opacity=0.2, shift={(\pizza@tx,\pizza@ty)}, rotate=\pizza@ta+70] (-0.12,-0.02) ellipse [x radius=0.16, y radius=0.07]; \fi \fi\fi}% \expandafter\def\csname pizza@crumbs0\endcsname{}% \expandafter\def\csname pizza@crumbs1\endcsname{}% \expandafter\def\csname pizza@crumbs2\endcsname{}% \pgfmathtruncatemacro\pizza@K{\pizza@crumbs*9*\pizza@barea}% \ifnum\pizza@K>0 \pizza@for\pizza@ci{1}{\pizza@K}{% \pizza@rtwo{\pizza@ci}{\pizza@seed+977}% \pizza@classify{\pizza@px}{\pizza@py}{0}{-0.04}% \ifnum\pizza@cls>0 \ifnum\pizza@@{eaten}{\pizza@cls}=1 \pizza@crumb{\pizza@px pt+\pizza@@{sx}{\pizza@cls}pt}{\pizza@py pt+\pizza@@{sy}{\pizza@cls}pt}{\the\pizza@ci}% \fi\fi}% % and a few round every bite \pgfmathtruncatemacro\pizza@K{max(1,round(5*\pizza@crumbs))}% \def\pizza@bitec##1##2{% \pizza@for\pizza@cj{1}{\pizza@K}{% \pizza@ihash{\pizza@ck*29+\pizza@cj}{\pizza@seed+61}\count@=\pizza@hC \pizza@modN{48}% \edef\pizza@cc{\csname pizza@cos@\the\count@\endcsname}\edef\pizza@cn{\csname pizza@sin@\the\count@\endcsname}% \pizza@ihash{\pizza@ck*31+\pizza@cj}{\pizza@seed+67}% \dimen@=\dimexpr\pizza@bitesize pt*(150+950*\pizza@hC/997)/1000\relax \pizza@crumb{##1pt+\pizza@@{sx}{\the\pizza@ck}pt+\pizza@cc\dimen@}% {##2pt+\pizza@@{sy}{\the\pizza@ck}pt+\pizza@cn\dimen@}{\pizza@ck*37+\pizza@cj}}}% \pizza@for\pizza@ck{1}{\pizza@n}{\csname pizza@bc@\the\pizza@ck\endcsname}% \pizza@flushcrumbs \fi} %% ================================================================== %% The toppings %% Each is drawn around (0,0) at its natural size in cm, in the colour %% `pizzatopping'; \pizzalw is a thin line width that follows `scale'. %% \pizzanewtopping{name}{radius}{density}{colour}{drawing}: the radius %% keeps toppings off the crust and the cuts, and the density is how %% many go on each square centimetre at density=1. %% ================================================================== \pizzanewtopping{pepperoni}{0.21}{2.6}{pizzapepperoni}{% \fill[pizzatopping!65!black] (0.012,-0.02) circle [radius=0.205]; \fill[pizzatopping] (0,0) circle [radius=0.2]; \fill[pizzatopping!72!white] (0.06,0.07) circle [radius=0.028] (-0.08,0.03) circle [radius=0.022] (-0.02,-0.09) circle [radius=0.026] (0.1,-0.05) circle [radius=0.018] (-0.07,-0.06) circle [radius=0.014]; \fill[pizzatopping!78!black] (0.02,0.125) circle [radius=0.017] (0.125,0.04) circle [radius=0.013] (-0.11,0.1) circle [radius=0.013] (0.04,-0.03) circle [radius=0.012]; \draw[white, opacity=0.5, line width=1.4*\pizzalw, line cap=round] (160:0.15) arc [start angle=160, end angle=115, radius=0.15]; \draw[pizzatopping!50!black, line width=\pizzalw] (0,0) circle [radius=0.2];} \pizzanewtopping{mushroom}{0.2}{2.4}{pizzamushroom}{% \def\pizza@mush{(-0.055,-0.17) -- (-0.065,-0.01) -- (-0.19,-0.01) .. controls (-0.2,0.11) and (-0.11,0.17) .. (0,0.17) .. controls (0.11,0.17) and (0.2,0.11) .. (0.19,-0.01) -- (0.065,-0.01) -- (0.055,-0.17) .. controls (0.02,-0.19) and (-0.02,-0.19) .. cycle}% \fill[pizzatopping] \pizza@mush; \fill[pizzatopping!60!black, opacity=0.55] (-0.18,-0.01) -- (0.18,-0.01) -- (0.17,0.035) .. controls (0.06,0.05) and (-0.06,0.05) .. (-0.17,0.035) -- cycle; \fill[pizzatopping!82!black] (0.02,-0.01) -- (0.064,-0.01) -- (0.055,-0.165) -- (0.02,-0.178) -- cycle; \draw[white, opacity=0.6, line width=1.6*\pizzalw, line cap=round] (-0.12,0.105) .. controls (-0.05,0.145) .. (0.04,0.148); \draw[pizzatopping!40!black, line width=\pizzalw, line join=round] \pizza@mush;} \pizzanewtopping{olive}{0.1}{4}{pizzaolive}{% \fill[pizzatopping, even odd rule] (0,0) circle [radius=0.1] (0.006,0.004) circle [radius=0.042]; \draw[white, opacity=0.5, line width=1.2*\pizzalw, line cap=round] (125:0.074) arc [start angle=125, end angle=185, radius=0.074]; \draw[black, line width=0.8*\pizzalw] (0,0) circle [radius=0.1] (0.006,0.004) circle [radius=0.042];} \pizzanewtopping{greenpepper}{0.2}{2.4}{pizzagreenpepper}{% \def\pizza@strip{(-0.19,-0.06) .. controls (-0.12,0.12) and (0.12,0.12) .. (0.19,-0.06) -- (0.145,-0.085) .. controls (0.085,0.045) and (-0.085,0.045) .. (-0.145,-0.085) -- cycle}% \fill[pizzatopping] \pizza@strip; \draw[pizzatopping!45!white, line width=1.3*\pizzalw, line cap=round] (-0.135,-0.055) .. controls (-0.08,0.055) and (0.08,0.055) .. (0.135,-0.055); \draw[white, opacity=0.5, line width=1.2*\pizzalw, line cap=round] (-0.12,0.03) .. controls (-0.06,0.085) .. (0.02,0.09); \draw[pizzatopping!45!black, line width=\pizzalw, line join=round] \pizza@strip;} \pgfkeys{/pizza/pepper/.code={\pizza@addlayer{greenpepper}{#1}}, /pizza/pepper/.default={}} \def\pizza@ringseg#1#2#3#4{(#3:#1) arc [start angle=#3, end angle=#4, radius=#1] -- (#4:#2) arc [start angle=#4, end angle=#3, radius=#2] -- cycle} \pizzanewtopping{onion}{0.2}{2.2}{pizzaonion}{% \filldraw[fill=pizzatopping!22!white, draw=pizzatopping!60!black, line width=0.8*\pizzalw, line join=round] \pizza@ringseg{0.2}{0.155}{25}{165} \pizza@ringseg{0.125}{0.085}{40}{150}; \fill[pizzatopping] \pizza@ringseg{0.2}{0.18}{25}{165} \pizza@ringseg{0.125}{0.107}{40}{150}; \draw[pizzatopping!60!black, line width=0.8*\pizzalw, line join=round] \pizza@ringseg{0.2}{0.155}{25}{165} \pizza@ringseg{0.125}{0.085}{40}{150};} \pizzanewtopping{ham}{0.16}{3}{pizzaham}{% \filldraw[fill=pizzatopping, draw=pizzatopping!50!black, line width=\pizzalw, line join=round] (-0.12,-0.11) -- (0.115,-0.125) -- (0.13,0.105) -- (-0.11,0.12) -- cycle; \draw[white, opacity=0.65, line width=1.5*\pizzalw, line cap=round] (-0.08,0.065) .. controls (-0.02,0.0) and (0.04,0.05) .. (0.085,-0.035); \draw[pizzatopping!75!black, opacity=0.7, line width=1.2*\pizzalw] (-0.105,-0.095) -- (0.1,-0.108);} \pizzanewtopping{pineapple}{0.14}{3.2}{pizzapineapple}{% \filldraw[fill=pizzatopping, draw=pizzatopping!45!orange!80!black, line width=\pizzalw, line join=round] (-0.13,-0.08) -- (0.13,-0.08) -- (0.09,0.1) -- (-0.09,0.1) -- cycle; \draw[orange!70!pizzatopping, opacity=0.6, line width=0.7*\pizzalw] (-0.065,-0.065) -- (-0.045,0.085) (0,-0.065) -- (0,0.085) (0.065,-0.065) -- (0.045,0.085); \draw[pizzatopping!50!orange, line width=1.6*\pizzalw, line cap=round] (-0.085,0.093) -- (0.085,0.093);} \pizzanewtopping{sausage}{0.1}{5}{pizzasausage}{% \filldraw[fill=pizzatopping, draw=pizzatopping!50!black, line width=\pizzalw, line join=round] plot[smooth cycle, tension=0.7] coordinates {(-0.09,-0.02) (-0.05,-0.08) (0.03,-0.09) (0.09,-0.03) (0.08,0.05) (0.02,0.09) (-0.06,0.07)}; \fill[pizzatopping!60!black] (0.02,0.02) circle [radius=0.013] (-0.03,-0.03) circle [radius=0.011] (0.05,-0.04) circle [radius=0.01]; \fill[white, opacity=0.35] (-0.035,0.04) circle [radius=0.02];} \pizzanewtopping{tomato}{0.26}{1.4}{pizzatomatoslice}{% \filldraw[fill=pizzatopping, draw=pizzatopping!50!black, line width=\pizzalw] (0,0) circle [radius=0.25]; \fill[pizzatopping!80!white] (0,0) circle [radius=0.19]; \foreach \pizza@a in {30,150,270}{% \fill[pizzatopping!55!white, rotate=\pizza@a] (0.105,0) ellipse [x radius=0.07, y radius=0.058]; \fill[pizzaseed, rotate=\pizza@a] (0.09,0.02) ellipse [x radius=0.016, y radius=0.01] (0.12,-0.015) ellipse [x radius=0.016, y radius=0.01] (0.08,-0.025) ellipse [x radius=0.014, y radius=0.009];} \fill[pizzatopping!88!white] (0,0) circle [radius=0.04]; \draw[white, opacity=0.45, line width=1.4*\pizzalw, line cap=round] (150:0.22) arc [start angle=150, end angle=110, radius=0.22];} \pizzanewtopping{basil}{0.2}{1.8}{pizzabasil}{% \def\pizza@leaf{(-0.19,0) .. controls (-0.1,0.13) and (0.08,0.12) .. (0.19,0.0) .. controls (0.08,-0.1) and (-0.1,-0.12) .. (-0.19,0) -- cycle}% \fill[pizzatopping] \pizza@leaf; \fill[pizzatopping!70!black, opacity=0.35] (-0.19,0) .. controls (-0.05,0.0) .. (0.19,0.0) .. controls (0.08,-0.1) and (-0.1,-0.12) .. (-0.19,0) -- cycle; \draw[pizzatopping!45!white, line width=0.8*\pizzalw, line cap=round] (-0.17,0) .. controls (-0.02,0.01) .. (0.16,0.0) (-0.07,0.005) -- (-0.02,0.06) (0.02,0.005) -- (0.07,0.05) (-0.05,0.002) -- (0.0,-0.05); \draw[pizzatopping!45!black, line width=\pizzalw, line join=round] \pizza@leaf;} \pizzanewtopping{jalapeno}{0.12}{3.5}{pizzajalapeno}{% \fill[pizzatopping, even odd rule] (0,0) circle [radius=0.12] (0,0) circle [radius=0.085]; \fill[pizzatopping!35!white, even odd rule] (0,0) circle [radius=0.085] (0,0) circle [radius=0.03]; \fill[pizzaseed] (0.05,0.02) ellipse [x radius=0.018, y radius=0.011] (-0.04,0.04) ellipse [x radius=0.011, y radius=0.018] (-0.02,-0.05) ellipse [x radius=0.018, y radius=0.011]; \draw[pizzatopping!45!black, line width=\pizzalw] (0,0) circle [radius=0.12] (0,0) circle [radius=0.03];} % a cooked shrimp, curled into a C, with its tail fan tucked in \def\pizza@shrimpbody{(-40:0.18) arc [start angle=-40, end angle=215, radius=0.18] -- (215:0.085) arc [start angle=215, end angle=-40, radius=0.085] arc [start angle=140, end angle=320, radius=0.0475] -- cycle} \pizzanewtopping{shrimp}{0.2}{2}{pizzashrimp}{% \foreach \pizza@a in {290,335}{% \filldraw[fill=pizzatopping!75!red, draw=pizzatopping!45!black, line width=0.7*\pizzalw, shift={(215:0.13)}, rotate=\pizza@a] (0.05,0) ellipse [x radius=0.058, y radius=0.03];} \fill[pizzatopping] \pizza@shrimpbody; \begin{scope} \clip \pizza@shrimpbody; % the red back and the pale belly \fill[pizzatopping!72!red!92!black] (-40:0.2) arc [start angle=-40, end angle=215, radius=0.2] -- (215:0.152) arc [start angle=215, end angle=-40, radius=0.152] -- cycle; \fill[pizzatopping!45!white] (-40:0.106) arc [start angle=-40, end angle=215, radius=0.106] -- (215:0.06) arc [start angle=215, end angle=-40, radius=0.06] -- cycle; % the joints between its segments \draw[white, opacity=0.6, line width=1.2*\pizzalw] \foreach \pizza@a in {20,65,110,155,195}{(\pizza@a:0.09) -- (\pizza@a:0.19)}; \draw[white, opacity=0.55, line width=1.4*\pizzalw, line cap=round] (125:0.133) arc [start angle=125, end angle=70, radius=0.133]; \end{scope} \draw[pizzatopping!45!black, line width=\pizzalw, line join=round] \pizza@shrimpbody;} % a wilted spinach leaf on its stalk \def\pizza@spinachleaf{(-0.13,0.0) .. controls (-0.13,0.09) and (-0.06,0.15) .. (0.02,0.15) .. controls (0.08,0.16) and (0.1,0.12) .. (0.14,0.12) .. controls (0.2,0.1) and (0.22,0.03) .. (0.2,-0.02) .. controls (0.21,-0.08) and (0.15,-0.13) .. (0.08,-0.12) .. controls (0.02,-0.14) and (-0.06,-0.12) .. (-0.1,-0.07) .. controls (-0.12,-0.05) and (-0.13,-0.03) .. (-0.13,0.0) -- cycle} \pizzanewtopping{spinach}{0.2}{1.7}{pizzaspinach}{% \draw[pizzatopping!45!black, line width=2.6*\pizzalw, line cap=round] (-0.12,0) -- (-0.22,-0.035); \draw[pizzatopping!55!white, line width=1.4*\pizzalw, line cap=round] (-0.12,0) -- (-0.22,-0.035); \fill[pizzatopping] \pizza@spinachleaf; \begin{scope} \clip \pizza@spinachleaf; \fill[pizzatopping!65!black, opacity=0.45] (-0.2,0.0) .. controls (0.0,0.02) .. (0.25,0.0) -- (0.25,-0.2) -- (-0.2,-0.2) -- cycle; \draw[pizzatopping!80!black, opacity=0.6, line width=0.9*\pizzalw, line cap=round] (0.13,0.1) .. controls (0.15,0.07) .. (0.17,0.08) (0.05,-0.09) .. controls (0.08,-0.07) .. (0.11,-0.09); \end{scope} \draw[pizzatopping!40!white, line width=0.9*\pizzalw, line cap=round] (-0.12,0) .. controls (0.0,0.012) .. (0.17,0.0) (-0.04,0.006) .. controls (-0.01,0.05) .. (0.0,0.11) (0.06,0.007) .. controls (0.09,0.05) .. (0.11,0.09) (-0.03,0.004) .. controls (0.0,-0.04) .. (0.02,-0.08) (0.08,0.004) .. controls (0.11,-0.03) .. (0.13,-0.07); \draw[white, opacity=0.35, line width=1.2*\pizzalw, line cap=round] (-0.08,0.08) .. controls (-0.04,0.12) .. (0.02,0.13); \draw[pizzatopping!40!black, line width=\pizzalw, line join=round] \pizza@spinachleaf;} % a round of fresh mozzarella, melting softly at its edge \def\pizza@mozzround{plot[smooth cycle, tension=0.8] coordinates {(0.22,0.01) (0.15,0.16) (0.0,0.21) (-0.16,0.15) (-0.22,0.0) (-0.15,-0.16) (0.01,-0.215) (0.16,-0.15)}} \pizzanewtopping{mozzarella}{0.24}{1.15}{pizzamozzslice}{% \fill[pizzatopping!85!pizzamozzarella, opacity=0.72] plot[smooth cycle, tension=0.8] coordinates {(0.27,0.02) (0.19,0.2) (0.0,0.27) (-0.2,0.19) (-0.28,-0.01) (-0.18,-0.21) (0.02,-0.27) (0.21,-0.18)}; \fill[pizzatopping] \pizza@mozzround; \begin{scope} \clip \pizza@mozzround; \fill[pizzatopping!82!orange!88!black, opacity=0.3, even odd rule] (-1,-1) rectangle (1,1) (-0.035,0.035) circle [radius=0.205]; \end{scope} \fill[white, rotate=25] (-0.06,0.1) ellipse [x radius=0.065, y radius=0.026]; \fill[white, opacity=0.8] (0.06,0.13) circle [radius=0.012]; \draw[pizzatopping!80!orange!75!black, line width=0.7*\pizzalw] \pizza@mozzround;} \pgfkeys{/pizza/fancy mozzarella/.code={\pizza@addlayer{mozzarella}{#1}}, /pizza/fancy mozzarella/.default={}, /pizza/fresh mozzarella/.code={\pizza@addlayer{mozzarella}{#1}}, /pizza/fresh mozzarella/.default={}} \endinput