Scale a SVG without changing his position in C++











up vote
1
down vote

favorite












I'm currently working on a project for my school. I need to make a SVG landscape generator in C++.
My teacher give us different C++ functions which draw svg forms on a output.svg. We then open the file in a web browser and the generated landscape appears.
His functions write HTML5 tags to draw svg like <circle> and <polygon>.



For example the function to draw an hexagon:



void Svgfile::addHexagone(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4,
double x5,double y5,double x6,double y6, std::string colorFill){
m_ostrm << "<polygon points="" << x1 << "," << y1 << " " << x2 << "," << y2 << " " << x3 << "," << y3
<< " " << x4 << "," << y4 << " " << x5 << "," << y5 << " " << x6 << "," << y6
<< "" style="fill:" << colorFill << "" ></polygon>";


The problem is my program needs to scale differently each SVG object of my landscape to add variety.
I made a very simple rock represented by a grey hexagon using addHexagone. But <polygon> use the position of 6 points,
and the only way I find to resize it is to multiply each x and y of each points by a variable *size.
It's working, but it changes the position of my shape which is not what I need.
I've read some docs about ViewBox attribute on a SVG but I didn't manage to use it.
I also tried to add a attribute transform='size(10em)' but nothing changed.










share|improve this question






















  • transform as an attribute does not take units. nor is size a valid keyword. transform='scale(1.1)' might be what you want.
    – Robert Longson
    Nov 22 at 11:45

















up vote
1
down vote

favorite












I'm currently working on a project for my school. I need to make a SVG landscape generator in C++.
My teacher give us different C++ functions which draw svg forms on a output.svg. We then open the file in a web browser and the generated landscape appears.
His functions write HTML5 tags to draw svg like <circle> and <polygon>.



For example the function to draw an hexagon:



void Svgfile::addHexagone(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4,
double x5,double y5,double x6,double y6, std::string colorFill){
m_ostrm << "<polygon points="" << x1 << "," << y1 << " " << x2 << "," << y2 << " " << x3 << "," << y3
<< " " << x4 << "," << y4 << " " << x5 << "," << y5 << " " << x6 << "," << y6
<< "" style="fill:" << colorFill << "" ></polygon>";


The problem is my program needs to scale differently each SVG object of my landscape to add variety.
I made a very simple rock represented by a grey hexagon using addHexagone. But <polygon> use the position of 6 points,
and the only way I find to resize it is to multiply each x and y of each points by a variable *size.
It's working, but it changes the position of my shape which is not what I need.
I've read some docs about ViewBox attribute on a SVG but I didn't manage to use it.
I also tried to add a attribute transform='size(10em)' but nothing changed.










share|improve this question






















  • transform as an attribute does not take units. nor is size a valid keyword. transform='scale(1.1)' might be what you want.
    – Robert Longson
    Nov 22 at 11:45















up vote
1
down vote

favorite









up vote
1
down vote

favorite











I'm currently working on a project for my school. I need to make a SVG landscape generator in C++.
My teacher give us different C++ functions which draw svg forms on a output.svg. We then open the file in a web browser and the generated landscape appears.
His functions write HTML5 tags to draw svg like <circle> and <polygon>.



For example the function to draw an hexagon:



void Svgfile::addHexagone(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4,
double x5,double y5,double x6,double y6, std::string colorFill){
m_ostrm << "<polygon points="" << x1 << "," << y1 << " " << x2 << "," << y2 << " " << x3 << "," << y3
<< " " << x4 << "," << y4 << " " << x5 << "," << y5 << " " << x6 << "," << y6
<< "" style="fill:" << colorFill << "" ></polygon>";


The problem is my program needs to scale differently each SVG object of my landscape to add variety.
I made a very simple rock represented by a grey hexagon using addHexagone. But <polygon> use the position of 6 points,
and the only way I find to resize it is to multiply each x and y of each points by a variable *size.
It's working, but it changes the position of my shape which is not what I need.
I've read some docs about ViewBox attribute on a SVG but I didn't manage to use it.
I also tried to add a attribute transform='size(10em)' but nothing changed.










share|improve this question













I'm currently working on a project for my school. I need to make a SVG landscape generator in C++.
My teacher give us different C++ functions which draw svg forms on a output.svg. We then open the file in a web browser and the generated landscape appears.
His functions write HTML5 tags to draw svg like <circle> and <polygon>.



For example the function to draw an hexagon:



void Svgfile::addHexagone(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4,
double x5,double y5,double x6,double y6, std::string colorFill){
m_ostrm << "<polygon points="" << x1 << "," << y1 << " " << x2 << "," << y2 << " " << x3 << "," << y3
<< " " << x4 << "," << y4 << " " << x5 << "," << y5 << " " << x6 << "," << y6
<< "" style="fill:" << colorFill << "" ></polygon>";


The problem is my program needs to scale differently each SVG object of my landscape to add variety.
I made a very simple rock represented by a grey hexagon using addHexagone. But <polygon> use the position of 6 points,
and the only way I find to resize it is to multiply each x and y of each points by a variable *size.
It's working, but it changes the position of my shape which is not what I need.
I've read some docs about ViewBox attribute on a SVG but I didn't manage to use it.
I also tried to add a attribute transform='size(10em)' but nothing changed.







c++ css svg






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 at 11:30









Kadarach

71




71












  • transform as an attribute does not take units. nor is size a valid keyword. transform='scale(1.1)' might be what you want.
    – Robert Longson
    Nov 22 at 11:45




















  • transform as an attribute does not take units. nor is size a valid keyword. transform='scale(1.1)' might be what you want.
    – Robert Longson
    Nov 22 at 11:45


















transform as an attribute does not take units. nor is size a valid keyword. transform='scale(1.1)' might be what you want.
– Robert Longson
Nov 22 at 11:45






transform as an attribute does not take units. nor is size a valid keyword. transform='scale(1.1)' might be what you want.
– Robert Longson
Nov 22 at 11:45














3 Answers
3






active

oldest

votes

















up vote
1
down vote













To scale an object without changing its position, you must first find its position. One way of defining that is the 'center of mass' Find the center of mass of points method (just use 1 for each point as 'mass', so it's a simple average). Once you have the position, subtract it from all points of your object (in this case, polygon), this will bring it with its center of mass positioned at the origin, then scale the new point coordinates as you did, by multiplying with the scale. Then simply add back the center of mass coordinates to each point of your object, and you are done.






share|improve this answer





















  • Nice tips thanks. I managed to calculate the center of mass of points for the hexagon and draw it as a cross on my SVG. It works. But when I subtract it from all points of my object (each x - centerx and each y - centery) the hexagon is center at the origin of my page (top left) and the cross still at the old position.
    – Kadarach
    Nov 22 at 12:15












  • I didn't quite understand the end of your comment but it works ! Thanks for you help Adrian. The code is not very lisible but I can now scale my objects easily.
    – Kadarach
    Nov 22 at 12:34












  • Yes, the center of mass is where it is. You translated the polygon in the origin, which is ok, now scale it and translate it back by adding back the center of mass coordinates you subtracted.
    – Adrian Roman
    Nov 22 at 12:34


















up vote
0
down vote













You can use transform property, just as in example:



<svg xmlns="http://www.w3.org/2000/svg" width="200px" height="200px" viewBox="0 0 200 200">
<g>
<circle cx="20" cy="20" r="10"/>
</g>
<g transform="scale(2)">
<circle cx="50" cy="50" r="10"/>
</g>
</svg>





share|improve this answer





















  • It works but this change the position of my object too
    – Kadarach
    Nov 22 at 11:50










  • In fact it doesn't :) It all depends on "What do you consider as a center/freezed point of an object", as mentioned by @Adrian Roman. If it is not a center of a circle, just add translate to your scale. Like transform="scale(10) translate(50,50)"
    – grapes
    Nov 22 at 12:13










  • Yes I understand thanks for you help, I'll use the center of mass that Adrian Roman told me about and then scale it with transform !
    – Kadarach
    Nov 22 at 12:27


















up vote
0
down vote













I'm not sure why we should be doing your assignments for you...



Obviously you need to scale your heagon points before you position it. Make a function that generates the hexagon points you want and then call your addHexagon() fmethod.



Something like this:



void generateHexagon(double centreX, double centreY, double hexagonSize, std::string fillColour)
{
double pts = new double[6][2];
for (int step=0; step<6; step++)
{
double angle = step * 60f;
pts[step][0] = centreX + hexagonSize * cos(angle);
pts[step][1] = centreY + hexagonSize * sin(angle);
}
Svgfile::addHexagone(pts[0][0], pts[0][1],
pts[1][0], pts[1][1],
pts[2][0], pts[2][1],
pts[3][0], pts[3][1],
pts[4][0], pts[4][1],
pts[5][0], pts[5][1],
fillColour);
}





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    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: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2fstackoverflow.com%2fquestions%2f53430001%2fscale-a-svg-without-changing-his-position-in-c%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    To scale an object without changing its position, you must first find its position. One way of defining that is the 'center of mass' Find the center of mass of points method (just use 1 for each point as 'mass', so it's a simple average). Once you have the position, subtract it from all points of your object (in this case, polygon), this will bring it with its center of mass positioned at the origin, then scale the new point coordinates as you did, by multiplying with the scale. Then simply add back the center of mass coordinates to each point of your object, and you are done.






    share|improve this answer





















    • Nice tips thanks. I managed to calculate the center of mass of points for the hexagon and draw it as a cross on my SVG. It works. But when I subtract it from all points of my object (each x - centerx and each y - centery) the hexagon is center at the origin of my page (top left) and the cross still at the old position.
      – Kadarach
      Nov 22 at 12:15












    • I didn't quite understand the end of your comment but it works ! Thanks for you help Adrian. The code is not very lisible but I can now scale my objects easily.
      – Kadarach
      Nov 22 at 12:34












    • Yes, the center of mass is where it is. You translated the polygon in the origin, which is ok, now scale it and translate it back by adding back the center of mass coordinates you subtracted.
      – Adrian Roman
      Nov 22 at 12:34















    up vote
    1
    down vote













    To scale an object without changing its position, you must first find its position. One way of defining that is the 'center of mass' Find the center of mass of points method (just use 1 for each point as 'mass', so it's a simple average). Once you have the position, subtract it from all points of your object (in this case, polygon), this will bring it with its center of mass positioned at the origin, then scale the new point coordinates as you did, by multiplying with the scale. Then simply add back the center of mass coordinates to each point of your object, and you are done.






    share|improve this answer





















    • Nice tips thanks. I managed to calculate the center of mass of points for the hexagon and draw it as a cross on my SVG. It works. But when I subtract it from all points of my object (each x - centerx and each y - centery) the hexagon is center at the origin of my page (top left) and the cross still at the old position.
      – Kadarach
      Nov 22 at 12:15












    • I didn't quite understand the end of your comment but it works ! Thanks for you help Adrian. The code is not very lisible but I can now scale my objects easily.
      – Kadarach
      Nov 22 at 12:34












    • Yes, the center of mass is where it is. You translated the polygon in the origin, which is ok, now scale it and translate it back by adding back the center of mass coordinates you subtracted.
      – Adrian Roman
      Nov 22 at 12:34













    up vote
    1
    down vote










    up vote
    1
    down vote









    To scale an object without changing its position, you must first find its position. One way of defining that is the 'center of mass' Find the center of mass of points method (just use 1 for each point as 'mass', so it's a simple average). Once you have the position, subtract it from all points of your object (in this case, polygon), this will bring it with its center of mass positioned at the origin, then scale the new point coordinates as you did, by multiplying with the scale. Then simply add back the center of mass coordinates to each point of your object, and you are done.






    share|improve this answer












    To scale an object without changing its position, you must first find its position. One way of defining that is the 'center of mass' Find the center of mass of points method (just use 1 for each point as 'mass', so it's a simple average). Once you have the position, subtract it from all points of your object (in this case, polygon), this will bring it with its center of mass positioned at the origin, then scale the new point coordinates as you did, by multiplying with the scale. Then simply add back the center of mass coordinates to each point of your object, and you are done.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 22 at 11:39









    Adrian Roman

    50948




    50948












    • Nice tips thanks. I managed to calculate the center of mass of points for the hexagon and draw it as a cross on my SVG. It works. But when I subtract it from all points of my object (each x - centerx and each y - centery) the hexagon is center at the origin of my page (top left) and the cross still at the old position.
      – Kadarach
      Nov 22 at 12:15












    • I didn't quite understand the end of your comment but it works ! Thanks for you help Adrian. The code is not very lisible but I can now scale my objects easily.
      – Kadarach
      Nov 22 at 12:34












    • Yes, the center of mass is where it is. You translated the polygon in the origin, which is ok, now scale it and translate it back by adding back the center of mass coordinates you subtracted.
      – Adrian Roman
      Nov 22 at 12:34


















    • Nice tips thanks. I managed to calculate the center of mass of points for the hexagon and draw it as a cross on my SVG. It works. But when I subtract it from all points of my object (each x - centerx and each y - centery) the hexagon is center at the origin of my page (top left) and the cross still at the old position.
      – Kadarach
      Nov 22 at 12:15












    • I didn't quite understand the end of your comment but it works ! Thanks for you help Adrian. The code is not very lisible but I can now scale my objects easily.
      – Kadarach
      Nov 22 at 12:34












    • Yes, the center of mass is where it is. You translated the polygon in the origin, which is ok, now scale it and translate it back by adding back the center of mass coordinates you subtracted.
      – Adrian Roman
      Nov 22 at 12:34
















    Nice tips thanks. I managed to calculate the center of mass of points for the hexagon and draw it as a cross on my SVG. It works. But when I subtract it from all points of my object (each x - centerx and each y - centery) the hexagon is center at the origin of my page (top left) and the cross still at the old position.
    – Kadarach
    Nov 22 at 12:15






    Nice tips thanks. I managed to calculate the center of mass of points for the hexagon and draw it as a cross on my SVG. It works. But when I subtract it from all points of my object (each x - centerx and each y - centery) the hexagon is center at the origin of my page (top left) and the cross still at the old position.
    – Kadarach
    Nov 22 at 12:15














    I didn't quite understand the end of your comment but it works ! Thanks for you help Adrian. The code is not very lisible but I can now scale my objects easily.
    – Kadarach
    Nov 22 at 12:34






    I didn't quite understand the end of your comment but it works ! Thanks for you help Adrian. The code is not very lisible but I can now scale my objects easily.
    – Kadarach
    Nov 22 at 12:34














    Yes, the center of mass is where it is. You translated the polygon in the origin, which is ok, now scale it and translate it back by adding back the center of mass coordinates you subtracted.
    – Adrian Roman
    Nov 22 at 12:34




    Yes, the center of mass is where it is. You translated the polygon in the origin, which is ok, now scale it and translate it back by adding back the center of mass coordinates you subtracted.
    – Adrian Roman
    Nov 22 at 12:34












    up vote
    0
    down vote













    You can use transform property, just as in example:



    <svg xmlns="http://www.w3.org/2000/svg" width="200px" height="200px" viewBox="0 0 200 200">
    <g>
    <circle cx="20" cy="20" r="10"/>
    </g>
    <g transform="scale(2)">
    <circle cx="50" cy="50" r="10"/>
    </g>
    </svg>





    share|improve this answer





















    • It works but this change the position of my object too
      – Kadarach
      Nov 22 at 11:50










    • In fact it doesn't :) It all depends on "What do you consider as a center/freezed point of an object", as mentioned by @Adrian Roman. If it is not a center of a circle, just add translate to your scale. Like transform="scale(10) translate(50,50)"
      – grapes
      Nov 22 at 12:13










    • Yes I understand thanks for you help, I'll use the center of mass that Adrian Roman told me about and then scale it with transform !
      – Kadarach
      Nov 22 at 12:27















    up vote
    0
    down vote













    You can use transform property, just as in example:



    <svg xmlns="http://www.w3.org/2000/svg" width="200px" height="200px" viewBox="0 0 200 200">
    <g>
    <circle cx="20" cy="20" r="10"/>
    </g>
    <g transform="scale(2)">
    <circle cx="50" cy="50" r="10"/>
    </g>
    </svg>





    share|improve this answer





















    • It works but this change the position of my object too
      – Kadarach
      Nov 22 at 11:50










    • In fact it doesn't :) It all depends on "What do you consider as a center/freezed point of an object", as mentioned by @Adrian Roman. If it is not a center of a circle, just add translate to your scale. Like transform="scale(10) translate(50,50)"
      – grapes
      Nov 22 at 12:13










    • Yes I understand thanks for you help, I'll use the center of mass that Adrian Roman told me about and then scale it with transform !
      – Kadarach
      Nov 22 at 12:27













    up vote
    0
    down vote










    up vote
    0
    down vote









    You can use transform property, just as in example:



    <svg xmlns="http://www.w3.org/2000/svg" width="200px" height="200px" viewBox="0 0 200 200">
    <g>
    <circle cx="20" cy="20" r="10"/>
    </g>
    <g transform="scale(2)">
    <circle cx="50" cy="50" r="10"/>
    </g>
    </svg>





    share|improve this answer












    You can use transform property, just as in example:



    <svg xmlns="http://www.w3.org/2000/svg" width="200px" height="200px" viewBox="0 0 200 200">
    <g>
    <circle cx="20" cy="20" r="10"/>
    </g>
    <g transform="scale(2)">
    <circle cx="50" cy="50" r="10"/>
    </g>
    </svg>






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 22 at 11:42









    grapes

    1,037113




    1,037113












    • It works but this change the position of my object too
      – Kadarach
      Nov 22 at 11:50










    • In fact it doesn't :) It all depends on "What do you consider as a center/freezed point of an object", as mentioned by @Adrian Roman. If it is not a center of a circle, just add translate to your scale. Like transform="scale(10) translate(50,50)"
      – grapes
      Nov 22 at 12:13










    • Yes I understand thanks for you help, I'll use the center of mass that Adrian Roman told me about and then scale it with transform !
      – Kadarach
      Nov 22 at 12:27


















    • It works but this change the position of my object too
      – Kadarach
      Nov 22 at 11:50










    • In fact it doesn't :) It all depends on "What do you consider as a center/freezed point of an object", as mentioned by @Adrian Roman. If it is not a center of a circle, just add translate to your scale. Like transform="scale(10) translate(50,50)"
      – grapes
      Nov 22 at 12:13










    • Yes I understand thanks for you help, I'll use the center of mass that Adrian Roman told me about and then scale it with transform !
      – Kadarach
      Nov 22 at 12:27
















    It works but this change the position of my object too
    – Kadarach
    Nov 22 at 11:50




    It works but this change the position of my object too
    – Kadarach
    Nov 22 at 11:50












    In fact it doesn't :) It all depends on "What do you consider as a center/freezed point of an object", as mentioned by @Adrian Roman. If it is not a center of a circle, just add translate to your scale. Like transform="scale(10) translate(50,50)"
    – grapes
    Nov 22 at 12:13




    In fact it doesn't :) It all depends on "What do you consider as a center/freezed point of an object", as mentioned by @Adrian Roman. If it is not a center of a circle, just add translate to your scale. Like transform="scale(10) translate(50,50)"
    – grapes
    Nov 22 at 12:13












    Yes I understand thanks for you help, I'll use the center of mass that Adrian Roman told me about and then scale it with transform !
    – Kadarach
    Nov 22 at 12:27




    Yes I understand thanks for you help, I'll use the center of mass that Adrian Roman told me about and then scale it with transform !
    – Kadarach
    Nov 22 at 12:27










    up vote
    0
    down vote













    I'm not sure why we should be doing your assignments for you...



    Obviously you need to scale your heagon points before you position it. Make a function that generates the hexagon points you want and then call your addHexagon() fmethod.



    Something like this:



    void generateHexagon(double centreX, double centreY, double hexagonSize, std::string fillColour)
    {
    double pts = new double[6][2];
    for (int step=0; step<6; step++)
    {
    double angle = step * 60f;
    pts[step][0] = centreX + hexagonSize * cos(angle);
    pts[step][1] = centreY + hexagonSize * sin(angle);
    }
    Svgfile::addHexagone(pts[0][0], pts[0][1],
    pts[1][0], pts[1][1],
    pts[2][0], pts[2][1],
    pts[3][0], pts[3][1],
    pts[4][0], pts[4][1],
    pts[5][0], pts[5][1],
    fillColour);
    }





    share|improve this answer

























      up vote
      0
      down vote













      I'm not sure why we should be doing your assignments for you...



      Obviously you need to scale your heagon points before you position it. Make a function that generates the hexagon points you want and then call your addHexagon() fmethod.



      Something like this:



      void generateHexagon(double centreX, double centreY, double hexagonSize, std::string fillColour)
      {
      double pts = new double[6][2];
      for (int step=0; step<6; step++)
      {
      double angle = step * 60f;
      pts[step][0] = centreX + hexagonSize * cos(angle);
      pts[step][1] = centreY + hexagonSize * sin(angle);
      }
      Svgfile::addHexagone(pts[0][0], pts[0][1],
      pts[1][0], pts[1][1],
      pts[2][0], pts[2][1],
      pts[3][0], pts[3][1],
      pts[4][0], pts[4][1],
      pts[5][0], pts[5][1],
      fillColour);
      }





      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        I'm not sure why we should be doing your assignments for you...



        Obviously you need to scale your heagon points before you position it. Make a function that generates the hexagon points you want and then call your addHexagon() fmethod.



        Something like this:



        void generateHexagon(double centreX, double centreY, double hexagonSize, std::string fillColour)
        {
        double pts = new double[6][2];
        for (int step=0; step<6; step++)
        {
        double angle = step * 60f;
        pts[step][0] = centreX + hexagonSize * cos(angle);
        pts[step][1] = centreY + hexagonSize * sin(angle);
        }
        Svgfile::addHexagone(pts[0][0], pts[0][1],
        pts[1][0], pts[1][1],
        pts[2][0], pts[2][1],
        pts[3][0], pts[3][1],
        pts[4][0], pts[4][1],
        pts[5][0], pts[5][1],
        fillColour);
        }





        share|improve this answer












        I'm not sure why we should be doing your assignments for you...



        Obviously you need to scale your heagon points before you position it. Make a function that generates the hexagon points you want and then call your addHexagon() fmethod.



        Something like this:



        void generateHexagon(double centreX, double centreY, double hexagonSize, std::string fillColour)
        {
        double pts = new double[6][2];
        for (int step=0; step<6; step++)
        {
        double angle = step * 60f;
        pts[step][0] = centreX + hexagonSize * cos(angle);
        pts[step][1] = centreY + hexagonSize * sin(angle);
        }
        Svgfile::addHexagone(pts[0][0], pts[0][1],
        pts[1][0], pts[1][1],
        pts[2][0], pts[2][1],
        pts[3][0], pts[3][1],
        pts[4][0], pts[4][1],
        pts[5][0], pts[5][1],
        fillColour);
        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 at 12:26









        Paul LeBeau

        54.5k56492




        54.5k56492






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • 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%2fstackoverflow.com%2fquestions%2f53430001%2fscale-a-svg-without-changing-his-position-in-c%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

            Lallio

            Futebolista

            Jornalista