TikZ fill using draw color











up vote
2
down vote

favorite












The following code uses a decorator to add an arrow tip to an edge. Logically, the tip is part of the edge, and so I want it to be colored with the line-color. However, because the tip is rendered using fill, it takes its color from the fill parameter. How can I make the color to respond to draw=red, and also not respond to fill=blue?



enter image description here



documentclass[tikz, crop,border=1]{standalone}
usetikzlibrary{decorations.markings, decorations.pathreplacing}

newcommand{drawArrow}[2]{
draw[
decoration={
markings,
mark=at position 0.8 with {%
fill (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
}
},
postaction=decorate
] #1 -- #2;
}

begin{document}
begin{tikzpicture}[scale=2]
tikzset{
pe/.style={
line width = 1pt,
decoration={
show path construction,
lineto code={%
drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
},
closepath code={%
drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
}
},
postaction=decorate
}
}

% Not what I want
draw[pe, draw = red] (0, 0) -- (1, 0);

% Not what I want
draw[pe, draw = red, fill=blue] (0, 0.25) -- (1, 0.25) -- (1, 0.5) -- (0, 0.5) -- cycle;

% What I want
draw[pe, red] (0, 0.6) -- (1, 0.6);

% Not what I want
draw[pe, red, fill=blue] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

% What I want, simulated
fill[pe, fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
draw[pe, red] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;

end{tikzpicture}
end{document}









share|improve this question
























  • possible duplication of this question: tex.stackexchange.com/q/462552/138900
    – AndréC
    4 hours ago










  • Possible duplicate of TikZ arrow tip is drawn with two colors
    – AndréC
    4 hours ago















up vote
2
down vote

favorite












The following code uses a decorator to add an arrow tip to an edge. Logically, the tip is part of the edge, and so I want it to be colored with the line-color. However, because the tip is rendered using fill, it takes its color from the fill parameter. How can I make the color to respond to draw=red, and also not respond to fill=blue?



enter image description here



documentclass[tikz, crop,border=1]{standalone}
usetikzlibrary{decorations.markings, decorations.pathreplacing}

newcommand{drawArrow}[2]{
draw[
decoration={
markings,
mark=at position 0.8 with {%
fill (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
}
},
postaction=decorate
] #1 -- #2;
}

begin{document}
begin{tikzpicture}[scale=2]
tikzset{
pe/.style={
line width = 1pt,
decoration={
show path construction,
lineto code={%
drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
},
closepath code={%
drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
}
},
postaction=decorate
}
}

% Not what I want
draw[pe, draw = red] (0, 0) -- (1, 0);

% Not what I want
draw[pe, draw = red, fill=blue] (0, 0.25) -- (1, 0.25) -- (1, 0.5) -- (0, 0.5) -- cycle;

% What I want
draw[pe, red] (0, 0.6) -- (1, 0.6);

% Not what I want
draw[pe, red, fill=blue] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

% What I want, simulated
fill[pe, fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
draw[pe, red] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;

end{tikzpicture}
end{document}









share|improve this question
























  • possible duplication of this question: tex.stackexchange.com/q/462552/138900
    – AndréC
    4 hours ago










  • Possible duplicate of TikZ arrow tip is drawn with two colors
    – AndréC
    4 hours ago













up vote
2
down vote

favorite









up vote
2
down vote

favorite











The following code uses a decorator to add an arrow tip to an edge. Logically, the tip is part of the edge, and so I want it to be colored with the line-color. However, because the tip is rendered using fill, it takes its color from the fill parameter. How can I make the color to respond to draw=red, and also not respond to fill=blue?



enter image description here



documentclass[tikz, crop,border=1]{standalone}
usetikzlibrary{decorations.markings, decorations.pathreplacing}

newcommand{drawArrow}[2]{
draw[
decoration={
markings,
mark=at position 0.8 with {%
fill (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
}
},
postaction=decorate
] #1 -- #2;
}

begin{document}
begin{tikzpicture}[scale=2]
tikzset{
pe/.style={
line width = 1pt,
decoration={
show path construction,
lineto code={%
drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
},
closepath code={%
drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
}
},
postaction=decorate
}
}

% Not what I want
draw[pe, draw = red] (0, 0) -- (1, 0);

% Not what I want
draw[pe, draw = red, fill=blue] (0, 0.25) -- (1, 0.25) -- (1, 0.5) -- (0, 0.5) -- cycle;

% What I want
draw[pe, red] (0, 0.6) -- (1, 0.6);

% Not what I want
draw[pe, red, fill=blue] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

% What I want, simulated
fill[pe, fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
draw[pe, red] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;

end{tikzpicture}
end{document}









share|improve this question















The following code uses a decorator to add an arrow tip to an edge. Logically, the tip is part of the edge, and so I want it to be colored with the line-color. However, because the tip is rendered using fill, it takes its color from the fill parameter. How can I make the color to respond to draw=red, and also not respond to fill=blue?



enter image description here



documentclass[tikz, crop,border=1]{standalone}
usetikzlibrary{decorations.markings, decorations.pathreplacing}

newcommand{drawArrow}[2]{
draw[
decoration={
markings,
mark=at position 0.8 with {%
fill (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
}
},
postaction=decorate
] #1 -- #2;
}

begin{document}
begin{tikzpicture}[scale=2]
tikzset{
pe/.style={
line width = 1pt,
decoration={
show path construction,
lineto code={%
drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
},
closepath code={%
drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
}
},
postaction=decorate
}
}

% Not what I want
draw[pe, draw = red] (0, 0) -- (1, 0);

% Not what I want
draw[pe, draw = red, fill=blue] (0, 0.25) -- (1, 0.25) -- (1, 0.5) -- (0, 0.5) -- cycle;

% What I want
draw[pe, red] (0, 0.6) -- (1, 0.6);

% Not what I want
draw[pe, red, fill=blue] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

% What I want, simulated
fill[pe, fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
draw[pe, red] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;

end{tikzpicture}
end{document}






tikz-pgf tikz-styles tikz-decorations






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 hours ago

























asked 4 hours ago









kaba

25717




25717












  • possible duplication of this question: tex.stackexchange.com/q/462552/138900
    – AndréC
    4 hours ago










  • Possible duplicate of TikZ arrow tip is drawn with two colors
    – AndréC
    4 hours ago


















  • possible duplication of this question: tex.stackexchange.com/q/462552/138900
    – AndréC
    4 hours ago










  • Possible duplicate of TikZ arrow tip is drawn with two colors
    – AndréC
    4 hours ago
















possible duplication of this question: tex.stackexchange.com/q/462552/138900
– AndréC
4 hours ago




possible duplication of this question: tex.stackexchange.com/q/462552/138900
– AndréC
4 hours ago












Possible duplicate of TikZ arrow tip is drawn with two colors
– AndréC
4 hours ago




Possible duplicate of TikZ arrow tip is drawn with two colors
– AndréC
4 hours ago










3 Answers
3






active

oldest

votes

















up vote
1
down vote













Update 2



You can make the color of the decoration a parameter of the style.



decoration={
markings, mark=at position 0.8 with {%
fill[#1] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
}


Just call this style pe=yellow, by default these style is red.



documentclass[tikz, crop,border=1]{standalone}
usetikzlibrary{decorations.markings}

begin{document}
begin{tikzpicture}
tikzset{
pe/.style={
%line width = 1pt,
decoration={
markings, mark=at position 0.8 with {%
fill[#1] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
}
},
postaction=decorate
},
pe/.default=red
}
% Incorrect
draw[pe=yellow, draw = red] (0, 0) -- (1, 0);

% Incorrect
draw[pe=black, draw = red, fill=blue] (0, 0.25) -- (1, 0.25) -- (1, 0.5) -- (0, 0.5) -- cycle;

% Correct
draw[pe, red] (0, 0.6) -- (1, 0.6);

% Incorrect
draw[pe, red, fill=blue] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

% Correct, simulated
fill[pe, fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
end{tikzpicture}
end{document}


pe default



Update



If I understood correctly, you must specify the color in the decoration.



decoration={
markings, mark=at position 0.8 with {%
fill[red] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
}
},


decoration



documentclass[tikz, crop,border=1]{standalone}
usetikzlibrary{decorations.markings}

begin{document}
begin{tikzpicture}
tikzset{
pe/.style={
%line width = 1pt,
decoration={
markings, mark=at position 0.8 with {%
fill[red] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
}
},
postaction=decorate
},
}

% Incorrect
draw[pe, draw = red] (0, 0) -- (1, 0);

% Incorrect
draw[pe, draw = red, fill=blue] (0, 0.25) -- (1, 0.25) -- (1, 0.5) -- (0, 0.5) -- cycle;

% Correct
draw[pe, red] (0, 0.6) -- (1, 0.6);

% Incorrect
draw[pe, red, fill=blue] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

% Correct, simulated
fill[pe, fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
draw[pe, red] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;

end{tikzpicture}
end{document}

Simply by not specifying `draw=red`, but just `red`

draw[pe, red] (0, 0) -- (1, 0);

[![red][2]][2]

documentclass[tikz, crop,border=5mm]{standalone}
usetikzlibrary{decorations.markings}

begin{document}
begin{tikzpicture}
tikzset{
pe/.style={
decoration={
markings, mark=at position 0.8 with {%
fill (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
}
},
postaction=decorate
}
}
draw[pe, red] (0, 0) -- (1, 0);
end{tikzpicture}
end{document}





share|improve this answer























  • This modifies the fill color, which I want to control independently for filled polygons.
    – kaba
    4 hours ago










  • Show us an example of its effect.
    – AndréC
    4 hours ago










  • I was wrong in that it does not modify the fill color. However, specifying the fill color overrides the color for the arrow tip, which should not happen.
    – kaba
    4 hours ago










  • I don't understand what your problem is now, edit your question.
    – AndréC
    4 hours ago










  • Added new images. The arrow should respond to setting the draw color, and not respond to setting the fill color.
    – kaba
    4 hours ago


















up vote
1
down vote













Just define a style for the arrow and set it accordingly.



documentclass[tikz, crop,border=1]{standalone}
usetikzlibrary{decorations.markings, decorations.pathreplacing}
tikzset{pearrow/.style={fill},
peset/.code={tikzset{pearrow/.style={#1}}}}
newcommand{drawArrow}[2]{
draw[
decoration={
markings,
mark=at position 0.8 with {%
path[pearrow] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
}
},
postaction=decorate
] #1 -- #2;
}

begin{document}
begin{tikzpicture}[scale=2]
tikzset{
pe/.style={
line width = 1pt,
decoration={
show path construction,
lineto code={%
drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
},
closepath code={%
drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
}
},
postaction=decorate
}
}


% with peset
draw[pe, red, fill=blue,peset={fill=red}] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

% What I want, simulated
fill[pe, fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
draw[pe, red] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;

end{tikzpicture}
end{document}


enter image description here






share|improve this answer






























    up vote
    0
    down vote













    The following findArrowColor style, based on this Georg Sievelson's answer, picks the current stroke color if such is available, then the current text color if such is available, and black color as the last resort.



    enter image description here



    documentclass[tikz, crop,border=1]{standalone}
    usetikzlibrary{decorations.markings, decorations.pathreplacing}

    usepackage{ifthen}

    makeatletter
    tikzset{
    /tikz/findArrowColor/.style={/utils/exec={%
    ifthenelse{equal{tikz@strokecolor}{}}%
    {%
    ifthenelse{equal{tikz@textcolor}{}}%
    {%
    colorlet{#1}{black}%
    }%
    {colorlet{#1}{tikz@textcolor}}%
    }%
    {%
    colorlet{#1}{tikz@strokecolor}%
    }%
    }}
    }
    makeatother

    newcommand{drawArrow}[2]{
    draw[
    decoration={
    markings,
    mark=at position 0.8 with {%
    begin{scope}
    tikzset{findArrowColor=arrowColor}
    fill[fill=arrowColor] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
    end{scope}
    }
    },
    postaction=decorate
    ] #1 -- #2;
    }

    begin{document}
    begin{tikzpicture}[scale=2]

    tikzset{
    pe/.style={
    line width = 1pt,
    decoration={
    show path construction,
    lineto code={%
    begin{scope}[#1]
    drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
    end{scope}
    },
    closepath code={%
    begin{scope}[#1]
    drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
    end{scope}
    }
    },
    postaction=decorate
    }
    }

    draw[pe, fill = blue] (0, -0.2) -- (1, -0.2);
    draw[pe, draw = red] (0, 0) -- (1, 0);
    draw[pe, draw = red, fill=blue] (0, 0.25) -- (1, 0.25) -- (1, 0.5) -- (0, 0.5) -- cycle;
    draw[pe, red, fill=blue] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

    fill[fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
    draw[pe, red] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;

    end{tikzpicture}
    end{document}





    share|improve this answer























      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',
      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%2f464062%2ftikz-fill-using-draw-color%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      1
      down vote













      Update 2



      You can make the color of the decoration a parameter of the style.



      decoration={
      markings, mark=at position 0.8 with {%
      fill[#1] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }


      Just call this style pe=yellow, by default these style is red.



      documentclass[tikz, crop,border=1]{standalone}
      usetikzlibrary{decorations.markings}

      begin{document}
      begin{tikzpicture}
      tikzset{
      pe/.style={
      %line width = 1pt,
      decoration={
      markings, mark=at position 0.8 with {%
      fill[#1] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }
      },
      postaction=decorate
      },
      pe/.default=red
      }
      % Incorrect
      draw[pe=yellow, draw = red] (0, 0) -- (1, 0);

      % Incorrect
      draw[pe=black, draw = red, fill=blue] (0, 0.25) -- (1, 0.25) -- (1, 0.5) -- (0, 0.5) -- cycle;

      % Correct
      draw[pe, red] (0, 0.6) -- (1, 0.6);

      % Incorrect
      draw[pe, red, fill=blue] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

      % Correct, simulated
      fill[pe, fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
      end{tikzpicture}
      end{document}


      pe default



      Update



      If I understood correctly, you must specify the color in the decoration.



      decoration={
      markings, mark=at position 0.8 with {%
      fill[red] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }
      },


      decoration



      documentclass[tikz, crop,border=1]{standalone}
      usetikzlibrary{decorations.markings}

      begin{document}
      begin{tikzpicture}
      tikzset{
      pe/.style={
      %line width = 1pt,
      decoration={
      markings, mark=at position 0.8 with {%
      fill[red] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }
      },
      postaction=decorate
      },
      }

      % Incorrect
      draw[pe, draw = red] (0, 0) -- (1, 0);

      % Incorrect
      draw[pe, draw = red, fill=blue] (0, 0.25) -- (1, 0.25) -- (1, 0.5) -- (0, 0.5) -- cycle;

      % Correct
      draw[pe, red] (0, 0.6) -- (1, 0.6);

      % Incorrect
      draw[pe, red, fill=blue] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

      % Correct, simulated
      fill[pe, fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
      draw[pe, red] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;

      end{tikzpicture}
      end{document}

      Simply by not specifying `draw=red`, but just `red`

      draw[pe, red] (0, 0) -- (1, 0);

      [![red][2]][2]

      documentclass[tikz, crop,border=5mm]{standalone}
      usetikzlibrary{decorations.markings}

      begin{document}
      begin{tikzpicture}
      tikzset{
      pe/.style={
      decoration={
      markings, mark=at position 0.8 with {%
      fill (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }
      },
      postaction=decorate
      }
      }
      draw[pe, red] (0, 0) -- (1, 0);
      end{tikzpicture}
      end{document}





      share|improve this answer























      • This modifies the fill color, which I want to control independently for filled polygons.
        – kaba
        4 hours ago










      • Show us an example of its effect.
        – AndréC
        4 hours ago










      • I was wrong in that it does not modify the fill color. However, specifying the fill color overrides the color for the arrow tip, which should not happen.
        – kaba
        4 hours ago










      • I don't understand what your problem is now, edit your question.
        – AndréC
        4 hours ago










      • Added new images. The arrow should respond to setting the draw color, and not respond to setting the fill color.
        – kaba
        4 hours ago















      up vote
      1
      down vote













      Update 2



      You can make the color of the decoration a parameter of the style.



      decoration={
      markings, mark=at position 0.8 with {%
      fill[#1] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }


      Just call this style pe=yellow, by default these style is red.



      documentclass[tikz, crop,border=1]{standalone}
      usetikzlibrary{decorations.markings}

      begin{document}
      begin{tikzpicture}
      tikzset{
      pe/.style={
      %line width = 1pt,
      decoration={
      markings, mark=at position 0.8 with {%
      fill[#1] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }
      },
      postaction=decorate
      },
      pe/.default=red
      }
      % Incorrect
      draw[pe=yellow, draw = red] (0, 0) -- (1, 0);

      % Incorrect
      draw[pe=black, draw = red, fill=blue] (0, 0.25) -- (1, 0.25) -- (1, 0.5) -- (0, 0.5) -- cycle;

      % Correct
      draw[pe, red] (0, 0.6) -- (1, 0.6);

      % Incorrect
      draw[pe, red, fill=blue] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

      % Correct, simulated
      fill[pe, fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
      end{tikzpicture}
      end{document}


      pe default



      Update



      If I understood correctly, you must specify the color in the decoration.



      decoration={
      markings, mark=at position 0.8 with {%
      fill[red] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }
      },


      decoration



      documentclass[tikz, crop,border=1]{standalone}
      usetikzlibrary{decorations.markings}

      begin{document}
      begin{tikzpicture}
      tikzset{
      pe/.style={
      %line width = 1pt,
      decoration={
      markings, mark=at position 0.8 with {%
      fill[red] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }
      },
      postaction=decorate
      },
      }

      % Incorrect
      draw[pe, draw = red] (0, 0) -- (1, 0);

      % Incorrect
      draw[pe, draw = red, fill=blue] (0, 0.25) -- (1, 0.25) -- (1, 0.5) -- (0, 0.5) -- cycle;

      % Correct
      draw[pe, red] (0, 0.6) -- (1, 0.6);

      % Incorrect
      draw[pe, red, fill=blue] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

      % Correct, simulated
      fill[pe, fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
      draw[pe, red] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;

      end{tikzpicture}
      end{document}

      Simply by not specifying `draw=red`, but just `red`

      draw[pe, red] (0, 0) -- (1, 0);

      [![red][2]][2]

      documentclass[tikz, crop,border=5mm]{standalone}
      usetikzlibrary{decorations.markings}

      begin{document}
      begin{tikzpicture}
      tikzset{
      pe/.style={
      decoration={
      markings, mark=at position 0.8 with {%
      fill (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }
      },
      postaction=decorate
      }
      }
      draw[pe, red] (0, 0) -- (1, 0);
      end{tikzpicture}
      end{document}





      share|improve this answer























      • This modifies the fill color, which I want to control independently for filled polygons.
        – kaba
        4 hours ago










      • Show us an example of its effect.
        – AndréC
        4 hours ago










      • I was wrong in that it does not modify the fill color. However, specifying the fill color overrides the color for the arrow tip, which should not happen.
        – kaba
        4 hours ago










      • I don't understand what your problem is now, edit your question.
        – AndréC
        4 hours ago










      • Added new images. The arrow should respond to setting the draw color, and not respond to setting the fill color.
        – kaba
        4 hours ago













      up vote
      1
      down vote










      up vote
      1
      down vote









      Update 2



      You can make the color of the decoration a parameter of the style.



      decoration={
      markings, mark=at position 0.8 with {%
      fill[#1] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }


      Just call this style pe=yellow, by default these style is red.



      documentclass[tikz, crop,border=1]{standalone}
      usetikzlibrary{decorations.markings}

      begin{document}
      begin{tikzpicture}
      tikzset{
      pe/.style={
      %line width = 1pt,
      decoration={
      markings, mark=at position 0.8 with {%
      fill[#1] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }
      },
      postaction=decorate
      },
      pe/.default=red
      }
      % Incorrect
      draw[pe=yellow, draw = red] (0, 0) -- (1, 0);

      % Incorrect
      draw[pe=black, draw = red, fill=blue] (0, 0.25) -- (1, 0.25) -- (1, 0.5) -- (0, 0.5) -- cycle;

      % Correct
      draw[pe, red] (0, 0.6) -- (1, 0.6);

      % Incorrect
      draw[pe, red, fill=blue] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

      % Correct, simulated
      fill[pe, fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
      end{tikzpicture}
      end{document}


      pe default



      Update



      If I understood correctly, you must specify the color in the decoration.



      decoration={
      markings, mark=at position 0.8 with {%
      fill[red] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }
      },


      decoration



      documentclass[tikz, crop,border=1]{standalone}
      usetikzlibrary{decorations.markings}

      begin{document}
      begin{tikzpicture}
      tikzset{
      pe/.style={
      %line width = 1pt,
      decoration={
      markings, mark=at position 0.8 with {%
      fill[red] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }
      },
      postaction=decorate
      },
      }

      % Incorrect
      draw[pe, draw = red] (0, 0) -- (1, 0);

      % Incorrect
      draw[pe, draw = red, fill=blue] (0, 0.25) -- (1, 0.25) -- (1, 0.5) -- (0, 0.5) -- cycle;

      % Correct
      draw[pe, red] (0, 0.6) -- (1, 0.6);

      % Incorrect
      draw[pe, red, fill=blue] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

      % Correct, simulated
      fill[pe, fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
      draw[pe, red] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;

      end{tikzpicture}
      end{document}

      Simply by not specifying `draw=red`, but just `red`

      draw[pe, red] (0, 0) -- (1, 0);

      [![red][2]][2]

      documentclass[tikz, crop,border=5mm]{standalone}
      usetikzlibrary{decorations.markings}

      begin{document}
      begin{tikzpicture}
      tikzset{
      pe/.style={
      decoration={
      markings, mark=at position 0.8 with {%
      fill (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }
      },
      postaction=decorate
      }
      }
      draw[pe, red] (0, 0) -- (1, 0);
      end{tikzpicture}
      end{document}





      share|improve this answer














      Update 2



      You can make the color of the decoration a parameter of the style.



      decoration={
      markings, mark=at position 0.8 with {%
      fill[#1] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }


      Just call this style pe=yellow, by default these style is red.



      documentclass[tikz, crop,border=1]{standalone}
      usetikzlibrary{decorations.markings}

      begin{document}
      begin{tikzpicture}
      tikzset{
      pe/.style={
      %line width = 1pt,
      decoration={
      markings, mark=at position 0.8 with {%
      fill[#1] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }
      },
      postaction=decorate
      },
      pe/.default=red
      }
      % Incorrect
      draw[pe=yellow, draw = red] (0, 0) -- (1, 0);

      % Incorrect
      draw[pe=black, draw = red, fill=blue] (0, 0.25) -- (1, 0.25) -- (1, 0.5) -- (0, 0.5) -- cycle;

      % Correct
      draw[pe, red] (0, 0.6) -- (1, 0.6);

      % Incorrect
      draw[pe, red, fill=blue] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

      % Correct, simulated
      fill[pe, fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
      end{tikzpicture}
      end{document}


      pe default



      Update



      If I understood correctly, you must specify the color in the decoration.



      decoration={
      markings, mark=at position 0.8 with {%
      fill[red] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }
      },


      decoration



      documentclass[tikz, crop,border=1]{standalone}
      usetikzlibrary{decorations.markings}

      begin{document}
      begin{tikzpicture}
      tikzset{
      pe/.style={
      %line width = 1pt,
      decoration={
      markings, mark=at position 0.8 with {%
      fill[red] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }
      },
      postaction=decorate
      },
      }

      % Incorrect
      draw[pe, draw = red] (0, 0) -- (1, 0);

      % Incorrect
      draw[pe, draw = red, fill=blue] (0, 0.25) -- (1, 0.25) -- (1, 0.5) -- (0, 0.5) -- cycle;

      % Correct
      draw[pe, red] (0, 0.6) -- (1, 0.6);

      % Incorrect
      draw[pe, red, fill=blue] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

      % Correct, simulated
      fill[pe, fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
      draw[pe, red] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;

      end{tikzpicture}
      end{document}

      Simply by not specifying `draw=red`, but just `red`

      draw[pe, red] (0, 0) -- (1, 0);

      [![red][2]][2]

      documentclass[tikz, crop,border=5mm]{standalone}
      usetikzlibrary{decorations.markings}

      begin{document}
      begin{tikzpicture}
      tikzset{
      pe/.style={
      decoration={
      markings, mark=at position 0.8 with {%
      fill (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }
      },
      postaction=decorate
      }
      }
      draw[pe, red] (0, 0) -- (1, 0);
      end{tikzpicture}
      end{document}






      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited 3 hours ago

























      answered 4 hours ago









      AndréC

      6,91711140




      6,91711140












      • This modifies the fill color, which I want to control independently for filled polygons.
        – kaba
        4 hours ago










      • Show us an example of its effect.
        – AndréC
        4 hours ago










      • I was wrong in that it does not modify the fill color. However, specifying the fill color overrides the color for the arrow tip, which should not happen.
        – kaba
        4 hours ago










      • I don't understand what your problem is now, edit your question.
        – AndréC
        4 hours ago










      • Added new images. The arrow should respond to setting the draw color, and not respond to setting the fill color.
        – kaba
        4 hours ago


















      • This modifies the fill color, which I want to control independently for filled polygons.
        – kaba
        4 hours ago










      • Show us an example of its effect.
        – AndréC
        4 hours ago










      • I was wrong in that it does not modify the fill color. However, specifying the fill color overrides the color for the arrow tip, which should not happen.
        – kaba
        4 hours ago










      • I don't understand what your problem is now, edit your question.
        – AndréC
        4 hours ago










      • Added new images. The arrow should respond to setting the draw color, and not respond to setting the fill color.
        – kaba
        4 hours ago
















      This modifies the fill color, which I want to control independently for filled polygons.
      – kaba
      4 hours ago




      This modifies the fill color, which I want to control independently for filled polygons.
      – kaba
      4 hours ago












      Show us an example of its effect.
      – AndréC
      4 hours ago




      Show us an example of its effect.
      – AndréC
      4 hours ago












      I was wrong in that it does not modify the fill color. However, specifying the fill color overrides the color for the arrow tip, which should not happen.
      – kaba
      4 hours ago




      I was wrong in that it does not modify the fill color. However, specifying the fill color overrides the color for the arrow tip, which should not happen.
      – kaba
      4 hours ago












      I don't understand what your problem is now, edit your question.
      – AndréC
      4 hours ago




      I don't understand what your problem is now, edit your question.
      – AndréC
      4 hours ago












      Added new images. The arrow should respond to setting the draw color, and not respond to setting the fill color.
      – kaba
      4 hours ago




      Added new images. The arrow should respond to setting the draw color, and not respond to setting the fill color.
      – kaba
      4 hours ago










      up vote
      1
      down vote













      Just define a style for the arrow and set it accordingly.



      documentclass[tikz, crop,border=1]{standalone}
      usetikzlibrary{decorations.markings, decorations.pathreplacing}
      tikzset{pearrow/.style={fill},
      peset/.code={tikzset{pearrow/.style={#1}}}}
      newcommand{drawArrow}[2]{
      draw[
      decoration={
      markings,
      mark=at position 0.8 with {%
      path[pearrow] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
      }
      },
      postaction=decorate
      ] #1 -- #2;
      }

      begin{document}
      begin{tikzpicture}[scale=2]
      tikzset{
      pe/.style={
      line width = 1pt,
      decoration={
      show path construction,
      lineto code={%
      drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
      },
      closepath code={%
      drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
      }
      },
      postaction=decorate
      }
      }


      % with peset
      draw[pe, red, fill=blue,peset={fill=red}] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

      % What I want, simulated
      fill[pe, fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
      draw[pe, red] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;

      end{tikzpicture}
      end{document}


      enter image description here






      share|improve this answer



























        up vote
        1
        down vote













        Just define a style for the arrow and set it accordingly.



        documentclass[tikz, crop,border=1]{standalone}
        usetikzlibrary{decorations.markings, decorations.pathreplacing}
        tikzset{pearrow/.style={fill},
        peset/.code={tikzset{pearrow/.style={#1}}}}
        newcommand{drawArrow}[2]{
        draw[
        decoration={
        markings,
        mark=at position 0.8 with {%
        path[pearrow] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
        }
        },
        postaction=decorate
        ] #1 -- #2;
        }

        begin{document}
        begin{tikzpicture}[scale=2]
        tikzset{
        pe/.style={
        line width = 1pt,
        decoration={
        show path construction,
        lineto code={%
        drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
        },
        closepath code={%
        drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
        }
        },
        postaction=decorate
        }
        }


        % with peset
        draw[pe, red, fill=blue,peset={fill=red}] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

        % What I want, simulated
        fill[pe, fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
        draw[pe, red] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;

        end{tikzpicture}
        end{document}


        enter image description here






        share|improve this answer

























          up vote
          1
          down vote










          up vote
          1
          down vote









          Just define a style for the arrow and set it accordingly.



          documentclass[tikz, crop,border=1]{standalone}
          usetikzlibrary{decorations.markings, decorations.pathreplacing}
          tikzset{pearrow/.style={fill},
          peset/.code={tikzset{pearrow/.style={#1}}}}
          newcommand{drawArrow}[2]{
          draw[
          decoration={
          markings,
          mark=at position 0.8 with {%
          path[pearrow] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
          }
          },
          postaction=decorate
          ] #1 -- #2;
          }

          begin{document}
          begin{tikzpicture}[scale=2]
          tikzset{
          pe/.style={
          line width = 1pt,
          decoration={
          show path construction,
          lineto code={%
          drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
          },
          closepath code={%
          drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
          }
          },
          postaction=decorate
          }
          }


          % with peset
          draw[pe, red, fill=blue,peset={fill=red}] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

          % What I want, simulated
          fill[pe, fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
          draw[pe, red] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;

          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer














          Just define a style for the arrow and set it accordingly.



          documentclass[tikz, crop,border=1]{standalone}
          usetikzlibrary{decorations.markings, decorations.pathreplacing}
          tikzset{pearrow/.style={fill},
          peset/.code={tikzset{pearrow/.style={#1}}}}
          newcommand{drawArrow}[2]{
          draw[
          decoration={
          markings,
          mark=at position 0.8 with {%
          path[pearrow] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
          }
          },
          postaction=decorate
          ] #1 -- #2;
          }

          begin{document}
          begin{tikzpicture}[scale=2]
          tikzset{
          pe/.style={
          line width = 1pt,
          decoration={
          show path construction,
          lineto code={%
          drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
          },
          closepath code={%
          drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
          }
          },
          postaction=decorate
          }
          }


          % with peset
          draw[pe, red, fill=blue,peset={fill=red}] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

          % What I want, simulated
          fill[pe, fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
          draw[pe, red] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;

          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









          marmot

          81.8k491174




          81.8k491174






















              up vote
              0
              down vote













              The following findArrowColor style, based on this Georg Sievelson's answer, picks the current stroke color if such is available, then the current text color if such is available, and black color as the last resort.



              enter image description here



              documentclass[tikz, crop,border=1]{standalone}
              usetikzlibrary{decorations.markings, decorations.pathreplacing}

              usepackage{ifthen}

              makeatletter
              tikzset{
              /tikz/findArrowColor/.style={/utils/exec={%
              ifthenelse{equal{tikz@strokecolor}{}}%
              {%
              ifthenelse{equal{tikz@textcolor}{}}%
              {%
              colorlet{#1}{black}%
              }%
              {colorlet{#1}{tikz@textcolor}}%
              }%
              {%
              colorlet{#1}{tikz@strokecolor}%
              }%
              }}
              }
              makeatother

              newcommand{drawArrow}[2]{
              draw[
              decoration={
              markings,
              mark=at position 0.8 with {%
              begin{scope}
              tikzset{findArrowColor=arrowColor}
              fill[fill=arrowColor] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
              end{scope}
              }
              },
              postaction=decorate
              ] #1 -- #2;
              }

              begin{document}
              begin{tikzpicture}[scale=2]

              tikzset{
              pe/.style={
              line width = 1pt,
              decoration={
              show path construction,
              lineto code={%
              begin{scope}[#1]
              drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
              end{scope}
              },
              closepath code={%
              begin{scope}[#1]
              drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
              end{scope}
              }
              },
              postaction=decorate
              }
              }

              draw[pe, fill = blue] (0, -0.2) -- (1, -0.2);
              draw[pe, draw = red] (0, 0) -- (1, 0);
              draw[pe, draw = red, fill=blue] (0, 0.25) -- (1, 0.25) -- (1, 0.5) -- (0, 0.5) -- cycle;
              draw[pe, red, fill=blue] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

              fill[fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
              draw[pe, red] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;

              end{tikzpicture}
              end{document}





              share|improve this answer



























                up vote
                0
                down vote













                The following findArrowColor style, based on this Georg Sievelson's answer, picks the current stroke color if such is available, then the current text color if such is available, and black color as the last resort.



                enter image description here



                documentclass[tikz, crop,border=1]{standalone}
                usetikzlibrary{decorations.markings, decorations.pathreplacing}

                usepackage{ifthen}

                makeatletter
                tikzset{
                /tikz/findArrowColor/.style={/utils/exec={%
                ifthenelse{equal{tikz@strokecolor}{}}%
                {%
                ifthenelse{equal{tikz@textcolor}{}}%
                {%
                colorlet{#1}{black}%
                }%
                {colorlet{#1}{tikz@textcolor}}%
                }%
                {%
                colorlet{#1}{tikz@strokecolor}%
                }%
                }}
                }
                makeatother

                newcommand{drawArrow}[2]{
                draw[
                decoration={
                markings,
                mark=at position 0.8 with {%
                begin{scope}
                tikzset{findArrowColor=arrowColor}
                fill[fill=arrowColor] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
                end{scope}
                }
                },
                postaction=decorate
                ] #1 -- #2;
                }

                begin{document}
                begin{tikzpicture}[scale=2]

                tikzset{
                pe/.style={
                line width = 1pt,
                decoration={
                show path construction,
                lineto code={%
                begin{scope}[#1]
                drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
                end{scope}
                },
                closepath code={%
                begin{scope}[#1]
                drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
                end{scope}
                }
                },
                postaction=decorate
                }
                }

                draw[pe, fill = blue] (0, -0.2) -- (1, -0.2);
                draw[pe, draw = red] (0, 0) -- (1, 0);
                draw[pe, draw = red, fill=blue] (0, 0.25) -- (1, 0.25) -- (1, 0.5) -- (0, 0.5) -- cycle;
                draw[pe, red, fill=blue] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

                fill[fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
                draw[pe, red] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;

                end{tikzpicture}
                end{document}





                share|improve this answer

























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  The following findArrowColor style, based on this Georg Sievelson's answer, picks the current stroke color if such is available, then the current text color if such is available, and black color as the last resort.



                  enter image description here



                  documentclass[tikz, crop,border=1]{standalone}
                  usetikzlibrary{decorations.markings, decorations.pathreplacing}

                  usepackage{ifthen}

                  makeatletter
                  tikzset{
                  /tikz/findArrowColor/.style={/utils/exec={%
                  ifthenelse{equal{tikz@strokecolor}{}}%
                  {%
                  ifthenelse{equal{tikz@textcolor}{}}%
                  {%
                  colorlet{#1}{black}%
                  }%
                  {colorlet{#1}{tikz@textcolor}}%
                  }%
                  {%
                  colorlet{#1}{tikz@strokecolor}%
                  }%
                  }}
                  }
                  makeatother

                  newcommand{drawArrow}[2]{
                  draw[
                  decoration={
                  markings,
                  mark=at position 0.8 with {%
                  begin{scope}
                  tikzset{findArrowColor=arrowColor}
                  fill[fill=arrowColor] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
                  end{scope}
                  }
                  },
                  postaction=decorate
                  ] #1 -- #2;
                  }

                  begin{document}
                  begin{tikzpicture}[scale=2]

                  tikzset{
                  pe/.style={
                  line width = 1pt,
                  decoration={
                  show path construction,
                  lineto code={%
                  begin{scope}[#1]
                  drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
                  end{scope}
                  },
                  closepath code={%
                  begin{scope}[#1]
                  drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
                  end{scope}
                  }
                  },
                  postaction=decorate
                  }
                  }

                  draw[pe, fill = blue] (0, -0.2) -- (1, -0.2);
                  draw[pe, draw = red] (0, 0) -- (1, 0);
                  draw[pe, draw = red, fill=blue] (0, 0.25) -- (1, 0.25) -- (1, 0.5) -- (0, 0.5) -- cycle;
                  draw[pe, red, fill=blue] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

                  fill[fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
                  draw[pe, red] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;

                  end{tikzpicture}
                  end{document}





                  share|improve this answer














                  The following findArrowColor style, based on this Georg Sievelson's answer, picks the current stroke color if such is available, then the current text color if such is available, and black color as the last resort.



                  enter image description here



                  documentclass[tikz, crop,border=1]{standalone}
                  usetikzlibrary{decorations.markings, decorations.pathreplacing}

                  usepackage{ifthen}

                  makeatletter
                  tikzset{
                  /tikz/findArrowColor/.style={/utils/exec={%
                  ifthenelse{equal{tikz@strokecolor}{}}%
                  {%
                  ifthenelse{equal{tikz@textcolor}{}}%
                  {%
                  colorlet{#1}{black}%
                  }%
                  {colorlet{#1}{tikz@textcolor}}%
                  }%
                  {%
                  colorlet{#1}{tikz@strokecolor}%
                  }%
                  }}
                  }
                  makeatother

                  newcommand{drawArrow}[2]{
                  draw[
                  decoration={
                  markings,
                  mark=at position 0.8 with {%
                  begin{scope}
                  tikzset{findArrowColor=arrowColor}
                  fill[fill=arrowColor] (0, 0.5pt) -- ++ (-0.25, 0.075) -- ++ (0, -0.075) -- cycle;
                  end{scope}
                  }
                  },
                  postaction=decorate
                  ] #1 -- #2;
                  }

                  begin{document}
                  begin{tikzpicture}[scale=2]

                  tikzset{
                  pe/.style={
                  line width = 1pt,
                  decoration={
                  show path construction,
                  lineto code={%
                  begin{scope}[#1]
                  drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
                  end{scope}
                  },
                  closepath code={%
                  begin{scope}[#1]
                  drawArrow{(tikzinputsegmentfirst)}{(tikzinputsegmentlast)}
                  end{scope}
                  }
                  },
                  postaction=decorate
                  }
                  }

                  draw[pe, fill = blue] (0, -0.2) -- (1, -0.2);
                  draw[pe, draw = red] (0, 0) -- (1, 0);
                  draw[pe, draw = red, fill=blue] (0, 0.25) -- (1, 0.25) -- (1, 0.5) -- (0, 0.5) -- cycle;
                  draw[pe, red, fill=blue] (0, 0.75) -- (1, 0.75) -- (1, 1) -- (0, 1) -- cycle;

                  fill[fill=blue] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;
                  draw[pe, red] (0, 1.1) -- (1, 1.1) -- (1, 1.35) -- (0, 1.35) -- cycle;

                  end{tikzpicture}
                  end{document}






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 21 mins ago

























                  answered 35 mins ago









                  kaba

                  25717




                  25717






























                      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.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • 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%2f464062%2ftikz-fill-using-draw-color%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

                      What visual should I use to simply compare current year value vs last year in Power BI desktop

                      How to ignore python UserWarning in pytest?

                      Alexandru Averescu