Using for loop in tikz to draw repeated shapes

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












7















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.



enter image description here



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:



enter image description here










share|improve this question



















  • 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
















7















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.



enter image description here



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:



enter image description here










share|improve this question



















  • 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














7












7








7








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.



enter image description here



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:



enter image description here










share|improve this question
















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.



enter image description here



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:



enter image description here







tikz-pgf foreach loops






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 13 at 8:20







Sndn

















asked Mar 13 at 7:20









SndnSndn

1775




1775







  • 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





    @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











1 Answer
1






active

oldest

votes


















13














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=- ++(-0.4,0.4)
to[out=180,in=180] ++ (0,-0.4) -- cycle;]
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


enter image description here






share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "85"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%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









    13














    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=- ++(-0.4,0.4)
    to[out=180,in=180] ++ (0,-0.4) -- cycle;]
    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


    enter image description here






    share|improve this answer



























      13














      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=- ++(-0.4,0.4)
      to[out=180,in=180] ++ (0,-0.4) -- cycle;]
      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


      enter image description here






      share|improve this answer

























        13












        13








        13







        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=- ++(-0.4,0.4)
        to[out=180,in=180] ++ (0,-0.4) -- cycle;]
        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


        enter image description here






        share|improve this answer













        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=- ++(-0.4,0.4)
        to[out=180,in=180] ++ (0,-0.4) -- cycle;]
        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


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 13 at 7:30









        marmotmarmot

        117k5150283




        117k5150283



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f479224%2fusing-for-loop-in-tikz-to-draw-repeated-shapes%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

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?