Using for loop in tikz to draw repeated shapesMaterials for learning TikZCustom figure with color barsUsing double for-loop in tikzRotate a node but not its content: the case of the ellipse decorationTikZ: Using Loop to Draw Grid of NodesWhat is the simplest way to align a line with a circle?Using pgfplotsinvokeforeach in foreach loopTikZ: Drawing an arc from an intersection to an intersectionLaTeX3 loop expanding to repeated sUsing foreach for repeated structureCreating lines of custom shapes in Tikz using foreachLoop code for repeated sums
Is this Pascal's Matrix?
How to read string as hex number in bash?
Why do I have a large white artefact on the rendered image?
Does convergence of polynomials imply that of its coefficients?
Animating wave motion in water
Symbolism of 18 Journeyers
What favor did Moody owe Dumbledore?
Print a physical multiplication table
Did Nintendo change its mind about 68000 SNES?
How to determine the greatest d orbital splitting?
Is VPN a layer 3 concept?
Do I need an EFI partition for each 18.04 ubuntu I have on my HD?
The English Debate
is this saw blade faulty?
Why doesn't the fusion process of the sun speed up?
Is xar preinstalled on macOS?
What happens when the centripetal force is equal and opposite to the centrifugal force?
Friend wants my recommendation but I don't want to give it to him
Have the tides ever turned twice on any open problem?
Which partition to make active?
Nested Dynamic SOQL Query
Determine voltage drop over 10G resistors with cheap multimeter
What is it called when someone votes for an option that's not their first choice?
How do you justify more code being written by following clean code practices?
Using for loop in tikz to draw repeated shapes
Materials for learning TikZCustom figure with color barsUsing double for-loop in tikzRotate a node but not its content: the case of the ellipse decorationTikZ: Using Loop to Draw Grid of NodesWhat is the simplest way to align a line with a circle?Using pgfplotsinvokeforeach in foreach loopTikZ: Drawing an arc from an intersection to an intersectionLaTeX3 loop expanding to repeated sUsing foreach for repeated structureCreating lines of custom shapes in Tikz using foreachLoop code for repeated sums
I am trying to create a lenticular pattern like the one in the picture.
I believe the repeated shape can be drawn using a for loop in tikz, but I wasn't able to get it done properly.
Appreciate any help on looping.
Edit: This is a part of a bigger diagram and below is the code.
begindocument
begintikzpicture[>=Stealth[inset=0pt,length=10pt,angle'=35,round]]
pgfmathsetmacrolensRadius6
pgfmathsetmacrolensHeight3
pgfmathsetmacrostartAngleasin(lensHeight/lensRadius)
draw [] (0,lensHeight)
arc[start angle=180-startAngle,delta
angle=2*startAngle,radius=lensRadius]node [below, align=center] \
[1em]Main\[-1ex]lens
arc[start angle=-startAngle,delta angle=2*startAngle,radius=lensRadius]
-- cycle;
draw [line width=1mm ] (-1.5,3) -- (-1.5,-3) node [below, align=center] \
[1em]Weak\[-1ex]diffuser;
draw [] (6,lensHeight)
arc[start angle=180-startAngle,delta
angle=2*startAngle,radius=lensRadius]node [below, align=center] \
[1em]Field\[-1ex]lens
-- cycle;
draw[] plot[only marks, mark=*,mark size=10pt,mark options=fill=Sepia]
coordinates(-6.5,0) node[below, align=center]\[1em]Object;
draw[] (-6,0) -- (0,3);
draw[] (-6,0) -- (0,-3);
draw[] (6.5,0) -- (0,3);
draw[] (6.5,0) -- (0,-3);
%lenticular pattern
pgfmathsetmacrolensRadius0.2
pgfmathsetmacrolensHeight0.2
pgfmathsetmacrostartAngleasin(lensHeight/lensRadius)
draw [] (8,lensHeight)
arc[start angle=180-startAngle,delta
angle=2*startAngle,radius=lensRadius];
draw [line width=0.25mm ] (8,3) -- (8,-3) -- (8.2,-3) -- (8.2,3) -- cycle;
endtikzpicture
enddocument
Output:
tikz-pgf foreach loops
add a comment |
I am trying to create a lenticular pattern like the one in the picture.
I believe the repeated shape can be drawn using a for loop in tikz, but I wasn't able to get it done properly.
Appreciate any help on looping.
Edit: This is a part of a bigger diagram and below is the code.
begindocument
begintikzpicture[>=Stealth[inset=0pt,length=10pt,angle'=35,round]]
pgfmathsetmacrolensRadius6
pgfmathsetmacrolensHeight3
pgfmathsetmacrostartAngleasin(lensHeight/lensRadius)
draw [] (0,lensHeight)
arc[start angle=180-startAngle,delta
angle=2*startAngle,radius=lensRadius]node [below, align=center] \
[1em]Main\[-1ex]lens
arc[start angle=-startAngle,delta angle=2*startAngle,radius=lensRadius]
-- cycle;
draw [line width=1mm ] (-1.5,3) -- (-1.5,-3) node [below, align=center] \
[1em]Weak\[-1ex]diffuser;
draw [] (6,lensHeight)
arc[start angle=180-startAngle,delta
angle=2*startAngle,radius=lensRadius]node [below, align=center] \
[1em]Field\[-1ex]lens
-- cycle;
draw[] plot[only marks, mark=*,mark size=10pt,mark options=fill=Sepia]
coordinates(-6.5,0) node[below, align=center]\[1em]Object;
draw[] (-6,0) -- (0,3);
draw[] (-6,0) -- (0,-3);
draw[] (6.5,0) -- (0,3);
draw[] (6.5,0) -- (0,-3);
%lenticular pattern
pgfmathsetmacrolensRadius0.2
pgfmathsetmacrolensHeight0.2
pgfmathsetmacrostartAngleasin(lensHeight/lensRadius)
draw [] (8,lensHeight)
arc[start angle=180-startAngle,delta
angle=2*startAngle,radius=lensRadius];
draw [line width=0.25mm ] (8,3) -- (8,-3) -- (8.2,-3) -- (8.2,3) -- cycle;
endtikzpicture
enddocument
Output:
tikz-pgf foreach loops
1
@Raaja sometimes one simply has no clue where to start :) I wouldn't close a question simply because one doesn't know how to do something: that's why they're here.
– Superuser27
Mar 13 at 7:38
2
@Superuser27 An OP doesnt always need a perfect MWE to start with. But atleast some commitment or motivation should be there behind a question, instead of knowing the way how to proceed and not trying it. Everyone of us makes mistakes (I am also learning things that way). In this case OP knows what to do, and has the recipies to do. It's just a matter of trial-and-error to atleast begin something. If you see this: tex.stackexchange.com/questions/472117/… then OP already has some knowledge on where to start with:)
.
– Raaja
Mar 13 at 7:45
1
@Raaja Thanks for pointing out. Added the code and the output I got so far.
– Sndn
Mar 13 at 8:22
@sndn good!! +1 since, this question already has an answer given by marmot. Consider accepting it, if you think that solves your issue.
– Raaja
Mar 13 at 8:30
add a comment |
I am trying to create a lenticular pattern like the one in the picture.
I believe the repeated shape can be drawn using a for loop in tikz, but I wasn't able to get it done properly.
Appreciate any help on looping.
Edit: This is a part of a bigger diagram and below is the code.
begindocument
begintikzpicture[>=Stealth[inset=0pt,length=10pt,angle'=35,round]]
pgfmathsetmacrolensRadius6
pgfmathsetmacrolensHeight3
pgfmathsetmacrostartAngleasin(lensHeight/lensRadius)
draw [] (0,lensHeight)
arc[start angle=180-startAngle,delta
angle=2*startAngle,radius=lensRadius]node [below, align=center] \
[1em]Main\[-1ex]lens
arc[start angle=-startAngle,delta angle=2*startAngle,radius=lensRadius]
-- cycle;
draw [line width=1mm ] (-1.5,3) -- (-1.5,-3) node [below, align=center] \
[1em]Weak\[-1ex]diffuser;
draw [] (6,lensHeight)
arc[start angle=180-startAngle,delta
angle=2*startAngle,radius=lensRadius]node [below, align=center] \
[1em]Field\[-1ex]lens
-- cycle;
draw[] plot[only marks, mark=*,mark size=10pt,mark options=fill=Sepia]
coordinates(-6.5,0) node[below, align=center]\[1em]Object;
draw[] (-6,0) -- (0,3);
draw[] (-6,0) -- (0,-3);
draw[] (6.5,0) -- (0,3);
draw[] (6.5,0) -- (0,-3);
%lenticular pattern
pgfmathsetmacrolensRadius0.2
pgfmathsetmacrolensHeight0.2
pgfmathsetmacrostartAngleasin(lensHeight/lensRadius)
draw [] (8,lensHeight)
arc[start angle=180-startAngle,delta
angle=2*startAngle,radius=lensRadius];
draw [line width=0.25mm ] (8,3) -- (8,-3) -- (8.2,-3) -- (8.2,3) -- cycle;
endtikzpicture
enddocument
Output:
tikz-pgf foreach loops
I am trying to create a lenticular pattern like the one in the picture.
I believe the repeated shape can be drawn using a for loop in tikz, but I wasn't able to get it done properly.
Appreciate any help on looping.
Edit: This is a part of a bigger diagram and below is the code.
begindocument
begintikzpicture[>=Stealth[inset=0pt,length=10pt,angle'=35,round]]
pgfmathsetmacrolensRadius6
pgfmathsetmacrolensHeight3
pgfmathsetmacrostartAngleasin(lensHeight/lensRadius)
draw [] (0,lensHeight)
arc[start angle=180-startAngle,delta
angle=2*startAngle,radius=lensRadius]node [below, align=center] \
[1em]Main\[-1ex]lens
arc[start angle=-startAngle,delta angle=2*startAngle,radius=lensRadius]
-- cycle;
draw [line width=1mm ] (-1.5,3) -- (-1.5,-3) node [below, align=center] \
[1em]Weak\[-1ex]diffuser;
draw [] (6,lensHeight)
arc[start angle=180-startAngle,delta
angle=2*startAngle,radius=lensRadius]node [below, align=center] \
[1em]Field\[-1ex]lens
-- cycle;
draw[] plot[only marks, mark=*,mark size=10pt,mark options=fill=Sepia]
coordinates(-6.5,0) node[below, align=center]\[1em]Object;
draw[] (-6,0) -- (0,3);
draw[] (-6,0) -- (0,-3);
draw[] (6.5,0) -- (0,3);
draw[] (6.5,0) -- (0,-3);
%lenticular pattern
pgfmathsetmacrolensRadius0.2
pgfmathsetmacrolensHeight0.2
pgfmathsetmacrostartAngleasin(lensHeight/lensRadius)
draw [] (8,lensHeight)
arc[start angle=180-startAngle,delta
angle=2*startAngle,radius=lensRadius];
draw [line width=0.25mm ] (8,3) -- (8,-3) -- (8.2,-3) -- (8.2,3) -- cycle;
endtikzpicture
enddocument
Output:
tikz-pgf foreach loops
tikz-pgf foreach loops
edited Mar 13 at 8:20
Sndn
asked Mar 13 at 7:20
SndnSndn
1555
1555
1
@Raaja sometimes one simply has no clue where to start :) I wouldn't close a question simply because one doesn't know how to do something: that's why they're here.
– Superuser27
Mar 13 at 7:38
2
@Superuser27 An OP doesnt always need a perfect MWE to start with. But atleast some commitment or motivation should be there behind a question, instead of knowing the way how to proceed and not trying it. Everyone of us makes mistakes (I am also learning things that way). In this case OP knows what to do, and has the recipies to do. It's just a matter of trial-and-error to atleast begin something. If you see this: tex.stackexchange.com/questions/472117/… then OP already has some knowledge on where to start with:)
.
– Raaja
Mar 13 at 7:45
1
@Raaja Thanks for pointing out. Added the code and the output I got so far.
– Sndn
Mar 13 at 8:22
@sndn good!! +1 since, this question already has an answer given by marmot. Consider accepting it, if you think that solves your issue.
– Raaja
Mar 13 at 8:30
add a comment |
1
@Raaja sometimes one simply has no clue where to start :) I wouldn't close a question simply because one doesn't know how to do something: that's why they're here.
– Superuser27
Mar 13 at 7:38
2
@Superuser27 An OP doesnt always need a perfect MWE to start with. But atleast some commitment or motivation should be there behind a question, instead of knowing the way how to proceed and not trying it. Everyone of us makes mistakes (I am also learning things that way). In this case OP knows what to do, and has the recipies to do. It's just a matter of trial-and-error to atleast begin something. If you see this: tex.stackexchange.com/questions/472117/… then OP already has some knowledge on where to start with:)
.
– Raaja
Mar 13 at 7:45
1
@Raaja Thanks for pointing out. Added the code and the output I got so far.
– Sndn
Mar 13 at 8:22
@sndn good!! +1 since, this question already has an answer given by marmot. Consider accepting it, if you think that solves your issue.
– Raaja
Mar 13 at 8:30
1
1
@Raaja sometimes one simply has no clue where to start :) I wouldn't close a question simply because one doesn't know how to do something: that's why they're here.
– Superuser27
Mar 13 at 7:38
@Raaja sometimes one simply has no clue where to start :) I wouldn't close a question simply because one doesn't know how to do something: that's why they're here.
– Superuser27
Mar 13 at 7:38
2
2
@Superuser27 An OP doesnt always need a perfect MWE to start with. But atleast some commitment or motivation should be there behind a question, instead of knowing the way how to proceed and not trying it. Everyone of us makes mistakes (I am also learning things that way). In this case OP knows what to do, and has the recipies to do. It's just a matter of trial-and-error to atleast begin something. If you see this: tex.stackexchange.com/questions/472117/… then OP already has some knowledge on where to start with
:)
.– Raaja
Mar 13 at 7:45
@Superuser27 An OP doesnt always need a perfect MWE to start with. But atleast some commitment or motivation should be there behind a question, instead of knowing the way how to proceed and not trying it. Everyone of us makes mistakes (I am also learning things that way). In this case OP knows what to do, and has the recipies to do. It's just a matter of trial-and-error to atleast begin something. If you see this: tex.stackexchange.com/questions/472117/… then OP already has some knowledge on where to start with
:)
.– Raaja
Mar 13 at 7:45
1
1
@Raaja Thanks for pointing out. Added the code and the output I got so far.
– Sndn
Mar 13 at 8:22
@Raaja Thanks for pointing out. Added the code and the output I got so far.
– Sndn
Mar 13 at 8:22
@sndn good!! +1 since, this question already has an answer given by marmot. Consider accepting it, if you think that solves your issue.
– Raaja
Mar 13 at 8:30
@sndn good!! +1 since, this question already has an answer given by marmot. Consider accepting it, if you think that solves your issue.
– Raaja
Mar 13 at 8:30
add a comment |
1 Answer
1
active
oldest
votes
There are many possibilities to draw something like is, here is one of them.
documentclass[tikz,border=3.14mm]standalone
begindocument
begintikzpicture[pics/rr/.style=code=draw (0.2,-0.2) ]
path foreach X in 0,1,...,10
(0,0.4*X) picrr;
draw (0.2,-0.2) rectangle (0.4,10*0.4+0.2);
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/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
);
);
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%2f479224%2fusing-for-loop-in-tikz-to-draw-repeated-shapes%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
There are many possibilities to draw something like is, here is one of them.
documentclass[tikz,border=3.14mm]standalone
begindocument
begintikzpicture[pics/rr/.style=code=draw (0.2,-0.2) ]
path foreach X in 0,1,...,10
(0,0.4*X) picrr;
draw (0.2,-0.2) rectangle (0.4,10*0.4+0.2);
endtikzpicture
enddocument
add a comment |
There are many possibilities to draw something like is, here is one of them.
documentclass[tikz,border=3.14mm]standalone
begindocument
begintikzpicture[pics/rr/.style=code=draw (0.2,-0.2) ]
path foreach X in 0,1,...,10
(0,0.4*X) picrr;
draw (0.2,-0.2) rectangle (0.4,10*0.4+0.2);
endtikzpicture
enddocument
add a comment |
There are many possibilities to draw something like is, here is one of them.
documentclass[tikz,border=3.14mm]standalone
begindocument
begintikzpicture[pics/rr/.style=code=draw (0.2,-0.2) ]
path foreach X in 0,1,...,10
(0,0.4*X) picrr;
draw (0.2,-0.2) rectangle (0.4,10*0.4+0.2);
endtikzpicture
enddocument
There are many possibilities to draw something like is, here is one of them.
documentclass[tikz,border=3.14mm]standalone
begindocument
begintikzpicture[pics/rr/.style=code=draw (0.2,-0.2) ]
path foreach X in 0,1,...,10
(0,0.4*X) picrr;
draw (0.2,-0.2) rectangle (0.4,10*0.4+0.2);
endtikzpicture
enddocument
answered Mar 13 at 7:30
marmotmarmot
110k5136255
110k5136255
add a comment |
add a comment |
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%2f479224%2fusing-for-loop-in-tikz-to-draw-repeated-shapes%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
@Raaja sometimes one simply has no clue where to start :) I wouldn't close a question simply because one doesn't know how to do something: that's why they're here.
– Superuser27
Mar 13 at 7:38
2
@Superuser27 An OP doesnt always need a perfect MWE to start with. But atleast some commitment or motivation should be there behind a question, instead of knowing the way how to proceed and not trying it. Everyone of us makes mistakes (I am also learning things that way). In this case OP knows what to do, and has the recipies to do. It's just a matter of trial-and-error to atleast begin something. If you see this: tex.stackexchange.com/questions/472117/… then OP already has some knowledge on where to start with
:)
.– Raaja
Mar 13 at 7:45
1
@Raaja Thanks for pointing out. Added the code and the output I got so far.
– Sndn
Mar 13 at 8:22
@sndn good!! +1 since, this question already has an answer given by marmot. Consider accepting it, if you think that solves your issue.
– Raaja
Mar 13 at 8:30