Colorize sides regular polygon











up vote
5
down vote

favorite












To illustrate what edge-coloring is, I'd like to colorize a regular polygon. I want to generate the shape using TikZ, then colorize the sides (edges) of the polygon separately, for instance by doing something like this:



draw[red] (polygon.side 1);


Unfortunately, the world does not seem to work like this. For now my ugly workaround is to overdraw using dotted, dashed, and thick lines.



documentclass{standalone}
usepackage{tikz}
usetikzlibrary{shapes.geometric,positioning}

begin{document}
begin{tikzpicture}
node[draw, dotted, minimum size=2cm, regular polygon,
regular polygon sides=5] (polygon) {};
draw[thick] (polygon.corner 1) -- (polygon.corner 2);
draw[dashed] (polygon.corner 2) -- (polygon.corner 3);
draw[thick] (polygon.corner 4) -- (polygon.corner 5);
draw[dashed] (polygon.corner 5) -- (polygon.corner 1);
end{tikzpicture}
end{document}


edge-colored pentagon



Thanks!










share|improve this question






















  • Do you really want to use a node?
    – Sigur
    Nov 21 at 23:02










  • I want the simplest thing possible. I may have driven into the wrong direction. Also, why wouldn't I want a node?
    – Antonin Décimo
    Nov 21 at 23:04

















up vote
5
down vote

favorite












To illustrate what edge-coloring is, I'd like to colorize a regular polygon. I want to generate the shape using TikZ, then colorize the sides (edges) of the polygon separately, for instance by doing something like this:



draw[red] (polygon.side 1);


Unfortunately, the world does not seem to work like this. For now my ugly workaround is to overdraw using dotted, dashed, and thick lines.



documentclass{standalone}
usepackage{tikz}
usetikzlibrary{shapes.geometric,positioning}

begin{document}
begin{tikzpicture}
node[draw, dotted, minimum size=2cm, regular polygon,
regular polygon sides=5] (polygon) {};
draw[thick] (polygon.corner 1) -- (polygon.corner 2);
draw[dashed] (polygon.corner 2) -- (polygon.corner 3);
draw[thick] (polygon.corner 4) -- (polygon.corner 5);
draw[dashed] (polygon.corner 5) -- (polygon.corner 1);
end{tikzpicture}
end{document}


edge-colored pentagon



Thanks!










share|improve this question






















  • Do you really want to use a node?
    – Sigur
    Nov 21 at 23:02










  • I want the simplest thing possible. I may have driven into the wrong direction. Also, why wouldn't I want a node?
    – Antonin Décimo
    Nov 21 at 23:04















up vote
5
down vote

favorite









up vote
5
down vote

favorite











To illustrate what edge-coloring is, I'd like to colorize a regular polygon. I want to generate the shape using TikZ, then colorize the sides (edges) of the polygon separately, for instance by doing something like this:



draw[red] (polygon.side 1);


Unfortunately, the world does not seem to work like this. For now my ugly workaround is to overdraw using dotted, dashed, and thick lines.



documentclass{standalone}
usepackage{tikz}
usetikzlibrary{shapes.geometric,positioning}

begin{document}
begin{tikzpicture}
node[draw, dotted, minimum size=2cm, regular polygon,
regular polygon sides=5] (polygon) {};
draw[thick] (polygon.corner 1) -- (polygon.corner 2);
draw[dashed] (polygon.corner 2) -- (polygon.corner 3);
draw[thick] (polygon.corner 4) -- (polygon.corner 5);
draw[dashed] (polygon.corner 5) -- (polygon.corner 1);
end{tikzpicture}
end{document}


edge-colored pentagon



Thanks!










share|improve this question













To illustrate what edge-coloring is, I'd like to colorize a regular polygon. I want to generate the shape using TikZ, then colorize the sides (edges) of the polygon separately, for instance by doing something like this:



draw[red] (polygon.side 1);


Unfortunately, the world does not seem to work like this. For now my ugly workaround is to overdraw using dotted, dashed, and thick lines.



documentclass{standalone}
usepackage{tikz}
usetikzlibrary{shapes.geometric,positioning}

begin{document}
begin{tikzpicture}
node[draw, dotted, minimum size=2cm, regular polygon,
regular polygon sides=5] (polygon) {};
draw[thick] (polygon.corner 1) -- (polygon.corner 2);
draw[dashed] (polygon.corner 2) -- (polygon.corner 3);
draw[thick] (polygon.corner 4) -- (polygon.corner 5);
draw[dashed] (polygon.corner 5) -- (polygon.corner 1);
end{tikzpicture}
end{document}


edge-colored pentagon



Thanks!







tikz-pgf graphs tikz-shape polygon






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 at 22:59









Antonin Décimo

534




534












  • Do you really want to use a node?
    – Sigur
    Nov 21 at 23:02










  • I want the simplest thing possible. I may have driven into the wrong direction. Also, why wouldn't I want a node?
    – Antonin Décimo
    Nov 21 at 23:04




















  • Do you really want to use a node?
    – Sigur
    Nov 21 at 23:02










  • I want the simplest thing possible. I may have driven into the wrong direction. Also, why wouldn't I want a node?
    – Antonin Décimo
    Nov 21 at 23:04


















Do you really want to use a node?
– Sigur
Nov 21 at 23:02




Do you really want to use a node?
– Sigur
Nov 21 at 23:02












I want the simplest thing possible. I may have driven into the wrong direction. Also, why wouldn't I want a node?
– Antonin Décimo
Nov 21 at 23:04






I want the simplest thing possible. I may have driven into the wrong direction. Also, why wouldn't I want a node?
– Antonin Décimo
Nov 21 at 23:04












3 Answers
3






active

oldest

votes

















up vote
3
down vote



accepted










With regular polygon colors option, there's no need for extra commands to draw the sides. Everything is done within the node command.



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{shapes.geometric, positioning}

begin{document}
begin{tikzpicture}[
regular polygon colors/.style 2 args={
append after command={%
pgfextra
foreach i [count=ni, remember=ni as lasti (initially #1)] in {#2}{
draw[i] (tikzlastnode.corner lasti) --(tikzlastnode.corner ni);}
endpgfextra
}
},
]
node[minimum size=2cm, regular polygon,
regular polygon sides=5,
regular polygon colors={5}{red,blue,orange,green,cyan}] (polygon) {};

node[minimum size=2cm, regular polygon,
regular polygon sides=7,
regular polygon colors={7}{red, blue, orange, green, cyan, violet, brown},
right=of polygon] (polygon2) {};
end{tikzpicture}

end{document}


enter image description here






share|improve this answer




























    up vote
    5
    down vote













    Like this?



    enter image description here



    documentclass[margin=1mm]{standalone}
    usepackage{tikz}

    begin{document}
    begin{tikzpicture}[thick]
    foreach i/c in {90/red,162/blue,234/green,306/pink,378/orange}{
    draw[c] (i:1cm) -- (72+i:1cm);
    }
    end{tikzpicture}
    end{document}


    Edit 1: Another option, to have a better join line:



    enter image description here



    begin{tikzpicture}[thick]
    foreach i/c in {90/red,162/blue,234/green,306/pink,378/orange}{
    fill[c] (i:1cm) -- (72+i:1cm) -- (0,0) -- cycle;
    }
    fill[white] (90:.95cm)--(162:.95cm)--(234:.95cm)--(306:.95cm)--(378:.95cm)--cycle;
    end{tikzpicture}


    Edit 2: just for fun.



    enter image description here



    begin{tikzpicture}
    foreach r in {1,.9,...,.1}{
    pgfmathparse{30 * r}%
    pgfmathsetmacropercent{pgfmathresult}
    foreach i/c in {90/red,162/blue,234/green,306/pink,378/orange}{
    fill[c!percent] (i:r cm) -- (72+i:r cm) -- (0,0) -- cycle;
    }}
    end{tikzpicture}





    share|improve this answer






























      up vote
      3
      down vote













      Here is a proposal that defines a style polygon side which can be used e.g. like draw[red,polygon side=2]; to draw the second side red.



      documentclass[tikz,border=3.14mm]{standalone}
      usetikzlibrary{shapes.geometric}

      begin{document}
      begin{tikzpicture}[get next vertex/.code n args={2}{%
      pgfmathparse{int(1+mod(#1,5))}
      xdef#2{pgfmathresult}},
      polygon side/.style={get next vertex={#1}{tmpnextn},
      insert path={(polygon.corner #1)-- (polygon.corner tmpnextn)}}
      ]
      node[draw, dotted, minimum size=2cm, regular polygon,
      regular polygon sides=5] (polygon) {};
      foreach X [count=Y] in {red,blue,orange,green,cyan}
      {draw[X,polygon side=Y];}
      end{tikzpicture}
      end{document}


      enter image description here



      Note that as of now the number of corners (or sides) as well as the name of the object (or node), polygon, are hard coded. One could of course use pgfkeys to store them in some keys, and if you ask me to I'll be happy to add this to this answer.






      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%2f461207%2fcolorize-sides-regular-polygon%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
        3
        down vote



        accepted










        With regular polygon colors option, there's no need for extra commands to draw the sides. Everything is done within the node command.



        documentclass[tikz,border=3.14mm]{standalone}
        usetikzlibrary{shapes.geometric, positioning}

        begin{document}
        begin{tikzpicture}[
        regular polygon colors/.style 2 args={
        append after command={%
        pgfextra
        foreach i [count=ni, remember=ni as lasti (initially #1)] in {#2}{
        draw[i] (tikzlastnode.corner lasti) --(tikzlastnode.corner ni);}
        endpgfextra
        }
        },
        ]
        node[minimum size=2cm, regular polygon,
        regular polygon sides=5,
        regular polygon colors={5}{red,blue,orange,green,cyan}] (polygon) {};

        node[minimum size=2cm, regular polygon,
        regular polygon sides=7,
        regular polygon colors={7}{red, blue, orange, green, cyan, violet, brown},
        right=of polygon] (polygon2) {};
        end{tikzpicture}

        end{document}


        enter image description here






        share|improve this answer

























          up vote
          3
          down vote



          accepted










          With regular polygon colors option, there's no need for extra commands to draw the sides. Everything is done within the node command.



          documentclass[tikz,border=3.14mm]{standalone}
          usetikzlibrary{shapes.geometric, positioning}

          begin{document}
          begin{tikzpicture}[
          regular polygon colors/.style 2 args={
          append after command={%
          pgfextra
          foreach i [count=ni, remember=ni as lasti (initially #1)] in {#2}{
          draw[i] (tikzlastnode.corner lasti) --(tikzlastnode.corner ni);}
          endpgfextra
          }
          },
          ]
          node[minimum size=2cm, regular polygon,
          regular polygon sides=5,
          regular polygon colors={5}{red,blue,orange,green,cyan}] (polygon) {};

          node[minimum size=2cm, regular polygon,
          regular polygon sides=7,
          regular polygon colors={7}{red, blue, orange, green, cyan, violet, brown},
          right=of polygon] (polygon2) {};
          end{tikzpicture}

          end{document}


          enter image description here






          share|improve this answer























            up vote
            3
            down vote



            accepted







            up vote
            3
            down vote



            accepted






            With regular polygon colors option, there's no need for extra commands to draw the sides. Everything is done within the node command.



            documentclass[tikz,border=3.14mm]{standalone}
            usetikzlibrary{shapes.geometric, positioning}

            begin{document}
            begin{tikzpicture}[
            regular polygon colors/.style 2 args={
            append after command={%
            pgfextra
            foreach i [count=ni, remember=ni as lasti (initially #1)] in {#2}{
            draw[i] (tikzlastnode.corner lasti) --(tikzlastnode.corner ni);}
            endpgfextra
            }
            },
            ]
            node[minimum size=2cm, regular polygon,
            regular polygon sides=5,
            regular polygon colors={5}{red,blue,orange,green,cyan}] (polygon) {};

            node[minimum size=2cm, regular polygon,
            regular polygon sides=7,
            regular polygon colors={7}{red, blue, orange, green, cyan, violet, brown},
            right=of polygon] (polygon2) {};
            end{tikzpicture}

            end{document}


            enter image description here






            share|improve this answer












            With regular polygon colors option, there's no need for extra commands to draw the sides. Everything is done within the node command.



            documentclass[tikz,border=3.14mm]{standalone}
            usetikzlibrary{shapes.geometric, positioning}

            begin{document}
            begin{tikzpicture}[
            regular polygon colors/.style 2 args={
            append after command={%
            pgfextra
            foreach i [count=ni, remember=ni as lasti (initially #1)] in {#2}{
            draw[i] (tikzlastnode.corner lasti) --(tikzlastnode.corner ni);}
            endpgfextra
            }
            },
            ]
            node[minimum size=2cm, regular polygon,
            regular polygon sides=5,
            regular polygon colors={5}{red,blue,orange,green,cyan}] (polygon) {};

            node[minimum size=2cm, regular polygon,
            regular polygon sides=7,
            regular polygon colors={7}{red, blue, orange, green, cyan, violet, brown},
            right=of polygon] (polygon2) {};
            end{tikzpicture}

            end{document}


            enter image description here







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 22 at 8:55









            Ignasi

            90.7k4164303




            90.7k4164303






















                up vote
                5
                down vote













                Like this?



                enter image description here



                documentclass[margin=1mm]{standalone}
                usepackage{tikz}

                begin{document}
                begin{tikzpicture}[thick]
                foreach i/c in {90/red,162/blue,234/green,306/pink,378/orange}{
                draw[c] (i:1cm) -- (72+i:1cm);
                }
                end{tikzpicture}
                end{document}


                Edit 1: Another option, to have a better join line:



                enter image description here



                begin{tikzpicture}[thick]
                foreach i/c in {90/red,162/blue,234/green,306/pink,378/orange}{
                fill[c] (i:1cm) -- (72+i:1cm) -- (0,0) -- cycle;
                }
                fill[white] (90:.95cm)--(162:.95cm)--(234:.95cm)--(306:.95cm)--(378:.95cm)--cycle;
                end{tikzpicture}


                Edit 2: just for fun.



                enter image description here



                begin{tikzpicture}
                foreach r in {1,.9,...,.1}{
                pgfmathparse{30 * r}%
                pgfmathsetmacropercent{pgfmathresult}
                foreach i/c in {90/red,162/blue,234/green,306/pink,378/orange}{
                fill[c!percent] (i:r cm) -- (72+i:r cm) -- (0,0) -- cycle;
                }}
                end{tikzpicture}





                share|improve this answer



























                  up vote
                  5
                  down vote













                  Like this?



                  enter image description here



                  documentclass[margin=1mm]{standalone}
                  usepackage{tikz}

                  begin{document}
                  begin{tikzpicture}[thick]
                  foreach i/c in {90/red,162/blue,234/green,306/pink,378/orange}{
                  draw[c] (i:1cm) -- (72+i:1cm);
                  }
                  end{tikzpicture}
                  end{document}


                  Edit 1: Another option, to have a better join line:



                  enter image description here



                  begin{tikzpicture}[thick]
                  foreach i/c in {90/red,162/blue,234/green,306/pink,378/orange}{
                  fill[c] (i:1cm) -- (72+i:1cm) -- (0,0) -- cycle;
                  }
                  fill[white] (90:.95cm)--(162:.95cm)--(234:.95cm)--(306:.95cm)--(378:.95cm)--cycle;
                  end{tikzpicture}


                  Edit 2: just for fun.



                  enter image description here



                  begin{tikzpicture}
                  foreach r in {1,.9,...,.1}{
                  pgfmathparse{30 * r}%
                  pgfmathsetmacropercent{pgfmathresult}
                  foreach i/c in {90/red,162/blue,234/green,306/pink,378/orange}{
                  fill[c!percent] (i:r cm) -- (72+i:r cm) -- (0,0) -- cycle;
                  }}
                  end{tikzpicture}





                  share|improve this answer

























                    up vote
                    5
                    down vote










                    up vote
                    5
                    down vote









                    Like this?



                    enter image description here



                    documentclass[margin=1mm]{standalone}
                    usepackage{tikz}

                    begin{document}
                    begin{tikzpicture}[thick]
                    foreach i/c in {90/red,162/blue,234/green,306/pink,378/orange}{
                    draw[c] (i:1cm) -- (72+i:1cm);
                    }
                    end{tikzpicture}
                    end{document}


                    Edit 1: Another option, to have a better join line:



                    enter image description here



                    begin{tikzpicture}[thick]
                    foreach i/c in {90/red,162/blue,234/green,306/pink,378/orange}{
                    fill[c] (i:1cm) -- (72+i:1cm) -- (0,0) -- cycle;
                    }
                    fill[white] (90:.95cm)--(162:.95cm)--(234:.95cm)--(306:.95cm)--(378:.95cm)--cycle;
                    end{tikzpicture}


                    Edit 2: just for fun.



                    enter image description here



                    begin{tikzpicture}
                    foreach r in {1,.9,...,.1}{
                    pgfmathparse{30 * r}%
                    pgfmathsetmacropercent{pgfmathresult}
                    foreach i/c in {90/red,162/blue,234/green,306/pink,378/orange}{
                    fill[c!percent] (i:r cm) -- (72+i:r cm) -- (0,0) -- cycle;
                    }}
                    end{tikzpicture}





                    share|improve this answer














                    Like this?



                    enter image description here



                    documentclass[margin=1mm]{standalone}
                    usepackage{tikz}

                    begin{document}
                    begin{tikzpicture}[thick]
                    foreach i/c in {90/red,162/blue,234/green,306/pink,378/orange}{
                    draw[c] (i:1cm) -- (72+i:1cm);
                    }
                    end{tikzpicture}
                    end{document}


                    Edit 1: Another option, to have a better join line:



                    enter image description here



                    begin{tikzpicture}[thick]
                    foreach i/c in {90/red,162/blue,234/green,306/pink,378/orange}{
                    fill[c] (i:1cm) -- (72+i:1cm) -- (0,0) -- cycle;
                    }
                    fill[white] (90:.95cm)--(162:.95cm)--(234:.95cm)--(306:.95cm)--(378:.95cm)--cycle;
                    end{tikzpicture}


                    Edit 2: just for fun.



                    enter image description here



                    begin{tikzpicture}
                    foreach r in {1,.9,...,.1}{
                    pgfmathparse{30 * r}%
                    pgfmathsetmacropercent{pgfmathresult}
                    foreach i/c in {90/red,162/blue,234/green,306/pink,378/orange}{
                    fill[c!percent] (i:r cm) -- (72+i:r cm) -- (0,0) -- cycle;
                    }}
                    end{tikzpicture}






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Nov 21 at 23:37

























                    answered Nov 21 at 23:08









                    Sigur

                    23.6k354135




                    23.6k354135






















                        up vote
                        3
                        down vote













                        Here is a proposal that defines a style polygon side which can be used e.g. like draw[red,polygon side=2]; to draw the second side red.



                        documentclass[tikz,border=3.14mm]{standalone}
                        usetikzlibrary{shapes.geometric}

                        begin{document}
                        begin{tikzpicture}[get next vertex/.code n args={2}{%
                        pgfmathparse{int(1+mod(#1,5))}
                        xdef#2{pgfmathresult}},
                        polygon side/.style={get next vertex={#1}{tmpnextn},
                        insert path={(polygon.corner #1)-- (polygon.corner tmpnextn)}}
                        ]
                        node[draw, dotted, minimum size=2cm, regular polygon,
                        regular polygon sides=5] (polygon) {};
                        foreach X [count=Y] in {red,blue,orange,green,cyan}
                        {draw[X,polygon side=Y];}
                        end{tikzpicture}
                        end{document}


                        enter image description here



                        Note that as of now the number of corners (or sides) as well as the name of the object (or node), polygon, are hard coded. One could of course use pgfkeys to store them in some keys, and if you ask me to I'll be happy to add this to this answer.






                        share|improve this answer

























                          up vote
                          3
                          down vote













                          Here is a proposal that defines a style polygon side which can be used e.g. like draw[red,polygon side=2]; to draw the second side red.



                          documentclass[tikz,border=3.14mm]{standalone}
                          usetikzlibrary{shapes.geometric}

                          begin{document}
                          begin{tikzpicture}[get next vertex/.code n args={2}{%
                          pgfmathparse{int(1+mod(#1,5))}
                          xdef#2{pgfmathresult}},
                          polygon side/.style={get next vertex={#1}{tmpnextn},
                          insert path={(polygon.corner #1)-- (polygon.corner tmpnextn)}}
                          ]
                          node[draw, dotted, minimum size=2cm, regular polygon,
                          regular polygon sides=5] (polygon) {};
                          foreach X [count=Y] in {red,blue,orange,green,cyan}
                          {draw[X,polygon side=Y];}
                          end{tikzpicture}
                          end{document}


                          enter image description here



                          Note that as of now the number of corners (or sides) as well as the name of the object (or node), polygon, are hard coded. One could of course use pgfkeys to store them in some keys, and if you ask me to I'll be happy to add this to this answer.






                          share|improve this answer























                            up vote
                            3
                            down vote










                            up vote
                            3
                            down vote









                            Here is a proposal that defines a style polygon side which can be used e.g. like draw[red,polygon side=2]; to draw the second side red.



                            documentclass[tikz,border=3.14mm]{standalone}
                            usetikzlibrary{shapes.geometric}

                            begin{document}
                            begin{tikzpicture}[get next vertex/.code n args={2}{%
                            pgfmathparse{int(1+mod(#1,5))}
                            xdef#2{pgfmathresult}},
                            polygon side/.style={get next vertex={#1}{tmpnextn},
                            insert path={(polygon.corner #1)-- (polygon.corner tmpnextn)}}
                            ]
                            node[draw, dotted, minimum size=2cm, regular polygon,
                            regular polygon sides=5] (polygon) {};
                            foreach X [count=Y] in {red,blue,orange,green,cyan}
                            {draw[X,polygon side=Y];}
                            end{tikzpicture}
                            end{document}


                            enter image description here



                            Note that as of now the number of corners (or sides) as well as the name of the object (or node), polygon, are hard coded. One could of course use pgfkeys to store them in some keys, and if you ask me to I'll be happy to add this to this answer.






                            share|improve this answer












                            Here is a proposal that defines a style polygon side which can be used e.g. like draw[red,polygon side=2]; to draw the second side red.



                            documentclass[tikz,border=3.14mm]{standalone}
                            usetikzlibrary{shapes.geometric}

                            begin{document}
                            begin{tikzpicture}[get next vertex/.code n args={2}{%
                            pgfmathparse{int(1+mod(#1,5))}
                            xdef#2{pgfmathresult}},
                            polygon side/.style={get next vertex={#1}{tmpnextn},
                            insert path={(polygon.corner #1)-- (polygon.corner tmpnextn)}}
                            ]
                            node[draw, dotted, minimum size=2cm, regular polygon,
                            regular polygon sides=5] (polygon) {};
                            foreach X [count=Y] in {red,blue,orange,green,cyan}
                            {draw[X,polygon side=Y];}
                            end{tikzpicture}
                            end{document}


                            enter image description here



                            Note that as of now the number of corners (or sides) as well as the name of the object (or node), polygon, are hard coded. One could of course use pgfkeys to store them in some keys, and if you ask me to I'll be happy to add this to this answer.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 21 at 23:27









                            marmot

                            81k491173




                            81k491173






























                                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%2f461207%2fcolorize-sides-regular-polygon%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

                                Plaza Victoria

                                In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

                                How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...