How to draw special tikz borders












2















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/










share|improve this question



























    2















    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/










    share|improve this question

























      2












      2








      2








      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/










      share|improve this question














      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/







      tikz-pgf






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 3 hours ago









      sab hoquesab hoque

      1,514318




      1,514318






















          1 Answer
          1






          active

          oldest

          votes


















          2














          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






          share|improve this answer


























          • 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
            2 hours ago











          • 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
            2 hours ago













          • @sabhoque Yes. I updated the thingy. (The shading of the purple region is radial, I think, so it is invariant under rotations.)

            – marmot
            1 hour ago











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "85"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f471073%2fhow-to-draw-special-tikz-borders%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          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






          share|improve this answer


























          • 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
            2 hours ago











          • 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
            2 hours ago













          • @sabhoque Yes. I updated the thingy. (The shading of the purple region is radial, I think, so it is invariant under rotations.)

            – marmot
            1 hour ago
















          2














          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






          share|improve this answer


























          • 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
            2 hours ago











          • 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
            2 hours ago













          • @sabhoque Yes. I updated the thingy. (The shading of the purple region is radial, I think, so it is invariant under rotations.)

            – marmot
            1 hour ago














          2












          2








          2







          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






          share|improve this answer















          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







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 1 hour ago

























          answered 2 hours ago









          marmotmarmot

          93.1k4109204




          93.1k4109204













          • 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
            2 hours ago











          • 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
            2 hours ago













          • @sabhoque Yes. I updated the thingy. (The shading of the purple region is radial, I think, so it is invariant under rotations.)

            – marmot
            1 hour ago



















          • 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
            2 hours ago











          • 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
            2 hours ago













          • @sabhoque Yes. I updated the thingy. (The shading of the purple region is radial, I think, so it is invariant under rotations.)

            – marmot
            1 hour ago

















          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
          2 hours ago





          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
          2 hours ago













          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
          2 hours ago







          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
          2 hours ago















          @sabhoque Yes. I updated the thingy. (The shading of the purple region is radial, I think, so it is invariant under rotations.)

          – marmot
          1 hour ago





          @sabhoque Yes. I updated the thingy. (The shading of the purple region is radial, I think, so it is invariant under rotations.)

          – marmot
          1 hour ago


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f471073%2fhow-to-draw-special-tikz-borders%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          CARDNET

          Boot-repair Failure: Unable to locate package grub-common:i386

          Aws NAT - Aws IGW- Aws router