TIKZ Macro to draw hundredth of a squareTikZ: Cropping the Bounding BoxRotate a node but not its content: the case of the ellipse decorationMacro to draw a parabola with pgf/TikZNumerical conditional within tikz keys?How to draw points in TikZ?Drawing a flag in Tikz!TikZ: Drawing an arc from an intersection to an intersectionLine up nested tikz enviroments or how to get rid of themHow is a PGF shading applied?Is there an wasy way to program in Tikz something like the one in the image?

Manager told a colleague of mine I was getting fired soon

Does the US Armed Forces refuse to recruit anyone with an IQ less than 83?

Using 4K Skyrim Textures when running 1920 x 1080 display resolution?

Why is the time of useful consciousness only seconds at high altitudes?

Does the 'java' command compile Java programs?

Quote to show students don't have to fear making mistakes

Why do we not always use the closed testing principle for multiple comparisons?

Why do many websites hide input when entering a OTP

Determine the Winner of a Game of Australian Football

Does it require less energy to reach the Sun from Pluto's orbit than from Earth's orbit?

Would houseruling two or more instances of resistance to the same element as immunity be overly unbalanced?

Bothered by watching coworkers slacking off

Sum of series with addition

C - Learning Linked Lists, Pointer Manipulation - Store some ints, print and free memory

If I travelled back in time to invest in X company to make a fortune, roughly what is the probability that it would fail?

Could Boris Johnson face criminal charges for illegally proroguing Parliament?

Lighthouse Alternatives

How to tension rope between two trees?

Is right click on tables bad UX

Search for something difficult to count/estimate

Why is my vegetable stock bitter, but the chicken stock not?

Parent asking for money after I moved out

What benefits are there to blocking most search engines?

Injection from two strings to one string



TIKZ Macro to draw hundredth of a square


TikZ: Cropping the Bounding BoxRotate a node but not its content: the case of the ellipse decorationMacro to draw a parabola with pgf/TikZNumerical conditional within tikz keys?How to draw points in TikZ?Drawing a flag in Tikz!TikZ: Drawing an arc from an intersection to an intersectionLine up nested tikz enviroments or how to get rid of themHow is a PGF shading applied?Is there an wasy way to program in Tikz something like the one in the image?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









1















I would like to use a macro to draw automaticly this if I specify the number 195.



begintikzpicture[scale=0.25,baseline=([yshift=-.5ex]current bounding box.center)]
foreach i in 0,...,9
foreach j in 0,...,9
draw[red,shift=(i,j),fill](0,0) rectangle (1,1);



foreach i in 0,...,9
foreach j in 0,...,9
draw[shift=(i,j)](0,0) rectangle (1,1);

draw[very thick] (0,0) rectangle (10,10);
endtikzpicture
begintikzpicture[scale=0.25,baseline=([yshift=-.5ex]current bounding box.center)]
foreach i in 0,...,8
foreach j in 0,...,9
draw[red,shift=(i,j),fill](0,0) rectangle (1,1);


foreach j in 5,...,9
draw[red,shift=(9,j),fill](0,0) rectangle (1,1);


foreach i in 0,...,9
foreach j in 0,...,9
draw[shift=(i,j)](0,0) rectangle (1,1);

draw[very thick] (0,0) rectangle (10,10);
endtikzpicture


Thank you










share|improve this question









New contributor



jadou is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    Can you explain what you want a bit more clearly, in words as well as with the code?

    – Peter LeFanu Lumsdaine
    9 hours ago











  • I want to specify the number of hundreth and the macro to fill the right number of same size little squares inside big squares. For eg, if I specify 195, I want one big filled quare and 95 other little squares inside another big one.

    – jadou
    9 hours ago


















1















I would like to use a macro to draw automaticly this if I specify the number 195.



begintikzpicture[scale=0.25,baseline=([yshift=-.5ex]current bounding box.center)]
foreach i in 0,...,9
foreach j in 0,...,9
draw[red,shift=(i,j),fill](0,0) rectangle (1,1);



foreach i in 0,...,9
foreach j in 0,...,9
draw[shift=(i,j)](0,0) rectangle (1,1);

draw[very thick] (0,0) rectangle (10,10);
endtikzpicture
begintikzpicture[scale=0.25,baseline=([yshift=-.5ex]current bounding box.center)]
foreach i in 0,...,8
foreach j in 0,...,9
draw[red,shift=(i,j),fill](0,0) rectangle (1,1);


foreach j in 5,...,9
draw[red,shift=(9,j),fill](0,0) rectangle (1,1);


foreach i in 0,...,9
foreach j in 0,...,9
draw[shift=(i,j)](0,0) rectangle (1,1);

draw[very thick] (0,0) rectangle (10,10);
endtikzpicture


Thank you










share|improve this question









New contributor



jadou is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    Can you explain what you want a bit more clearly, in words as well as with the code?

    – Peter LeFanu Lumsdaine
    9 hours ago











  • I want to specify the number of hundreth and the macro to fill the right number of same size little squares inside big squares. For eg, if I specify 195, I want one big filled quare and 95 other little squares inside another big one.

    – jadou
    9 hours ago














1












1








1








I would like to use a macro to draw automaticly this if I specify the number 195.



begintikzpicture[scale=0.25,baseline=([yshift=-.5ex]current bounding box.center)]
foreach i in 0,...,9
foreach j in 0,...,9
draw[red,shift=(i,j),fill](0,0) rectangle (1,1);



foreach i in 0,...,9
foreach j in 0,...,9
draw[shift=(i,j)](0,0) rectangle (1,1);

draw[very thick] (0,0) rectangle (10,10);
endtikzpicture
begintikzpicture[scale=0.25,baseline=([yshift=-.5ex]current bounding box.center)]
foreach i in 0,...,8
foreach j in 0,...,9
draw[red,shift=(i,j),fill](0,0) rectangle (1,1);


foreach j in 5,...,9
draw[red,shift=(9,j),fill](0,0) rectangle (1,1);


foreach i in 0,...,9
foreach j in 0,...,9
draw[shift=(i,j)](0,0) rectangle (1,1);

draw[very thick] (0,0) rectangle (10,10);
endtikzpicture


Thank you










share|improve this question









New contributor



jadou is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I would like to use a macro to draw automaticly this if I specify the number 195.



begintikzpicture[scale=0.25,baseline=([yshift=-.5ex]current bounding box.center)]
foreach i in 0,...,9
foreach j in 0,...,9
draw[red,shift=(i,j),fill](0,0) rectangle (1,1);



foreach i in 0,...,9
foreach j in 0,...,9
draw[shift=(i,j)](0,0) rectangle (1,1);

draw[very thick] (0,0) rectangle (10,10);
endtikzpicture
begintikzpicture[scale=0.25,baseline=([yshift=-.5ex]current bounding box.center)]
foreach i in 0,...,8
foreach j in 0,...,9
draw[red,shift=(i,j),fill](0,0) rectangle (1,1);


foreach j in 5,...,9
draw[red,shift=(9,j),fill](0,0) rectangle (1,1);


foreach i in 0,...,9
foreach j in 0,...,9
draw[shift=(i,j)](0,0) rectangle (1,1);

draw[very thick] (0,0) rectangle (10,10);
endtikzpicture


Thank you







tikz-pgf draw






share|improve this question









New contributor



jadou is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question









New contributor



jadou is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question








edited 22 mins ago









Abdulrahman Bres

1085 bronze badges




1085 bronze badges






New contributor



jadou is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 9 hours ago









jadoujadou

82 bronze badges




82 bronze badges




New contributor



jadou is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




jadou is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • 1





    Can you explain what you want a bit more clearly, in words as well as with the code?

    – Peter LeFanu Lumsdaine
    9 hours ago











  • I want to specify the number of hundreth and the macro to fill the right number of same size little squares inside big squares. For eg, if I specify 195, I want one big filled quare and 95 other little squares inside another big one.

    – jadou
    9 hours ago













  • 1





    Can you explain what you want a bit more clearly, in words as well as with the code?

    – Peter LeFanu Lumsdaine
    9 hours ago











  • I want to specify the number of hundreth and the macro to fill the right number of same size little squares inside big squares. For eg, if I specify 195, I want one big filled quare and 95 other little squares inside another big one.

    – jadou
    9 hours ago








1




1





Can you explain what you want a bit more clearly, in words as well as with the code?

– Peter LeFanu Lumsdaine
9 hours ago





Can you explain what you want a bit more clearly, in words as well as with the code?

– Peter LeFanu Lumsdaine
9 hours ago













I want to specify the number of hundreth and the macro to fill the right number of same size little squares inside big squares. For eg, if I specify 195, I want one big filled quare and 95 other little squares inside another big one.

– jadou
9 hours ago






I want to specify the number of hundreth and the macro to fill the right number of same size little squares inside big squares. For eg, if I specify 195, I want one big filled quare and 95 other little squares inside another big one.

– jadou
9 hours ago











2 Answers
2






active

oldest

votes


















3
















This defines a pic, whose argument is the number you are referring to, and draws the partly filled squares accordingly.



documentclass[tikz,border=3mm]standalone
begindocument
tikzsetpics/pf/.style=code=foreach i in 0,...,9
foreach j in 0,...,9
pgfmathtruncatemacroitestifthenelse(i*10+j<#1,1,0)
draw[shift=(i,9-j)] ifnumitest=1 [fill=red] fi
(0,0) rectangle (1,1);

draw[very thick] (0,0) rectangle (10,10);
,
pics/pft/.style=code=%
pgfmathtruncatemacroimodint(#1/100)
path foreach X in 0,...,imod
(3*X,0) pic[scale=0.25]pf=#1-100*X;

begintikzpicture[baseline=([yshift=-.5ex]current bounding box.center)]
picpft=195;
endtikzpicture
begintikzpicture[baseline=([yshift=-.5ex]current bounding box.center)]
picpft=273;
endtikzpicture
enddocument


enter image description here






share|improve this answer


































    3
















    Something like this?



    documentclass[tikz]standalone
    usepackagetikz
    newcommandredsquare[1]%
    foreach i in 1,...,200

    pgfmathsetmacroRowNomod(i-1,10)
    pgfmathsetmacroColTmpfloor((i-1)/10)
    pgfmathsetmacroColNoifthenelse(ColTmp>9,ColTmp+1,ColTmp)
    typeoutRowNo,ColNo
    ifnum i > #1
    draw[shift=(ColNo,-RowNo),fill=white](0,0) rectangle (1,1);
    else
    draw[shift=(ColNo,-RowNo),fill=red](0,0) rectangle (1,1);
    fi

    draw [very thick] (0,1) rectangle +(10,-10);
    draw [very thick] (11,1) rectangle +(10,-10);


    begindocument

    begintikzpicture[scale=0.25]
    redsquare195

    beginscope[yshift=-13cm]
    redsquare163
    endscope
    endtikzpicture

    enddocument


    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/4.0/"u003ecc by-sa 4.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
      );



      );







      jadou is a new contributor. Be nice, and check out our Code of Conduct.









      draft saved

      draft discarded
















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f510034%2ftikz-macro-to-draw-hundredth-of-a-square%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









      3
















      This defines a pic, whose argument is the number you are referring to, and draws the partly filled squares accordingly.



      documentclass[tikz,border=3mm]standalone
      begindocument
      tikzsetpics/pf/.style=code=foreach i in 0,...,9
      foreach j in 0,...,9
      pgfmathtruncatemacroitestifthenelse(i*10+j<#1,1,0)
      draw[shift=(i,9-j)] ifnumitest=1 [fill=red] fi
      (0,0) rectangle (1,1);

      draw[very thick] (0,0) rectangle (10,10);
      ,
      pics/pft/.style=code=%
      pgfmathtruncatemacroimodint(#1/100)
      path foreach X in 0,...,imod
      (3*X,0) pic[scale=0.25]pf=#1-100*X;

      begintikzpicture[baseline=([yshift=-.5ex]current bounding box.center)]
      picpft=195;
      endtikzpicture
      begintikzpicture[baseline=([yshift=-.5ex]current bounding box.center)]
      picpft=273;
      endtikzpicture
      enddocument


      enter image description here






      share|improve this answer































        3
















        This defines a pic, whose argument is the number you are referring to, and draws the partly filled squares accordingly.



        documentclass[tikz,border=3mm]standalone
        begindocument
        tikzsetpics/pf/.style=code=foreach i in 0,...,9
        foreach j in 0,...,9
        pgfmathtruncatemacroitestifthenelse(i*10+j<#1,1,0)
        draw[shift=(i,9-j)] ifnumitest=1 [fill=red] fi
        (0,0) rectangle (1,1);

        draw[very thick] (0,0) rectangle (10,10);
        ,
        pics/pft/.style=code=%
        pgfmathtruncatemacroimodint(#1/100)
        path foreach X in 0,...,imod
        (3*X,0) pic[scale=0.25]pf=#1-100*X;

        begintikzpicture[baseline=([yshift=-.5ex]current bounding box.center)]
        picpft=195;
        endtikzpicture
        begintikzpicture[baseline=([yshift=-.5ex]current bounding box.center)]
        picpft=273;
        endtikzpicture
        enddocument


        enter image description here






        share|improve this answer





























          3














          3










          3









          This defines a pic, whose argument is the number you are referring to, and draws the partly filled squares accordingly.



          documentclass[tikz,border=3mm]standalone
          begindocument
          tikzsetpics/pf/.style=code=foreach i in 0,...,9
          foreach j in 0,...,9
          pgfmathtruncatemacroitestifthenelse(i*10+j<#1,1,0)
          draw[shift=(i,9-j)] ifnumitest=1 [fill=red] fi
          (0,0) rectangle (1,1);

          draw[very thick] (0,0) rectangle (10,10);
          ,
          pics/pft/.style=code=%
          pgfmathtruncatemacroimodint(#1/100)
          path foreach X in 0,...,imod
          (3*X,0) pic[scale=0.25]pf=#1-100*X;

          begintikzpicture[baseline=([yshift=-.5ex]current bounding box.center)]
          picpft=195;
          endtikzpicture
          begintikzpicture[baseline=([yshift=-.5ex]current bounding box.center)]
          picpft=273;
          endtikzpicture
          enddocument


          enter image description here






          share|improve this answer















          This defines a pic, whose argument is the number you are referring to, and draws the partly filled squares accordingly.



          documentclass[tikz,border=3mm]standalone
          begindocument
          tikzsetpics/pf/.style=code=foreach i in 0,...,9
          foreach j in 0,...,9
          pgfmathtruncatemacroitestifthenelse(i*10+j<#1,1,0)
          draw[shift=(i,9-j)] ifnumitest=1 [fill=red] fi
          (0,0) rectangle (1,1);

          draw[very thick] (0,0) rectangle (10,10);
          ,
          pics/pft/.style=code=%
          pgfmathtruncatemacroimodint(#1/100)
          path foreach X in 0,...,imod
          (3*X,0) pic[scale=0.25]pf=#1-100*X;

          begintikzpicture[baseline=([yshift=-.5ex]current bounding box.center)]
          picpft=195;
          endtikzpicture
          begintikzpicture[baseline=([yshift=-.5ex]current bounding box.center)]
          picpft=273;
          endtikzpicture
          enddocument


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 9 hours ago

























          answered 9 hours ago









          Schrödinger's catSchrödinger's cat

          10.3k13 silver badges30 bronze badges




          10.3k13 silver badges30 bronze badges


























              3
















              Something like this?



              documentclass[tikz]standalone
              usepackagetikz
              newcommandredsquare[1]%
              foreach i in 1,...,200

              pgfmathsetmacroRowNomod(i-1,10)
              pgfmathsetmacroColTmpfloor((i-1)/10)
              pgfmathsetmacroColNoifthenelse(ColTmp>9,ColTmp+1,ColTmp)
              typeoutRowNo,ColNo
              ifnum i > #1
              draw[shift=(ColNo,-RowNo),fill=white](0,0) rectangle (1,1);
              else
              draw[shift=(ColNo,-RowNo),fill=red](0,0) rectangle (1,1);
              fi

              draw [very thick] (0,1) rectangle +(10,-10);
              draw [very thick] (11,1) rectangle +(10,-10);


              begindocument

              begintikzpicture[scale=0.25]
              redsquare195

              beginscope[yshift=-13cm]
              redsquare163
              endscope
              endtikzpicture

              enddocument


              enter image description here






              share|improve this answer





























                3
















                Something like this?



                documentclass[tikz]standalone
                usepackagetikz
                newcommandredsquare[1]%
                foreach i in 1,...,200

                pgfmathsetmacroRowNomod(i-1,10)
                pgfmathsetmacroColTmpfloor((i-1)/10)
                pgfmathsetmacroColNoifthenelse(ColTmp>9,ColTmp+1,ColTmp)
                typeoutRowNo,ColNo
                ifnum i > #1
                draw[shift=(ColNo,-RowNo),fill=white](0,0) rectangle (1,1);
                else
                draw[shift=(ColNo,-RowNo),fill=red](0,0) rectangle (1,1);
                fi

                draw [very thick] (0,1) rectangle +(10,-10);
                draw [very thick] (11,1) rectangle +(10,-10);


                begindocument

                begintikzpicture[scale=0.25]
                redsquare195

                beginscope[yshift=-13cm]
                redsquare163
                endscope
                endtikzpicture

                enddocument


                enter image description here






                share|improve this answer



























                  3














                  3










                  3









                  Something like this?



                  documentclass[tikz]standalone
                  usepackagetikz
                  newcommandredsquare[1]%
                  foreach i in 1,...,200

                  pgfmathsetmacroRowNomod(i-1,10)
                  pgfmathsetmacroColTmpfloor((i-1)/10)
                  pgfmathsetmacroColNoifthenelse(ColTmp>9,ColTmp+1,ColTmp)
                  typeoutRowNo,ColNo
                  ifnum i > #1
                  draw[shift=(ColNo,-RowNo),fill=white](0,0) rectangle (1,1);
                  else
                  draw[shift=(ColNo,-RowNo),fill=red](0,0) rectangle (1,1);
                  fi

                  draw [very thick] (0,1) rectangle +(10,-10);
                  draw [very thick] (11,1) rectangle +(10,-10);


                  begindocument

                  begintikzpicture[scale=0.25]
                  redsquare195

                  beginscope[yshift=-13cm]
                  redsquare163
                  endscope
                  endtikzpicture

                  enddocument


                  enter image description here






                  share|improve this answer













                  Something like this?



                  documentclass[tikz]standalone
                  usepackagetikz
                  newcommandredsquare[1]%
                  foreach i in 1,...,200

                  pgfmathsetmacroRowNomod(i-1,10)
                  pgfmathsetmacroColTmpfloor((i-1)/10)
                  pgfmathsetmacroColNoifthenelse(ColTmp>9,ColTmp+1,ColTmp)
                  typeoutRowNo,ColNo
                  ifnum i > #1
                  draw[shift=(ColNo,-RowNo),fill=white](0,0) rectangle (1,1);
                  else
                  draw[shift=(ColNo,-RowNo),fill=red](0,0) rectangle (1,1);
                  fi

                  draw [very thick] (0,1) rectangle +(10,-10);
                  draw [very thick] (11,1) rectangle +(10,-10);


                  begindocument

                  begintikzpicture[scale=0.25]
                  redsquare195

                  beginscope[yshift=-13cm]
                  redsquare163
                  endscope
                  endtikzpicture

                  enddocument


                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 9 hours ago









                  Torbjørn T.Torbjørn T.

                  165k13 gold badges277 silver badges460 bronze badges




                  165k13 gold badges277 silver badges460 bronze badges
























                      jadou is a new contributor. Be nice, and check out our Code of Conduct.









                      draft saved

                      draft discarded

















                      jadou is a new contributor. Be nice, and check out our Code of Conduct.












                      jadou is a new contributor. Be nice, and check out our Code of Conduct.











                      jadou is a new contributor. Be nice, and check out our Code of Conduct.














                      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%2f510034%2ftikz-macro-to-draw-hundredth-of-a-square%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

                      Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                      Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                      199年 目錄 大件事 到箇年出世嗰人 到箇年死嗰人 節慶、風俗習慣 導覽選單