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;
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
New contributor
add a comment
|
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
New contributor
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
add a comment
|
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
New contributor
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
tikz-pgf draw
New contributor
New contributor
edited 22 mins ago
Abdulrahman Bres
1085 bronze badges
1085 bronze badges
New contributor
asked 9 hours ago
jadoujadou
82 bronze badges
82 bronze badges
New contributor
New contributor
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
add a comment
|
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
add a comment
|
2 Answers
2
active
oldest
votes
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
add a comment
|
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
add a comment
|
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
add a comment
|
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
add a comment
|
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
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
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
add a comment
|
add a comment
|
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
add a comment
|
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
add a comment
|
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
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
answered 9 hours ago
Torbjørn T.Torbjørn T.
165k13 gold badges277 silver badges460 bronze badges
165k13 gold badges277 silver badges460 bronze badges
add a comment
|
add a comment
|
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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