Regular polygon VS circle shapes in TikZ












5















This question is a kind of continuation this answer. There, it remains unclear which is the origin of the white space around the node content, if a square shape is used, and I would like to understand this. Given the following MWE



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

begin{document}
begin{tikzpicture}[every node/.style={draw, inner sep=0}]
node[regular polygon,regular polygon sides=4] (a) {XX};
node[regular polygon,regular polygon sides=100, blue] (b) {XX};
node[circle] (c) {XX};
foreach a in {north,south,east,west,north east,south east,north west,south west}{
fill[red] (a.a) circle(0.5pt);
fill[yellow] (b.a) circle(0.25pt);
fill[orange] (c.a) circle(0.25pt);
}
end{tikzpicture}
end{document}


I am a bit surprised that the black circle has a radius which is smaller than that of the inscribed circle in the polygon, since the pgf manual says




[...] the border of the polygon is always constructed using the
incircle, whose radius is calculated to tightly fit the node contents
(including any inner sep).




To show what I would have expected and what I would like to have I added a blue "fake circle" to the MWE as a regular polygon with 100 sides. Is there a way to draw such a blue circle using the circle shape, i.e. node[circle, ...]{XX};? Playing by hand with inner sep is not an option for me.



As clarification/additional information, I am interested in having a node shape to be used in a wider context, i.e. not in relation with the square. And also receiving an explanation about why the 4-sides polygon leaves so much space despite the inner sep=0 would be highly appreciated.





                 Figure MWE










share|improve this question

























  • You can see in the manual that for empty nodes the ratio is sqrt(2) (but I don't know why). In the manual a regular polygon with inner space equal to 0.3535cm (which is sqrt(2)/4) is tangent to circle with radius 1/2 cm.

    – Kpym
    1 hour ago











  • I had noticed that strange inner sep in the example. But I had also noticed that it was about an empty node. If I have an arbitrary node content, I would then need to adjust that 0.3535cm magic number (and I should think about how). Are you suggesting something like that?

    – Axel Krypton
    1 hour ago











  • You can see in the code that the inner circle radius is 1.41421 times the half of the longest side of the content box plus the inner sep.

    – Kpym
    43 mins ago













  • This sqrt(2) factor does make sense if you assume the the content is approximately quadratic. And I do not understand the question. That is, I thought I did before I saw the answers. Could you perhaps indicate to which extent the answers address the question. I am really confused.

    – marmot
    3 mins ago
















5















This question is a kind of continuation this answer. There, it remains unclear which is the origin of the white space around the node content, if a square shape is used, and I would like to understand this. Given the following MWE



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

begin{document}
begin{tikzpicture}[every node/.style={draw, inner sep=0}]
node[regular polygon,regular polygon sides=4] (a) {XX};
node[regular polygon,regular polygon sides=100, blue] (b) {XX};
node[circle] (c) {XX};
foreach a in {north,south,east,west,north east,south east,north west,south west}{
fill[red] (a.a) circle(0.5pt);
fill[yellow] (b.a) circle(0.25pt);
fill[orange] (c.a) circle(0.25pt);
}
end{tikzpicture}
end{document}


I am a bit surprised that the black circle has a radius which is smaller than that of the inscribed circle in the polygon, since the pgf manual says




[...] the border of the polygon is always constructed using the
incircle, whose radius is calculated to tightly fit the node contents
(including any inner sep).




To show what I would have expected and what I would like to have I added a blue "fake circle" to the MWE as a regular polygon with 100 sides. Is there a way to draw such a blue circle using the circle shape, i.e. node[circle, ...]{XX};? Playing by hand with inner sep is not an option for me.



As clarification/additional information, I am interested in having a node shape to be used in a wider context, i.e. not in relation with the square. And also receiving an explanation about why the 4-sides polygon leaves so much space despite the inner sep=0 would be highly appreciated.





                 Figure MWE










share|improve this question

























  • You can see in the manual that for empty nodes the ratio is sqrt(2) (but I don't know why). In the manual a regular polygon with inner space equal to 0.3535cm (which is sqrt(2)/4) is tangent to circle with radius 1/2 cm.

    – Kpym
    1 hour ago











  • I had noticed that strange inner sep in the example. But I had also noticed that it was about an empty node. If I have an arbitrary node content, I would then need to adjust that 0.3535cm magic number (and I should think about how). Are you suggesting something like that?

    – Axel Krypton
    1 hour ago











  • You can see in the code that the inner circle radius is 1.41421 times the half of the longest side of the content box plus the inner sep.

    – Kpym
    43 mins ago













  • This sqrt(2) factor does make sense if you assume the the content is approximately quadratic. And I do not understand the question. That is, I thought I did before I saw the answers. Could you perhaps indicate to which extent the answers address the question. I am really confused.

    – marmot
    3 mins ago














5












5








5








This question is a kind of continuation this answer. There, it remains unclear which is the origin of the white space around the node content, if a square shape is used, and I would like to understand this. Given the following MWE



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

begin{document}
begin{tikzpicture}[every node/.style={draw, inner sep=0}]
node[regular polygon,regular polygon sides=4] (a) {XX};
node[regular polygon,regular polygon sides=100, blue] (b) {XX};
node[circle] (c) {XX};
foreach a in {north,south,east,west,north east,south east,north west,south west}{
fill[red] (a.a) circle(0.5pt);
fill[yellow] (b.a) circle(0.25pt);
fill[orange] (c.a) circle(0.25pt);
}
end{tikzpicture}
end{document}


I am a bit surprised that the black circle has a radius which is smaller than that of the inscribed circle in the polygon, since the pgf manual says




[...] the border of the polygon is always constructed using the
incircle, whose radius is calculated to tightly fit the node contents
(including any inner sep).




To show what I would have expected and what I would like to have I added a blue "fake circle" to the MWE as a regular polygon with 100 sides. Is there a way to draw such a blue circle using the circle shape, i.e. node[circle, ...]{XX};? Playing by hand with inner sep is not an option for me.



As clarification/additional information, I am interested in having a node shape to be used in a wider context, i.e. not in relation with the square. And also receiving an explanation about why the 4-sides polygon leaves so much space despite the inner sep=0 would be highly appreciated.





                 Figure MWE










share|improve this question
















This question is a kind of continuation this answer. There, it remains unclear which is the origin of the white space around the node content, if a square shape is used, and I would like to understand this. Given the following MWE



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

begin{document}
begin{tikzpicture}[every node/.style={draw, inner sep=0}]
node[regular polygon,regular polygon sides=4] (a) {XX};
node[regular polygon,regular polygon sides=100, blue] (b) {XX};
node[circle] (c) {XX};
foreach a in {north,south,east,west,north east,south east,north west,south west}{
fill[red] (a.a) circle(0.5pt);
fill[yellow] (b.a) circle(0.25pt);
fill[orange] (c.a) circle(0.25pt);
}
end{tikzpicture}
end{document}


I am a bit surprised that the black circle has a radius which is smaller than that of the inscribed circle in the polygon, since the pgf manual says




[...] the border of the polygon is always constructed using the
incircle, whose radius is calculated to tightly fit the node contents
(including any inner sep).




To show what I would have expected and what I would like to have I added a blue "fake circle" to the MWE as a regular polygon with 100 sides. Is there a way to draw such a blue circle using the circle shape, i.e. node[circle, ...]{XX};? Playing by hand with inner sep is not an option for me.



As clarification/additional information, I am interested in having a node shape to be used in a wider context, i.e. not in relation with the square. And also receiving an explanation about why the 4-sides polygon leaves so much space despite the inner sep=0 would be highly appreciated.





                 Figure MWE







tikz-pgf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 hours ago







Axel Krypton

















asked 3 hours ago









Axel KryptonAxel Krypton

443110




443110













  • You can see in the manual that for empty nodes the ratio is sqrt(2) (but I don't know why). In the manual a regular polygon with inner space equal to 0.3535cm (which is sqrt(2)/4) is tangent to circle with radius 1/2 cm.

    – Kpym
    1 hour ago











  • I had noticed that strange inner sep in the example. But I had also noticed that it was about an empty node. If I have an arbitrary node content, I would then need to adjust that 0.3535cm magic number (and I should think about how). Are you suggesting something like that?

    – Axel Krypton
    1 hour ago











  • You can see in the code that the inner circle radius is 1.41421 times the half of the longest side of the content box plus the inner sep.

    – Kpym
    43 mins ago













  • This sqrt(2) factor does make sense if you assume the the content is approximately quadratic. And I do not understand the question. That is, I thought I did before I saw the answers. Could you perhaps indicate to which extent the answers address the question. I am really confused.

    – marmot
    3 mins ago



















  • You can see in the manual that for empty nodes the ratio is sqrt(2) (but I don't know why). In the manual a regular polygon with inner space equal to 0.3535cm (which is sqrt(2)/4) is tangent to circle with radius 1/2 cm.

    – Kpym
    1 hour ago











  • I had noticed that strange inner sep in the example. But I had also noticed that it was about an empty node. If I have an arbitrary node content, I would then need to adjust that 0.3535cm magic number (and I should think about how). Are you suggesting something like that?

    – Axel Krypton
    1 hour ago











  • You can see in the code that the inner circle radius is 1.41421 times the half of the longest side of the content box plus the inner sep.

    – Kpym
    43 mins ago













  • This sqrt(2) factor does make sense if you assume the the content is approximately quadratic. And I do not understand the question. That is, I thought I did before I saw the answers. Could you perhaps indicate to which extent the answers address the question. I am really confused.

    – marmot
    3 mins ago

















You can see in the manual that for empty nodes the ratio is sqrt(2) (but I don't know why). In the manual a regular polygon with inner space equal to 0.3535cm (which is sqrt(2)/4) is tangent to circle with radius 1/2 cm.

– Kpym
1 hour ago





You can see in the manual that for empty nodes the ratio is sqrt(2) (but I don't know why). In the manual a regular polygon with inner space equal to 0.3535cm (which is sqrt(2)/4) is tangent to circle with radius 1/2 cm.

– Kpym
1 hour ago













I had noticed that strange inner sep in the example. But I had also noticed that it was about an empty node. If I have an arbitrary node content, I would then need to adjust that 0.3535cm magic number (and I should think about how). Are you suggesting something like that?

– Axel Krypton
1 hour ago





I had noticed that strange inner sep in the example. But I had also noticed that it was about an empty node. If I have an arbitrary node content, I would then need to adjust that 0.3535cm magic number (and I should think about how). Are you suggesting something like that?

– Axel Krypton
1 hour ago













You can see in the code that the inner circle radius is 1.41421 times the half of the longest side of the content box plus the inner sep.

– Kpym
43 mins ago







You can see in the code that the inner circle radius is 1.41421 times the half of the longest side of the content box plus the inner sep.

– Kpym
43 mins ago















This sqrt(2) factor does make sense if you assume the the content is approximately quadratic. And I do not understand the question. That is, I thought I did before I saw the answers. Could you perhaps indicate to which extent the answers address the question. I am really confused.

– marmot
3 mins ago





This sqrt(2) factor does make sense if you assume the the content is approximately quadratic. And I do not understand the question. That is, I thought I did before I saw the answers. Could you perhaps indicate to which extent the answers address the question. I am really confused.

– marmot
3 mins ago










2 Answers
2






active

oldest

votes


















2














Using through library of Tikz.



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

begin{document}
begin{tikzpicture}[every node/.style={draw, inner sep=0}]
node[regular polygon,regular polygon sides=4] (a) {XX};
node (b) [draw,blue, circle through=(a.north)] at (a.center) {XX};
node[circle] (c) {XX};
foreach a in {north,south,east,west,north east,south east,north west,south west}{
fill[red] (a.a) circle(0.5pt);
fill[yellow] (b.a) circle(0.25pt);
fill[orange] (c.a) circle(0.25pt);
}

end{tikzpicture}
end{document}


enter image description here






share|improve this answer
























  • Although strictly speaking you proposed a valid way to draw the blue circle, I was more interested in a general way to draw that shape for a node, without having to rely to another node/point (see edit question). The only way I see I could use your idea is to always have two nodes, one invisible and one that would be the node I wish. However, this is not what I am looking for.

    – Axel Krypton
    1 hour ago



















1














The "inner circle" in shapes.geometric has a radius that is half of the longest side of the content box plus the inner sep, and multiplied by 1.4142136, which is approximately sqrt(2). So to obtain a circle shape that has this behavior you can define a new shape, let's say Circle (with capital C) that is a slight modification of the existing ellipse shape.



documentclass[tikz, border=7pt, convert={density=4200}]{standalone}
usetikzlibrary{shapes.geometric}
makeatletter
pgfdeclareshape{Circle}
%
% Draws a circle around the text
% (based on the original ellipse shape)
%
{%
savedanchorcenterpoint{%
pgf@x=.5wdpgfnodeparttextbox%
pgf@y=.5htpgfnodeparttextbox%
advancepgf@y by-.5dppgfnodeparttextbox%
}%
savedanchorradius{%
%
% Calculate ``height radius''
%
pgf@y=.5htpgfnodeparttextbox%
advancepgf@y by.5dppgfnodeparttextbox%
pgfmathsetlengthpgf@yb{pgfkeysvalueof{/pgf/inner ysep}}%
advancepgf@y bypgf@yb%
%
% Calculate ``width radius''
%
pgf@x=.5wdpgfnodeparttextbox%
pgfmathsetlengthpgf@xb{pgfkeysvalueof{/pgf/inner xsep}}%
advancepgf@x bypgf@xb%
%
% Adjust
%
% ==============================
% added to ellipse shape to become circle
ifdimpgf@y>pgf@x%
pgf@xpgf@y%
else%
pgf@ypgf@x%
fi%
% ==============================
pgf@x=1.4142136pgf@x%
pgf@y=1.4142136pgf@y%
%
% Adjust height, if necessary
%
pgfmathsetlengthpgf@yc{pgfkeysvalueof{/pgf/minimum height}}%
ifdimpgf@y<.5pgf@yc%
pgf@y=.5pgf@yc%
fi%
%
% Adjust width, if necessary
%
pgfmathsetlengthpgf@xc{pgfkeysvalueof{/pgf/minimum width}}%
ifdimpgf@x<.5pgf@xc%
pgf@x=.5pgf@xc%
fi%
%
% Add outer sep
%
pgfmathsetlength{pgf@xb}{pgfkeysvalueof{/pgf/outer xsep}}%
pgfmathsetlength{pgf@yb}{pgfkeysvalueof{/pgf/outer ysep}}%
advancepgf@x bypgf@xb%
advancepgf@y bypgf@yb%
}%

%
% Anchors
%
anchor{center}{centerpoint}%
anchor{mid}{centerpointpgfmathsetlengthpgf@y{.5ex}}%
anchor{base}{centerpointpgf@y=0pt}%
anchor{north}
{
pgf@process{radius}
pgf@ya=pgf@y%
pgf@process{centerpoint}
advancepgf@y bypgf@ya
}%
anchor{south}
{
pgf@process{radius}
pgf@ya=pgf@y%
pgf@process{centerpoint}
advancepgf@y by-pgf@ya
}%
anchor{west}
{
pgf@process{radius}
pgf@xa=pgf@x%
pgf@process{centerpoint}
advancepgf@x by-pgf@xa
}%
anchor{mid west}
{%
pgf@process{radius}
pgf@xa=pgf@x%
pgf@process{centerpoint}
advancepgf@x by-pgf@xa%
pgfmathsetlengthpgf@y{.5ex}
}%
anchor{base west}
{%
pgf@process{radius}
pgf@xa=pgf@x%
pgf@process{centerpoint}
advancepgf@x by-pgf@xa%
pgf@y=0pt
}%
anchor{north west}
{
pgf@process{radius}
pgf@xa=pgf@x%
pgf@ya=pgf@y%
pgf@process{centerpoint}
advancepgf@x by-0.707107pgf@xa
advancepgf@y by0.707107pgf@ya
}%
anchor{south west}
{
pgf@process{radius}
pgf@xa=pgf@x%
pgf@ya=pgf@y%
pgf@process{centerpoint}
advancepgf@x by-0.707107pgf@xa
advancepgf@y by-0.707107pgf@ya
}%
anchor{east}
{%
pgf@process{radius}
pgf@xa=pgf@x%
pgf@process{centerpoint}
advancepgf@x bypgf@xa
}%
anchor{mid east}
{%
pgf@process{radius}
pgf@xa=pgf@x%
pgf@process{centerpoint}
advancepgf@x bypgf@xa%
pgfmathsetlengthpgf@y{.5ex}
}%
anchor{base east}
{%
pgf@process{radius}
pgf@xa=pgf@x%
pgf@process{centerpoint}
advancepgf@x bypgf@xa%
pgf@y=0pt
}%
anchor{north east}
{
pgf@process{radius}
pgf@xa=pgf@x%
pgf@ya=pgf@y%
pgf@process{centerpoint}
advancepgf@x by0.707107pgf@xa
advancepgf@y by0.707107pgf@ya
}%
anchor{south east}
{
pgf@process{radius}
pgf@xa=pgf@x%
pgf@ya=pgf@y%
pgf@process{centerpoint}
advancepgf@x by0.707107pgf@xa
advancepgf@y by-0.707107pgf@ya
}%
anchorborder{
edefpgf@marshal{%
noexpandpgfpointborderellipse
{noexpandpgfqpoint{thepgf@x}{thepgf@y}}
{noexpandradius}%
}%
pgf@marshal%
pgf@xa=pgf@x%
pgf@ya=pgf@y%
centerpoint%
advancepgf@x bypgf@xa%
advancepgf@y bypgf@ya%
}%

%
% Background path
%
backgroundpath
{
pgf@process{radius}%
pgfutil@tempdima=pgf@x%
pgfutil@tempdimb=pgf@y%
pgfmathsetlength{pgf@xb}{pgfkeysvalueof{/pgf/outer xsep}}%
pgfmathsetlength{pgf@yb}{pgfkeysvalueof{/pgf/outer ysep}}%
advancepgfutil@tempdima by-pgf@xb%
advancepgfutil@tempdimb by-pgf@yb%
pgfpathellipse{centerpoint}{pgfqpoint{pgfutil@tempdima}{0pt}}{pgfqpoint{0pt}{pgfutil@tempdimb}}%
}%
}%
makeatother

begin{document}
begin{tikzpicture}[nodes={draw, inner sep=0}]
node[regular polygon,regular polygon sides=4] (a) {XX};
node[Circle, blue] (b) {XX};
node[circle] (c) {XX};
foreach a in {north,south,east,west,north east,south east,north west,south west}{
fill[red] (a.a) circle(0.5pt);
fill[yellow] (b.a) circle(0.25pt);
fill[orange] (c.a) circle(0.25pt);
}
end{tikzpicture}
end{document}


enter image description here






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',
    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%2f480661%2fregular-polygon-vs-circle-shapes-in-tikz%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    Using through library of Tikz.



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

    begin{document}
    begin{tikzpicture}[every node/.style={draw, inner sep=0}]
    node[regular polygon,regular polygon sides=4] (a) {XX};
    node (b) [draw,blue, circle through=(a.north)] at (a.center) {XX};
    node[circle] (c) {XX};
    foreach a in {north,south,east,west,north east,south east,north west,south west}{
    fill[red] (a.a) circle(0.5pt);
    fill[yellow] (b.a) circle(0.25pt);
    fill[orange] (c.a) circle(0.25pt);
    }

    end{tikzpicture}
    end{document}


    enter image description here






    share|improve this answer
























    • Although strictly speaking you proposed a valid way to draw the blue circle, I was more interested in a general way to draw that shape for a node, without having to rely to another node/point (see edit question). The only way I see I could use your idea is to always have two nodes, one invisible and one that would be the node I wish. However, this is not what I am looking for.

      – Axel Krypton
      1 hour ago
















    2














    Using through library of Tikz.



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

    begin{document}
    begin{tikzpicture}[every node/.style={draw, inner sep=0}]
    node[regular polygon,regular polygon sides=4] (a) {XX};
    node (b) [draw,blue, circle through=(a.north)] at (a.center) {XX};
    node[circle] (c) {XX};
    foreach a in {north,south,east,west,north east,south east,north west,south west}{
    fill[red] (a.a) circle(0.5pt);
    fill[yellow] (b.a) circle(0.25pt);
    fill[orange] (c.a) circle(0.25pt);
    }

    end{tikzpicture}
    end{document}


    enter image description here






    share|improve this answer
























    • Although strictly speaking you proposed a valid way to draw the blue circle, I was more interested in a general way to draw that shape for a node, without having to rely to another node/point (see edit question). The only way I see I could use your idea is to always have two nodes, one invisible and one that would be the node I wish. However, this is not what I am looking for.

      – Axel Krypton
      1 hour ago














    2












    2








    2







    Using through library of Tikz.



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

    begin{document}
    begin{tikzpicture}[every node/.style={draw, inner sep=0}]
    node[regular polygon,regular polygon sides=4] (a) {XX};
    node (b) [draw,blue, circle through=(a.north)] at (a.center) {XX};
    node[circle] (c) {XX};
    foreach a in {north,south,east,west,north east,south east,north west,south west}{
    fill[red] (a.a) circle(0.5pt);
    fill[yellow] (b.a) circle(0.25pt);
    fill[orange] (c.a) circle(0.25pt);
    }

    end{tikzpicture}
    end{document}


    enter image description here






    share|improve this answer













    Using through library of Tikz.



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

    begin{document}
    begin{tikzpicture}[every node/.style={draw, inner sep=0}]
    node[regular polygon,regular polygon sides=4] (a) {XX};
    node (b) [draw,blue, circle through=(a.north)] at (a.center) {XX};
    node[circle] (c) {XX};
    foreach a in {north,south,east,west,north east,south east,north west,south west}{
    fill[red] (a.a) circle(0.5pt);
    fill[yellow] (b.a) circle(0.25pt);
    fill[orange] (c.a) circle(0.25pt);
    }

    end{tikzpicture}
    end{document}


    enter image description here







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 2 hours ago









    ferahfezaferahfeza

    7,01911933




    7,01911933













    • Although strictly speaking you proposed a valid way to draw the blue circle, I was more interested in a general way to draw that shape for a node, without having to rely to another node/point (see edit question). The only way I see I could use your idea is to always have two nodes, one invisible and one that would be the node I wish. However, this is not what I am looking for.

      – Axel Krypton
      1 hour ago



















    • Although strictly speaking you proposed a valid way to draw the blue circle, I was more interested in a general way to draw that shape for a node, without having to rely to another node/point (see edit question). The only way I see I could use your idea is to always have two nodes, one invisible and one that would be the node I wish. However, this is not what I am looking for.

      – Axel Krypton
      1 hour ago

















    Although strictly speaking you proposed a valid way to draw the blue circle, I was more interested in a general way to draw that shape for a node, without having to rely to another node/point (see edit question). The only way I see I could use your idea is to always have two nodes, one invisible and one that would be the node I wish. However, this is not what I am looking for.

    – Axel Krypton
    1 hour ago





    Although strictly speaking you proposed a valid way to draw the blue circle, I was more interested in a general way to draw that shape for a node, without having to rely to another node/point (see edit question). The only way I see I could use your idea is to always have two nodes, one invisible and one that would be the node I wish. However, this is not what I am looking for.

    – Axel Krypton
    1 hour ago











    1














    The "inner circle" in shapes.geometric has a radius that is half of the longest side of the content box plus the inner sep, and multiplied by 1.4142136, which is approximately sqrt(2). So to obtain a circle shape that has this behavior you can define a new shape, let's say Circle (with capital C) that is a slight modification of the existing ellipse shape.



    documentclass[tikz, border=7pt, convert={density=4200}]{standalone}
    usetikzlibrary{shapes.geometric}
    makeatletter
    pgfdeclareshape{Circle}
    %
    % Draws a circle around the text
    % (based on the original ellipse shape)
    %
    {%
    savedanchorcenterpoint{%
    pgf@x=.5wdpgfnodeparttextbox%
    pgf@y=.5htpgfnodeparttextbox%
    advancepgf@y by-.5dppgfnodeparttextbox%
    }%
    savedanchorradius{%
    %
    % Calculate ``height radius''
    %
    pgf@y=.5htpgfnodeparttextbox%
    advancepgf@y by.5dppgfnodeparttextbox%
    pgfmathsetlengthpgf@yb{pgfkeysvalueof{/pgf/inner ysep}}%
    advancepgf@y bypgf@yb%
    %
    % Calculate ``width radius''
    %
    pgf@x=.5wdpgfnodeparttextbox%
    pgfmathsetlengthpgf@xb{pgfkeysvalueof{/pgf/inner xsep}}%
    advancepgf@x bypgf@xb%
    %
    % Adjust
    %
    % ==============================
    % added to ellipse shape to become circle
    ifdimpgf@y>pgf@x%
    pgf@xpgf@y%
    else%
    pgf@ypgf@x%
    fi%
    % ==============================
    pgf@x=1.4142136pgf@x%
    pgf@y=1.4142136pgf@y%
    %
    % Adjust height, if necessary
    %
    pgfmathsetlengthpgf@yc{pgfkeysvalueof{/pgf/minimum height}}%
    ifdimpgf@y<.5pgf@yc%
    pgf@y=.5pgf@yc%
    fi%
    %
    % Adjust width, if necessary
    %
    pgfmathsetlengthpgf@xc{pgfkeysvalueof{/pgf/minimum width}}%
    ifdimpgf@x<.5pgf@xc%
    pgf@x=.5pgf@xc%
    fi%
    %
    % Add outer sep
    %
    pgfmathsetlength{pgf@xb}{pgfkeysvalueof{/pgf/outer xsep}}%
    pgfmathsetlength{pgf@yb}{pgfkeysvalueof{/pgf/outer ysep}}%
    advancepgf@x bypgf@xb%
    advancepgf@y bypgf@yb%
    }%

    %
    % Anchors
    %
    anchor{center}{centerpoint}%
    anchor{mid}{centerpointpgfmathsetlengthpgf@y{.5ex}}%
    anchor{base}{centerpointpgf@y=0pt}%
    anchor{north}
    {
    pgf@process{radius}
    pgf@ya=pgf@y%
    pgf@process{centerpoint}
    advancepgf@y bypgf@ya
    }%
    anchor{south}
    {
    pgf@process{radius}
    pgf@ya=pgf@y%
    pgf@process{centerpoint}
    advancepgf@y by-pgf@ya
    }%
    anchor{west}
    {
    pgf@process{radius}
    pgf@xa=pgf@x%
    pgf@process{centerpoint}
    advancepgf@x by-pgf@xa
    }%
    anchor{mid west}
    {%
    pgf@process{radius}
    pgf@xa=pgf@x%
    pgf@process{centerpoint}
    advancepgf@x by-pgf@xa%
    pgfmathsetlengthpgf@y{.5ex}
    }%
    anchor{base west}
    {%
    pgf@process{radius}
    pgf@xa=pgf@x%
    pgf@process{centerpoint}
    advancepgf@x by-pgf@xa%
    pgf@y=0pt
    }%
    anchor{north west}
    {
    pgf@process{radius}
    pgf@xa=pgf@x%
    pgf@ya=pgf@y%
    pgf@process{centerpoint}
    advancepgf@x by-0.707107pgf@xa
    advancepgf@y by0.707107pgf@ya
    }%
    anchor{south west}
    {
    pgf@process{radius}
    pgf@xa=pgf@x%
    pgf@ya=pgf@y%
    pgf@process{centerpoint}
    advancepgf@x by-0.707107pgf@xa
    advancepgf@y by-0.707107pgf@ya
    }%
    anchor{east}
    {%
    pgf@process{radius}
    pgf@xa=pgf@x%
    pgf@process{centerpoint}
    advancepgf@x bypgf@xa
    }%
    anchor{mid east}
    {%
    pgf@process{radius}
    pgf@xa=pgf@x%
    pgf@process{centerpoint}
    advancepgf@x bypgf@xa%
    pgfmathsetlengthpgf@y{.5ex}
    }%
    anchor{base east}
    {%
    pgf@process{radius}
    pgf@xa=pgf@x%
    pgf@process{centerpoint}
    advancepgf@x bypgf@xa%
    pgf@y=0pt
    }%
    anchor{north east}
    {
    pgf@process{radius}
    pgf@xa=pgf@x%
    pgf@ya=pgf@y%
    pgf@process{centerpoint}
    advancepgf@x by0.707107pgf@xa
    advancepgf@y by0.707107pgf@ya
    }%
    anchor{south east}
    {
    pgf@process{radius}
    pgf@xa=pgf@x%
    pgf@ya=pgf@y%
    pgf@process{centerpoint}
    advancepgf@x by0.707107pgf@xa
    advancepgf@y by-0.707107pgf@ya
    }%
    anchorborder{
    edefpgf@marshal{%
    noexpandpgfpointborderellipse
    {noexpandpgfqpoint{thepgf@x}{thepgf@y}}
    {noexpandradius}%
    }%
    pgf@marshal%
    pgf@xa=pgf@x%
    pgf@ya=pgf@y%
    centerpoint%
    advancepgf@x bypgf@xa%
    advancepgf@y bypgf@ya%
    }%

    %
    % Background path
    %
    backgroundpath
    {
    pgf@process{radius}%
    pgfutil@tempdima=pgf@x%
    pgfutil@tempdimb=pgf@y%
    pgfmathsetlength{pgf@xb}{pgfkeysvalueof{/pgf/outer xsep}}%
    pgfmathsetlength{pgf@yb}{pgfkeysvalueof{/pgf/outer ysep}}%
    advancepgfutil@tempdima by-pgf@xb%
    advancepgfutil@tempdimb by-pgf@yb%
    pgfpathellipse{centerpoint}{pgfqpoint{pgfutil@tempdima}{0pt}}{pgfqpoint{0pt}{pgfutil@tempdimb}}%
    }%
    }%
    makeatother

    begin{document}
    begin{tikzpicture}[nodes={draw, inner sep=0}]
    node[regular polygon,regular polygon sides=4] (a) {XX};
    node[Circle, blue] (b) {XX};
    node[circle] (c) {XX};
    foreach a in {north,south,east,west,north east,south east,north west,south west}{
    fill[red] (a.a) circle(0.5pt);
    fill[yellow] (b.a) circle(0.25pt);
    fill[orange] (c.a) circle(0.25pt);
    }
    end{tikzpicture}
    end{document}


    enter image description here






    share|improve this answer




























      1














      The "inner circle" in shapes.geometric has a radius that is half of the longest side of the content box plus the inner sep, and multiplied by 1.4142136, which is approximately sqrt(2). So to obtain a circle shape that has this behavior you can define a new shape, let's say Circle (with capital C) that is a slight modification of the existing ellipse shape.



      documentclass[tikz, border=7pt, convert={density=4200}]{standalone}
      usetikzlibrary{shapes.geometric}
      makeatletter
      pgfdeclareshape{Circle}
      %
      % Draws a circle around the text
      % (based on the original ellipse shape)
      %
      {%
      savedanchorcenterpoint{%
      pgf@x=.5wdpgfnodeparttextbox%
      pgf@y=.5htpgfnodeparttextbox%
      advancepgf@y by-.5dppgfnodeparttextbox%
      }%
      savedanchorradius{%
      %
      % Calculate ``height radius''
      %
      pgf@y=.5htpgfnodeparttextbox%
      advancepgf@y by.5dppgfnodeparttextbox%
      pgfmathsetlengthpgf@yb{pgfkeysvalueof{/pgf/inner ysep}}%
      advancepgf@y bypgf@yb%
      %
      % Calculate ``width radius''
      %
      pgf@x=.5wdpgfnodeparttextbox%
      pgfmathsetlengthpgf@xb{pgfkeysvalueof{/pgf/inner xsep}}%
      advancepgf@x bypgf@xb%
      %
      % Adjust
      %
      % ==============================
      % added to ellipse shape to become circle
      ifdimpgf@y>pgf@x%
      pgf@xpgf@y%
      else%
      pgf@ypgf@x%
      fi%
      % ==============================
      pgf@x=1.4142136pgf@x%
      pgf@y=1.4142136pgf@y%
      %
      % Adjust height, if necessary
      %
      pgfmathsetlengthpgf@yc{pgfkeysvalueof{/pgf/minimum height}}%
      ifdimpgf@y<.5pgf@yc%
      pgf@y=.5pgf@yc%
      fi%
      %
      % Adjust width, if necessary
      %
      pgfmathsetlengthpgf@xc{pgfkeysvalueof{/pgf/minimum width}}%
      ifdimpgf@x<.5pgf@xc%
      pgf@x=.5pgf@xc%
      fi%
      %
      % Add outer sep
      %
      pgfmathsetlength{pgf@xb}{pgfkeysvalueof{/pgf/outer xsep}}%
      pgfmathsetlength{pgf@yb}{pgfkeysvalueof{/pgf/outer ysep}}%
      advancepgf@x bypgf@xb%
      advancepgf@y bypgf@yb%
      }%

      %
      % Anchors
      %
      anchor{center}{centerpoint}%
      anchor{mid}{centerpointpgfmathsetlengthpgf@y{.5ex}}%
      anchor{base}{centerpointpgf@y=0pt}%
      anchor{north}
      {
      pgf@process{radius}
      pgf@ya=pgf@y%
      pgf@process{centerpoint}
      advancepgf@y bypgf@ya
      }%
      anchor{south}
      {
      pgf@process{radius}
      pgf@ya=pgf@y%
      pgf@process{centerpoint}
      advancepgf@y by-pgf@ya
      }%
      anchor{west}
      {
      pgf@process{radius}
      pgf@xa=pgf@x%
      pgf@process{centerpoint}
      advancepgf@x by-pgf@xa
      }%
      anchor{mid west}
      {%
      pgf@process{radius}
      pgf@xa=pgf@x%
      pgf@process{centerpoint}
      advancepgf@x by-pgf@xa%
      pgfmathsetlengthpgf@y{.5ex}
      }%
      anchor{base west}
      {%
      pgf@process{radius}
      pgf@xa=pgf@x%
      pgf@process{centerpoint}
      advancepgf@x by-pgf@xa%
      pgf@y=0pt
      }%
      anchor{north west}
      {
      pgf@process{radius}
      pgf@xa=pgf@x%
      pgf@ya=pgf@y%
      pgf@process{centerpoint}
      advancepgf@x by-0.707107pgf@xa
      advancepgf@y by0.707107pgf@ya
      }%
      anchor{south west}
      {
      pgf@process{radius}
      pgf@xa=pgf@x%
      pgf@ya=pgf@y%
      pgf@process{centerpoint}
      advancepgf@x by-0.707107pgf@xa
      advancepgf@y by-0.707107pgf@ya
      }%
      anchor{east}
      {%
      pgf@process{radius}
      pgf@xa=pgf@x%
      pgf@process{centerpoint}
      advancepgf@x bypgf@xa
      }%
      anchor{mid east}
      {%
      pgf@process{radius}
      pgf@xa=pgf@x%
      pgf@process{centerpoint}
      advancepgf@x bypgf@xa%
      pgfmathsetlengthpgf@y{.5ex}
      }%
      anchor{base east}
      {%
      pgf@process{radius}
      pgf@xa=pgf@x%
      pgf@process{centerpoint}
      advancepgf@x bypgf@xa%
      pgf@y=0pt
      }%
      anchor{north east}
      {
      pgf@process{radius}
      pgf@xa=pgf@x%
      pgf@ya=pgf@y%
      pgf@process{centerpoint}
      advancepgf@x by0.707107pgf@xa
      advancepgf@y by0.707107pgf@ya
      }%
      anchor{south east}
      {
      pgf@process{radius}
      pgf@xa=pgf@x%
      pgf@ya=pgf@y%
      pgf@process{centerpoint}
      advancepgf@x by0.707107pgf@xa
      advancepgf@y by-0.707107pgf@ya
      }%
      anchorborder{
      edefpgf@marshal{%
      noexpandpgfpointborderellipse
      {noexpandpgfqpoint{thepgf@x}{thepgf@y}}
      {noexpandradius}%
      }%
      pgf@marshal%
      pgf@xa=pgf@x%
      pgf@ya=pgf@y%
      centerpoint%
      advancepgf@x bypgf@xa%
      advancepgf@y bypgf@ya%
      }%

      %
      % Background path
      %
      backgroundpath
      {
      pgf@process{radius}%
      pgfutil@tempdima=pgf@x%
      pgfutil@tempdimb=pgf@y%
      pgfmathsetlength{pgf@xb}{pgfkeysvalueof{/pgf/outer xsep}}%
      pgfmathsetlength{pgf@yb}{pgfkeysvalueof{/pgf/outer ysep}}%
      advancepgfutil@tempdima by-pgf@xb%
      advancepgfutil@tempdimb by-pgf@yb%
      pgfpathellipse{centerpoint}{pgfqpoint{pgfutil@tempdima}{0pt}}{pgfqpoint{0pt}{pgfutil@tempdimb}}%
      }%
      }%
      makeatother

      begin{document}
      begin{tikzpicture}[nodes={draw, inner sep=0}]
      node[regular polygon,regular polygon sides=4] (a) {XX};
      node[Circle, blue] (b) {XX};
      node[circle] (c) {XX};
      foreach a in {north,south,east,west,north east,south east,north west,south west}{
      fill[red] (a.a) circle(0.5pt);
      fill[yellow] (b.a) circle(0.25pt);
      fill[orange] (c.a) circle(0.25pt);
      }
      end{tikzpicture}
      end{document}


      enter image description here






      share|improve this answer


























        1












        1








        1







        The "inner circle" in shapes.geometric has a radius that is half of the longest side of the content box plus the inner sep, and multiplied by 1.4142136, which is approximately sqrt(2). So to obtain a circle shape that has this behavior you can define a new shape, let's say Circle (with capital C) that is a slight modification of the existing ellipse shape.



        documentclass[tikz, border=7pt, convert={density=4200}]{standalone}
        usetikzlibrary{shapes.geometric}
        makeatletter
        pgfdeclareshape{Circle}
        %
        % Draws a circle around the text
        % (based on the original ellipse shape)
        %
        {%
        savedanchorcenterpoint{%
        pgf@x=.5wdpgfnodeparttextbox%
        pgf@y=.5htpgfnodeparttextbox%
        advancepgf@y by-.5dppgfnodeparttextbox%
        }%
        savedanchorradius{%
        %
        % Calculate ``height radius''
        %
        pgf@y=.5htpgfnodeparttextbox%
        advancepgf@y by.5dppgfnodeparttextbox%
        pgfmathsetlengthpgf@yb{pgfkeysvalueof{/pgf/inner ysep}}%
        advancepgf@y bypgf@yb%
        %
        % Calculate ``width radius''
        %
        pgf@x=.5wdpgfnodeparttextbox%
        pgfmathsetlengthpgf@xb{pgfkeysvalueof{/pgf/inner xsep}}%
        advancepgf@x bypgf@xb%
        %
        % Adjust
        %
        % ==============================
        % added to ellipse shape to become circle
        ifdimpgf@y>pgf@x%
        pgf@xpgf@y%
        else%
        pgf@ypgf@x%
        fi%
        % ==============================
        pgf@x=1.4142136pgf@x%
        pgf@y=1.4142136pgf@y%
        %
        % Adjust height, if necessary
        %
        pgfmathsetlengthpgf@yc{pgfkeysvalueof{/pgf/minimum height}}%
        ifdimpgf@y<.5pgf@yc%
        pgf@y=.5pgf@yc%
        fi%
        %
        % Adjust width, if necessary
        %
        pgfmathsetlengthpgf@xc{pgfkeysvalueof{/pgf/minimum width}}%
        ifdimpgf@x<.5pgf@xc%
        pgf@x=.5pgf@xc%
        fi%
        %
        % Add outer sep
        %
        pgfmathsetlength{pgf@xb}{pgfkeysvalueof{/pgf/outer xsep}}%
        pgfmathsetlength{pgf@yb}{pgfkeysvalueof{/pgf/outer ysep}}%
        advancepgf@x bypgf@xb%
        advancepgf@y bypgf@yb%
        }%

        %
        % Anchors
        %
        anchor{center}{centerpoint}%
        anchor{mid}{centerpointpgfmathsetlengthpgf@y{.5ex}}%
        anchor{base}{centerpointpgf@y=0pt}%
        anchor{north}
        {
        pgf@process{radius}
        pgf@ya=pgf@y%
        pgf@process{centerpoint}
        advancepgf@y bypgf@ya
        }%
        anchor{south}
        {
        pgf@process{radius}
        pgf@ya=pgf@y%
        pgf@process{centerpoint}
        advancepgf@y by-pgf@ya
        }%
        anchor{west}
        {
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@process{centerpoint}
        advancepgf@x by-pgf@xa
        }%
        anchor{mid west}
        {%
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@process{centerpoint}
        advancepgf@x by-pgf@xa%
        pgfmathsetlengthpgf@y{.5ex}
        }%
        anchor{base west}
        {%
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@process{centerpoint}
        advancepgf@x by-pgf@xa%
        pgf@y=0pt
        }%
        anchor{north west}
        {
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@ya=pgf@y%
        pgf@process{centerpoint}
        advancepgf@x by-0.707107pgf@xa
        advancepgf@y by0.707107pgf@ya
        }%
        anchor{south west}
        {
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@ya=pgf@y%
        pgf@process{centerpoint}
        advancepgf@x by-0.707107pgf@xa
        advancepgf@y by-0.707107pgf@ya
        }%
        anchor{east}
        {%
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@process{centerpoint}
        advancepgf@x bypgf@xa
        }%
        anchor{mid east}
        {%
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@process{centerpoint}
        advancepgf@x bypgf@xa%
        pgfmathsetlengthpgf@y{.5ex}
        }%
        anchor{base east}
        {%
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@process{centerpoint}
        advancepgf@x bypgf@xa%
        pgf@y=0pt
        }%
        anchor{north east}
        {
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@ya=pgf@y%
        pgf@process{centerpoint}
        advancepgf@x by0.707107pgf@xa
        advancepgf@y by0.707107pgf@ya
        }%
        anchor{south east}
        {
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@ya=pgf@y%
        pgf@process{centerpoint}
        advancepgf@x by0.707107pgf@xa
        advancepgf@y by-0.707107pgf@ya
        }%
        anchorborder{
        edefpgf@marshal{%
        noexpandpgfpointborderellipse
        {noexpandpgfqpoint{thepgf@x}{thepgf@y}}
        {noexpandradius}%
        }%
        pgf@marshal%
        pgf@xa=pgf@x%
        pgf@ya=pgf@y%
        centerpoint%
        advancepgf@x bypgf@xa%
        advancepgf@y bypgf@ya%
        }%

        %
        % Background path
        %
        backgroundpath
        {
        pgf@process{radius}%
        pgfutil@tempdima=pgf@x%
        pgfutil@tempdimb=pgf@y%
        pgfmathsetlength{pgf@xb}{pgfkeysvalueof{/pgf/outer xsep}}%
        pgfmathsetlength{pgf@yb}{pgfkeysvalueof{/pgf/outer ysep}}%
        advancepgfutil@tempdima by-pgf@xb%
        advancepgfutil@tempdimb by-pgf@yb%
        pgfpathellipse{centerpoint}{pgfqpoint{pgfutil@tempdima}{0pt}}{pgfqpoint{0pt}{pgfutil@tempdimb}}%
        }%
        }%
        makeatother

        begin{document}
        begin{tikzpicture}[nodes={draw, inner sep=0}]
        node[regular polygon,regular polygon sides=4] (a) {XX};
        node[Circle, blue] (b) {XX};
        node[circle] (c) {XX};
        foreach a in {north,south,east,west,north east,south east,north west,south west}{
        fill[red] (a.a) circle(0.5pt);
        fill[yellow] (b.a) circle(0.25pt);
        fill[orange] (c.a) circle(0.25pt);
        }
        end{tikzpicture}
        end{document}


        enter image description here






        share|improve this answer













        The "inner circle" in shapes.geometric has a radius that is half of the longest side of the content box plus the inner sep, and multiplied by 1.4142136, which is approximately sqrt(2). So to obtain a circle shape that has this behavior you can define a new shape, let's say Circle (with capital C) that is a slight modification of the existing ellipse shape.



        documentclass[tikz, border=7pt, convert={density=4200}]{standalone}
        usetikzlibrary{shapes.geometric}
        makeatletter
        pgfdeclareshape{Circle}
        %
        % Draws a circle around the text
        % (based on the original ellipse shape)
        %
        {%
        savedanchorcenterpoint{%
        pgf@x=.5wdpgfnodeparttextbox%
        pgf@y=.5htpgfnodeparttextbox%
        advancepgf@y by-.5dppgfnodeparttextbox%
        }%
        savedanchorradius{%
        %
        % Calculate ``height radius''
        %
        pgf@y=.5htpgfnodeparttextbox%
        advancepgf@y by.5dppgfnodeparttextbox%
        pgfmathsetlengthpgf@yb{pgfkeysvalueof{/pgf/inner ysep}}%
        advancepgf@y bypgf@yb%
        %
        % Calculate ``width radius''
        %
        pgf@x=.5wdpgfnodeparttextbox%
        pgfmathsetlengthpgf@xb{pgfkeysvalueof{/pgf/inner xsep}}%
        advancepgf@x bypgf@xb%
        %
        % Adjust
        %
        % ==============================
        % added to ellipse shape to become circle
        ifdimpgf@y>pgf@x%
        pgf@xpgf@y%
        else%
        pgf@ypgf@x%
        fi%
        % ==============================
        pgf@x=1.4142136pgf@x%
        pgf@y=1.4142136pgf@y%
        %
        % Adjust height, if necessary
        %
        pgfmathsetlengthpgf@yc{pgfkeysvalueof{/pgf/minimum height}}%
        ifdimpgf@y<.5pgf@yc%
        pgf@y=.5pgf@yc%
        fi%
        %
        % Adjust width, if necessary
        %
        pgfmathsetlengthpgf@xc{pgfkeysvalueof{/pgf/minimum width}}%
        ifdimpgf@x<.5pgf@xc%
        pgf@x=.5pgf@xc%
        fi%
        %
        % Add outer sep
        %
        pgfmathsetlength{pgf@xb}{pgfkeysvalueof{/pgf/outer xsep}}%
        pgfmathsetlength{pgf@yb}{pgfkeysvalueof{/pgf/outer ysep}}%
        advancepgf@x bypgf@xb%
        advancepgf@y bypgf@yb%
        }%

        %
        % Anchors
        %
        anchor{center}{centerpoint}%
        anchor{mid}{centerpointpgfmathsetlengthpgf@y{.5ex}}%
        anchor{base}{centerpointpgf@y=0pt}%
        anchor{north}
        {
        pgf@process{radius}
        pgf@ya=pgf@y%
        pgf@process{centerpoint}
        advancepgf@y bypgf@ya
        }%
        anchor{south}
        {
        pgf@process{radius}
        pgf@ya=pgf@y%
        pgf@process{centerpoint}
        advancepgf@y by-pgf@ya
        }%
        anchor{west}
        {
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@process{centerpoint}
        advancepgf@x by-pgf@xa
        }%
        anchor{mid west}
        {%
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@process{centerpoint}
        advancepgf@x by-pgf@xa%
        pgfmathsetlengthpgf@y{.5ex}
        }%
        anchor{base west}
        {%
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@process{centerpoint}
        advancepgf@x by-pgf@xa%
        pgf@y=0pt
        }%
        anchor{north west}
        {
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@ya=pgf@y%
        pgf@process{centerpoint}
        advancepgf@x by-0.707107pgf@xa
        advancepgf@y by0.707107pgf@ya
        }%
        anchor{south west}
        {
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@ya=pgf@y%
        pgf@process{centerpoint}
        advancepgf@x by-0.707107pgf@xa
        advancepgf@y by-0.707107pgf@ya
        }%
        anchor{east}
        {%
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@process{centerpoint}
        advancepgf@x bypgf@xa
        }%
        anchor{mid east}
        {%
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@process{centerpoint}
        advancepgf@x bypgf@xa%
        pgfmathsetlengthpgf@y{.5ex}
        }%
        anchor{base east}
        {%
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@process{centerpoint}
        advancepgf@x bypgf@xa%
        pgf@y=0pt
        }%
        anchor{north east}
        {
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@ya=pgf@y%
        pgf@process{centerpoint}
        advancepgf@x by0.707107pgf@xa
        advancepgf@y by0.707107pgf@ya
        }%
        anchor{south east}
        {
        pgf@process{radius}
        pgf@xa=pgf@x%
        pgf@ya=pgf@y%
        pgf@process{centerpoint}
        advancepgf@x by0.707107pgf@xa
        advancepgf@y by-0.707107pgf@ya
        }%
        anchorborder{
        edefpgf@marshal{%
        noexpandpgfpointborderellipse
        {noexpandpgfqpoint{thepgf@x}{thepgf@y}}
        {noexpandradius}%
        }%
        pgf@marshal%
        pgf@xa=pgf@x%
        pgf@ya=pgf@y%
        centerpoint%
        advancepgf@x bypgf@xa%
        advancepgf@y bypgf@ya%
        }%

        %
        % Background path
        %
        backgroundpath
        {
        pgf@process{radius}%
        pgfutil@tempdima=pgf@x%
        pgfutil@tempdimb=pgf@y%
        pgfmathsetlength{pgf@xb}{pgfkeysvalueof{/pgf/outer xsep}}%
        pgfmathsetlength{pgf@yb}{pgfkeysvalueof{/pgf/outer ysep}}%
        advancepgfutil@tempdima by-pgf@xb%
        advancepgfutil@tempdimb by-pgf@yb%
        pgfpathellipse{centerpoint}{pgfqpoint{pgfutil@tempdima}{0pt}}{pgfqpoint{0pt}{pgfutil@tempdimb}}%
        }%
        }%
        makeatother

        begin{document}
        begin{tikzpicture}[nodes={draw, inner sep=0}]
        node[regular polygon,regular polygon sides=4] (a) {XX};
        node[Circle, blue] (b) {XX};
        node[circle] (c) {XX};
        foreach a in {north,south,east,west,north east,south east,north west,south west}{
        fill[red] (a.a) circle(0.5pt);
        fill[yellow] (b.a) circle(0.25pt);
        fill[orange] (c.a) circle(0.25pt);
        }
        end{tikzpicture}
        end{document}


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 16 mins ago









        KpymKpym

        16.6k24089




        16.6k24089






























            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%2f480661%2fregular-polygon-vs-circle-shapes-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

            Cosme II de Mèdici

            Hivernacle

            Marbre de Carrara