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













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

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













  • 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=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


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=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


    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=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


      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=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


        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=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


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 13 at 7:30









        marmotmarmot

        110k5136255




        110k5136255



























            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 should I support this large drywall patch? Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How do I cover large gaps in drywall?How do I keep drywall around a patch from crumbling?Can I glue a second layer of drywall?How to patch long strip on drywall?Large drywall patch: how to avoid bulging seams?Drywall Mesh Patch vs. Bulge? To remove or not to remove?How to fix this drywall job?Prep drywall before backsplashWhat's the best way to fix this horrible drywall patch job?Drywall patching using 3M Patch Plus Primer

            random experiment with two different functions on unit interval Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)Random variable and probability space notionsRandom Walk with EdgesFinding functions where the increase over a random interval is Poisson distributedNumber of days until dayCan an observed event in fact be of zero probability?Unit random processmodels of coins and uniform distributionHow to get the number of successes given $n$ trials , probability $P$ and a random variable $X$Absorbing Markov chain in a computer. Is “almost every” turned into always convergence in computer executions?Stopped random walk is not uniformly integrable

            Lowndes Grove History Architecture References Navigation menu32°48′6″N 79°57′58″W / 32.80167°N 79.96611°W / 32.80167; -79.9661132°48′6″N 79°57′58″W / 32.80167°N 79.96611°W / 32.80167; -79.9661178002500"National Register Information System"Historic houses of South Carolina"Lowndes Grove""+32° 48' 6.00", −79° 57' 58.00""Lowndes Grove, Charleston County (260 St. Margaret St., Charleston)""Lowndes Grove"The Charleston ExpositionIt Happened in South Carolina"Lowndes Grove (House), Saint Margaret Street & Sixth Avenue, Charleston, Charleston County, SC(Photographs)"Plantations of the Carolina Low Countrye