3

I am trying to draw a diagram showing the action of soap on grease and dirt. Currently I have the following diagram:

enter image description here

I would like the shapes that surround the large orange-yellow blobs to be the same as the shapes that are free and not bound. The code is as follows:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[left=0.00cm, right=0.00cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.pathreplacing,fadings}
\newcommand{\lipid}[3]{
    \begin{scope}[xshift=#1cm,yshift=#2cm,rotate=#3]
        \shadedraw[shading=radial,inner color=purple!40,outer color=purple!60!black] (0,0) circle (2.5pt);
        \shade[shading=linear,top color=purple!60!black,bottom color=green!70!black] (-0.75pt,-2pt) rectangle (0.75pt,-12pt);
    \end{scope}
}
\begin{document}
\pgfdeclaredecoration{lipidleaflet}{initial}
{
    % Place as many segments as possible along the path to decorate
    % the minimum distance between two segments is set to 7 pt.
    \state{initial}[width=\pgfdecoratedpathlength/floor(\pgfdecoratedpathlength/7pt)]
    {
        \pgfpathmoveto{\pgfpoint{-0.75pt}{3pt}}
        \pgfpathlineto{\pgfpoint{-0.75pt}{-7pt}}
        \pgfpathlineto{\pgfpoint{0.75pt}{-7pt}}
        \pgfpathlineto{\pgfpoint{0.75pt}{3pt}}
        % Draw the head group
        \pgfpathmoveto{\pgfpoint{1pt}{0pt}}
        \pgfpathcircle{\pgfpoint{0pt}{5pt}}{2.5pt}
    }
    \state{final}
    {
        \pgfpathmoveto{\pgfpointdecoratedpathlast}
    }
}
\begin{tikzpicture}
    % BACKGROUND
    \shadedraw[bottom color=cyan!10,top color=cyan!60!blue]  (-0.5,0) rectangle (11,7.5);
    \draw[thick] (-0.5,0) -- (11,0);
    % LARGE MOLECULES
    \shadedraw[shading=radial,inner color=yellow!20,outer color=orange!40] (0,1.5) .. controls (2,1.5) and (3,2) .. (4,2) .. controls (5,2) and (5.5,2) .. (5.5,1.5) .. controls (5.5,1) and (4.5,0.5) .. (4.5,0) -- (-0.5,0) -- (-0.5,1.5) -- cycle;
    \shadedraw[shading=radial,inner color=yellow!20,outer color=orange!40] (7,3.5) .. controls (6.5,4) and (7.5,4.5) .. (8,5) .. controls (8.5,5.5) and (9,5.5) .. (9.5,5.5) .. controls (10,5.5) and (10.5,5) .. (10.5,4.5) .. controls (10.5,4) and (10.5,4) .. (10,3.5).. controls (9.5,3) and (9.5,3) .. (8.5,3) .. controls (8,3) and (7.5,3) .. (7,3.5);
    % BOUND LIPIDS
    \draw[decorate, decoration={lipidleaflet}] (0,1.5) .. controls (2,1.5) and (3,2) .. (4,2) .. controls (5,2) and (5.5,2) .. (5.5,1.5) .. controls (5.5,1) and (4.5,0.5) .. (4.5,0);
    \draw[decorate, decoration={lipidleaflet}]  (7,3.5) .. controls (6.5,4) and (7.5,4.5) .. (8,5) .. controls (8.5,5.5) and (9,5.5) .. (9.5,5.5) .. controls (10,5.5) and (10.5,5) .. (10.5,4.5) .. controls (10.5,4) and (10.5,4) .. (10,3.5).. controls (9.5,3) and (9.5,3) .. (8.5,3) .. controls (8,3) and (7.5,3) .. (7,3.5);
    % FREE LIPIDS
    \lipid{1}{6}{20}
    \lipid{5.5}{5.5}{193}
    \lipid{0.5}{2.5}{201}
    \lipid{3}{7}{118}
    \lipid{2.5}{3.5}{217}
    \lipid{3.5}{5}{346}
    \lipid{5}{3.5}{26}
    \lipid{6.5}{2.5}{310}
    \lipid{6.5}{1}{123}
    \lipid{9}{1}{353}
    % LABELLING
    \node at (2,0.5) {Grease on Surface};
    \node at (9,2.5) {Micelle};
    \draw (8.7,4.3) -- (7.5,6) node[anchor=south,align=center] {Grease particle made\\soluble by soap};
\end{tikzpicture}
\end{document}

Some of the code comes from http://www.texample.net/tikz/examples/lipid-vesicle/

5

Ok, I made some refinements:

  1. Use pics for the lipids.
  2. Adjust their shading angle to make the shading uniform. The shading angle is computed based on the actual orientation of the lipids.
  3. Lifted the lipids up. To change the lift, change 2mm in \path pic[midway,sloped,yshift=2mm] {lipid};
  4. Cleaned up a bit.

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[left=0.00cm, right=0.00cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc,fadings,decorations.markings}

\tikzset{pics/.cd,
lipid/.style={code={
\shadedraw[shading=radial,inner color=purple!40,outer color=purple!60!black] (0,0) circle (2.5pt);
\shade let \p1=($(1,0)-(0,0)$),\n1={atan2(\y1,\x1)},
\p2=($(current bounding box.east)-(current bounding box.west)$),\n2={\n1-atan2(\y2,\x2)}
 in %{\pgfextra{\typeout{\n2}}}
 [shading=linear,top color=purple!60!black,bottom color=green!70!black,
shading angle=\n2] (-0.75pt,-2pt) rectangle (0.75pt,-12pt);
}}}

\begin{document}
\begin{tikzpicture}[multi lipid/.style={decoration={markings,
mark=between positions 0 and 1 step #1 with {%
\begin{scope}
\path  pic[midway,sloped,yshift=2mm] {lipid};
\end{scope}}
}}]
    % BACKGROUND
    \shadedraw[bottom color=cyan!10,top color=cyan!60!blue]  (-0.5,0) rectangle (11,7.5);
    \draw[thick] (-0.5,0) -- (11,0);
    % LARGE MOLECULES
    \shadedraw[shading=radial,inner color=yellow!20,outer color=orange!40] (0,1.5) .. controls (2,1.5) and (3,2) .. (4,2) .. controls (5,2) and (5.5,2) .. (5.5,1.5) .. controls (5.5,1) and (4.5,0.5) .. (4.5,0) -- (-0.5,0) -- (-0.5,1.5) -- cycle;
    \shadedraw[shading=radial,inner color=yellow!20,outer color=orange!40] (7,3.5) .. controls (6.5,4) and (7.5,4.5) .. (8,5) .. controls (8.5,5.5) and (9,5.5) .. (9.5,5.5) .. controls (10,5.5) and (10.5,5) .. (10.5,4.5) .. controls (10.5,4) and (10.5,4) .. (10,3.5).. controls (9.5,3) and (9.5,3) .. (8.5,3) .. controls (8,3) and (7.5,3) .. (7,3.5);
    % BOUND LIPIDS
    \draw[decorate,multi lipid=4.2mm] (0,1.5) .. controls (2,1.5) and (3,2) .. (4,2) .. controls (5,2) and (5.5,2) .. (5.5,1.5) .. controls (5.5,1) and (4.5,0.5) .. (4.5,0);
    \draw[decorate,multi lipid=4.2mm]  (7,3.5) .. controls (6.5,4) and (7.5,4.5) .. (8,5) .. controls (8.5,5.5) and (9,5.5) .. (9.5,5.5) .. controls (10,5.5) and (10.5,5) .. (10.5,4.5) .. controls (10.5,4) and (10.5,4) .. (10,3.5).. controls (9.5,3) and (9.5,3) .. (8.5,3) .. controls (8,3) and (7.5,3) .. (7,3.5);
    % FREE LIPIDS
    \path (1,6) pic[rotate=20]{lipid}
    (5.5,5.5) pic[rotate=193]{lipid}
    (0.5,2.5) pic[rotate=201]{lipid}
    (3,7) pic[rotate=118]{lipid}
    (2.5,3.5) pic[rotate=217]{lipid}
    (3.5,5) pic[rotate=346]{lipid}
    (5,3.5) pic[rotate=26]{lipid}
    (6.5,2.5) pic[rotate=310]{lipid}
    (6.5,1) pic[rotate=123]{lipid}
    (9,1) pic[rotate=353]{lipid};
    % LABELLING
    \node at (2,0.5) {Grease on Surface};
    \node at (9,2.5) {Micelle};
    \draw (8.7,4.3) -- (7.5,6) node[anchor=south,align=center] {Grease particle made\\soluble by soap};
\end{tikzpicture}
\end{document}

enter image description here

  • Mainly a fixed distance. Also on another note, if you look at the picture in the original image from the question, the lipids stick out more, but I think I can do that myself. Thanks so much – sab hoque Jan 21 at 3:01
  • There appears to be one issue that I have only come across now, the shading on the green-purple region changes with the orientation of the lipid. Is it possible to make it a fixed gradient such that it is always purple at the end near the circle and green at the tail. I would like to apply this to all the lipids (including the free ones) – sab hoque Jan 21 at 3:03
  • 1
    @sabhoque Yes. I updated the thingy. (The shading of the purple region is radial, I think, so it is invariant under rotations.) – marmot Jan 21 at 3:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.