Problems with filling a path that includes decorations in TikZ












8















I want to construct a rectangle with two sides having a slight curvature and the other two sides being zigzag lines. In the end, I want to fill it. While the construction of the path worked the way I expected, the filling did not. How can I tell TikZ to fill the area inside this rectangle?



enter image description here



documentclass{article}
usepackage{tikz}
usetikzlibrary{intersections, decorations}
usepackage{pgfplots}
pgfplotsset{compat=newest}
begin{document}
begin{tikzpicture}[scale=2]

coordinate (A) at (0,0);
coordinate (B) at (8,0);
coordinate (C) at (8,2);
coordinate (D) at (0,2);

begin{scope}[decoration=zigzag]
defmypath{ (A) to[out=10,in=170] (B)
decorate[decoration=zigzag] {(B)-- (C)} (C) to[out=170,in=10] (D)
decorate[decoration=zigzag]{(D)--(A)}
};
draw [fill=red] mypath;
end{scope}
end{tikzpicture}
end{document}









share|improve this question

























  • Welcome to TeX.sx! A tip: If you indent lines by 4 spaces or enclose words in backticks `, they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it).

    – Torbjørn T.
    Apr 23 '13 at 11:10











  • Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers.

    – jubobs
    May 3 '13 at 12:12
















8















I want to construct a rectangle with two sides having a slight curvature and the other two sides being zigzag lines. In the end, I want to fill it. While the construction of the path worked the way I expected, the filling did not. How can I tell TikZ to fill the area inside this rectangle?



enter image description here



documentclass{article}
usepackage{tikz}
usetikzlibrary{intersections, decorations}
usepackage{pgfplots}
pgfplotsset{compat=newest}
begin{document}
begin{tikzpicture}[scale=2]

coordinate (A) at (0,0);
coordinate (B) at (8,0);
coordinate (C) at (8,2);
coordinate (D) at (0,2);

begin{scope}[decoration=zigzag]
defmypath{ (A) to[out=10,in=170] (B)
decorate[decoration=zigzag] {(B)-- (C)} (C) to[out=170,in=10] (D)
decorate[decoration=zigzag]{(D)--(A)}
};
draw [fill=red] mypath;
end{scope}
end{tikzpicture}
end{document}









share|improve this question

























  • Welcome to TeX.sx! A tip: If you indent lines by 4 spaces or enclose words in backticks `, they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it).

    – Torbjørn T.
    Apr 23 '13 at 11:10











  • Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers.

    – jubobs
    May 3 '13 at 12:12














8












8








8


2






I want to construct a rectangle with two sides having a slight curvature and the other two sides being zigzag lines. In the end, I want to fill it. While the construction of the path worked the way I expected, the filling did not. How can I tell TikZ to fill the area inside this rectangle?



enter image description here



documentclass{article}
usepackage{tikz}
usetikzlibrary{intersections, decorations}
usepackage{pgfplots}
pgfplotsset{compat=newest}
begin{document}
begin{tikzpicture}[scale=2]

coordinate (A) at (0,0);
coordinate (B) at (8,0);
coordinate (C) at (8,2);
coordinate (D) at (0,2);

begin{scope}[decoration=zigzag]
defmypath{ (A) to[out=10,in=170] (B)
decorate[decoration=zigzag] {(B)-- (C)} (C) to[out=170,in=10] (D)
decorate[decoration=zigzag]{(D)--(A)}
};
draw [fill=red] mypath;
end{scope}
end{tikzpicture}
end{document}









share|improve this question
















I want to construct a rectangle with two sides having a slight curvature and the other two sides being zigzag lines. In the end, I want to fill it. While the construction of the path worked the way I expected, the filling did not. How can I tell TikZ to fill the area inside this rectangle?



enter image description here



documentclass{article}
usepackage{tikz}
usetikzlibrary{intersections, decorations}
usepackage{pgfplots}
pgfplotsset{compat=newest}
begin{document}
begin{tikzpicture}[scale=2]

coordinate (A) at (0,0);
coordinate (B) at (8,0);
coordinate (C) at (8,2);
coordinate (D) at (0,2);

begin{scope}[decoration=zigzag]
defmypath{ (A) to[out=10,in=170] (B)
decorate[decoration=zigzag] {(B)-- (C)} (C) to[out=170,in=10] (D)
decorate[decoration=zigzag]{(D)--(A)}
};
draw [fill=red] mypath;
end{scope}
end{tikzpicture}
end{document}






tikz-pgf decorations






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 23 '13 at 11:17









jubobs

41.7k17155243




41.7k17155243










asked Apr 23 '13 at 11:09









RainerRainer

1926




1926













  • Welcome to TeX.sx! A tip: If you indent lines by 4 spaces or enclose words in backticks `, they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it).

    – Torbjørn T.
    Apr 23 '13 at 11:10











  • Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers.

    – jubobs
    May 3 '13 at 12:12



















  • Welcome to TeX.sx! A tip: If you indent lines by 4 spaces or enclose words in backticks `, they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it).

    – Torbjørn T.
    Apr 23 '13 at 11:10











  • Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers.

    – jubobs
    May 3 '13 at 12:12

















Welcome to TeX.sx! A tip: If you indent lines by 4 spaces or enclose words in backticks `, they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it).

– Torbjørn T.
Apr 23 '13 at 11:10





Welcome to TeX.sx! A tip: If you indent lines by 4 spaces or enclose words in backticks `, they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it).

– Torbjørn T.
Apr 23 '13 at 11:10













Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers.

– jubobs
May 3 '13 at 12:12





Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers.

– jubobs
May 3 '13 at 12:12










1 Answer
1






active

oldest

votes


















12














You are breaking the path into pieces by repeating the coordinate names (B) and (D) hence each piece is filled individually. Removing them inside the braces (and the extra (C)) fixes the problem.



documentclass{article}
usepackage{tikz}
usetikzlibrary{decorations.pathmorphing}
begin{document}
begin{tikzpicture}
coordinate (A) at (0,0);
coordinate (B) at (2,0);
coordinate (C) at (2,2);
coordinate (D) at (0,2);
begin{scope}[decoration=zigzag]
draw[fill=red] (A) to[out=10,in=170] (B)
decorate {-- (C)}
to[out=170,in=10] (D)
decorate {--(A)};
end{scope}
end{tikzpicture}
end{document}


enter image description here






share|improve this answer


























  • Just a note: since the default decoration for the scope is already set with begin{scope}[decoration=zigzag] you can remove [decoration=zigzag] from the path to clean it up a bit.

    – erik
    Apr 23 '13 at 11:34











  • @erik Indeed I missed that. Thanks.

    – percusse
    Apr 23 '13 at 11:46











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%2f110222%2fproblems-with-filling-a-path-that-includes-decorations-in-tikz%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









12














You are breaking the path into pieces by repeating the coordinate names (B) and (D) hence each piece is filled individually. Removing them inside the braces (and the extra (C)) fixes the problem.



documentclass{article}
usepackage{tikz}
usetikzlibrary{decorations.pathmorphing}
begin{document}
begin{tikzpicture}
coordinate (A) at (0,0);
coordinate (B) at (2,0);
coordinate (C) at (2,2);
coordinate (D) at (0,2);
begin{scope}[decoration=zigzag]
draw[fill=red] (A) to[out=10,in=170] (B)
decorate {-- (C)}
to[out=170,in=10] (D)
decorate {--(A)};
end{scope}
end{tikzpicture}
end{document}


enter image description here






share|improve this answer


























  • Just a note: since the default decoration for the scope is already set with begin{scope}[decoration=zigzag] you can remove [decoration=zigzag] from the path to clean it up a bit.

    – erik
    Apr 23 '13 at 11:34











  • @erik Indeed I missed that. Thanks.

    – percusse
    Apr 23 '13 at 11:46
















12














You are breaking the path into pieces by repeating the coordinate names (B) and (D) hence each piece is filled individually. Removing them inside the braces (and the extra (C)) fixes the problem.



documentclass{article}
usepackage{tikz}
usetikzlibrary{decorations.pathmorphing}
begin{document}
begin{tikzpicture}
coordinate (A) at (0,0);
coordinate (B) at (2,0);
coordinate (C) at (2,2);
coordinate (D) at (0,2);
begin{scope}[decoration=zigzag]
draw[fill=red] (A) to[out=10,in=170] (B)
decorate {-- (C)}
to[out=170,in=10] (D)
decorate {--(A)};
end{scope}
end{tikzpicture}
end{document}


enter image description here






share|improve this answer


























  • Just a note: since the default decoration for the scope is already set with begin{scope}[decoration=zigzag] you can remove [decoration=zigzag] from the path to clean it up a bit.

    – erik
    Apr 23 '13 at 11:34











  • @erik Indeed I missed that. Thanks.

    – percusse
    Apr 23 '13 at 11:46














12












12








12







You are breaking the path into pieces by repeating the coordinate names (B) and (D) hence each piece is filled individually. Removing them inside the braces (and the extra (C)) fixes the problem.



documentclass{article}
usepackage{tikz}
usetikzlibrary{decorations.pathmorphing}
begin{document}
begin{tikzpicture}
coordinate (A) at (0,0);
coordinate (B) at (2,0);
coordinate (C) at (2,2);
coordinate (D) at (0,2);
begin{scope}[decoration=zigzag]
draw[fill=red] (A) to[out=10,in=170] (B)
decorate {-- (C)}
to[out=170,in=10] (D)
decorate {--(A)};
end{scope}
end{tikzpicture}
end{document}


enter image description here






share|improve this answer















You are breaking the path into pieces by repeating the coordinate names (B) and (D) hence each piece is filled individually. Removing them inside the braces (and the extra (C)) fixes the problem.



documentclass{article}
usepackage{tikz}
usetikzlibrary{decorations.pathmorphing}
begin{document}
begin{tikzpicture}
coordinate (A) at (0,0);
coordinate (B) at (2,0);
coordinate (C) at (2,2);
coordinate (D) at (0,2);
begin{scope}[decoration=zigzag]
draw[fill=red] (A) to[out=10,in=170] (B)
decorate {-- (C)}
to[out=170,in=10] (D)
decorate {--(A)};
end{scope}
end{tikzpicture}
end{document}


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 23 '13 at 12:00

























answered Apr 23 '13 at 11:21









percussepercusse

138k14257495




138k14257495













  • Just a note: since the default decoration for the scope is already set with begin{scope}[decoration=zigzag] you can remove [decoration=zigzag] from the path to clean it up a bit.

    – erik
    Apr 23 '13 at 11:34











  • @erik Indeed I missed that. Thanks.

    – percusse
    Apr 23 '13 at 11:46



















  • Just a note: since the default decoration for the scope is already set with begin{scope}[decoration=zigzag] you can remove [decoration=zigzag] from the path to clean it up a bit.

    – erik
    Apr 23 '13 at 11:34











  • @erik Indeed I missed that. Thanks.

    – percusse
    Apr 23 '13 at 11:46

















Just a note: since the default decoration for the scope is already set with begin{scope}[decoration=zigzag] you can remove [decoration=zigzag] from the path to clean it up a bit.

– erik
Apr 23 '13 at 11:34





Just a note: since the default decoration for the scope is already set with begin{scope}[decoration=zigzag] you can remove [decoration=zigzag] from the path to clean it up a bit.

– erik
Apr 23 '13 at 11:34













@erik Indeed I missed that. Thanks.

– percusse
Apr 23 '13 at 11:46





@erik Indeed I missed that. Thanks.

– percusse
Apr 23 '13 at 11:46


















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%2f110222%2fproblems-with-filling-a-path-that-includes-decorations-in-tikz%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

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?