Simplifying foreach to repeat a drawing

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











up vote
5
down vote

favorite












I use the following code to repeat a drawing. Can it be simplified?



documentclassbeamer
setbeamertemplatenavigation symbols
usepackagetikz
begindocument
beginframe[fragile,t]
frametitle
begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75,1,1.25,1.5,1.75,2,2.25,2.5,2.75,3,3.25,3.5,3.75,4,4.25
draw<2-4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75,4.25
draw<2> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in .75,1,1.25,1.5,1.75,2,2.25,2.5,2.75,3,3.25,3.5,3.75,4,4.25
draw<3,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in .75
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75,1,1.25,1.5,1.75,2,2.25,2.5,2.75,3,3.25,3.5,3.75,4,4.25
draw<2-4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
endtikzpicture
endframe
enddocument


Enter image description here



Enter image description here



Enter image description here



Enter image description here










share|improve this question



















  • 2




    Maybe you should think about using decorated paths (with dot-like markers), but then you would not need to draw every circle, only the "paths".
    – TeXnician
    Sep 25 at 5:57











  • Thank you. Can you please post your suggested code. I do not know how to do it.
    – Hany
    Sep 25 at 6:02











  • Unfortunately, I do not have that much experience in markers, but that's what a manual is for.
    – TeXnician
    Sep 25 at 6:11














up vote
5
down vote

favorite












I use the following code to repeat a drawing. Can it be simplified?



documentclassbeamer
setbeamertemplatenavigation symbols
usepackagetikz
begindocument
beginframe[fragile,t]
frametitle
begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75,1,1.25,1.5,1.75,2,2.25,2.5,2.75,3,3.25,3.5,3.75,4,4.25
draw<2-4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75,4.25
draw<2> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in .75,1,1.25,1.5,1.75,2,2.25,2.5,2.75,3,3.25,3.5,3.75,4,4.25
draw<3,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in .75
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75,1,1.25,1.5,1.75,2,2.25,2.5,2.75,3,3.25,3.5,3.75,4,4.25
draw<2-4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
endtikzpicture
endframe
enddocument


Enter image description here



Enter image description here



Enter image description here



Enter image description here










share|improve this question



















  • 2




    Maybe you should think about using decorated paths (with dot-like markers), but then you would not need to draw every circle, only the "paths".
    – TeXnician
    Sep 25 at 5:57











  • Thank you. Can you please post your suggested code. I do not know how to do it.
    – Hany
    Sep 25 at 6:02











  • Unfortunately, I do not have that much experience in markers, but that's what a manual is for.
    – TeXnician
    Sep 25 at 6:11












up vote
5
down vote

favorite









up vote
5
down vote

favorite











I use the following code to repeat a drawing. Can it be simplified?



documentclassbeamer
setbeamertemplatenavigation symbols
usepackagetikz
begindocument
beginframe[fragile,t]
frametitle
begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75,1,1.25,1.5,1.75,2,2.25,2.5,2.75,3,3.25,3.5,3.75,4,4.25
draw<2-4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75,4.25
draw<2> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in .75,1,1.25,1.5,1.75,2,2.25,2.5,2.75,3,3.25,3.5,3.75,4,4.25
draw<3,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in .75
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75,1,1.25,1.5,1.75,2,2.25,2.5,2.75,3,3.25,3.5,3.75,4,4.25
draw<2-4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
endtikzpicture
endframe
enddocument


Enter image description here



Enter image description here



Enter image description here



Enter image description here










share|improve this question















I use the following code to repeat a drawing. Can it be simplified?



documentclassbeamer
setbeamertemplatenavigation symbols
usepackagetikz
begindocument
beginframe[fragile,t]
frametitle
begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75,1,1.25,1.5,1.75,2,2.25,2.5,2.75,3,3.25,3.5,3.75,4,4.25
draw<2-4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75,4.25
draw<2> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in .75,1,1.25,1.5,1.75,2,2.25,2.5,2.75,3,3.25,3.5,3.75,4,4.25
draw<3,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in .75
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75
draw<2,3> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
foreach x in 4.25
draw<2,4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
foreach x in .75,1,1.25,1.5,1.75,2,2.25,2.5,2.75,3,3.25,3.5,3.75,4,4.25
draw<2-4> (x,0) node [circle, draw, very thick, green!40!black, fill=green, scale=0.6];
endtikzpicture

vspace -.18cm

begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
draw (x,0) node [circle, draw, brown, fill=yellow, scale=0.5];
endtikzpicture
endframe
enddocument


Enter image description here



Enter image description here



Enter image description here



Enter image description here







tikz-pgf foreach






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 25 at 17:22









Diaa

2,34511643




2,34511643










asked Sep 25 at 5:50









Hany

788314




788314







  • 2




    Maybe you should think about using decorated paths (with dot-like markers), but then you would not need to draw every circle, only the "paths".
    – TeXnician
    Sep 25 at 5:57











  • Thank you. Can you please post your suggested code. I do not know how to do it.
    – Hany
    Sep 25 at 6:02











  • Unfortunately, I do not have that much experience in markers, but that's what a manual is for.
    – TeXnician
    Sep 25 at 6:11












  • 2




    Maybe you should think about using decorated paths (with dot-like markers), but then you would not need to draw every circle, only the "paths".
    – TeXnician
    Sep 25 at 5:57











  • Thank you. Can you please post your suggested code. I do not know how to do it.
    – Hany
    Sep 25 at 6:02











  • Unfortunately, I do not have that much experience in markers, but that's what a manual is for.
    – TeXnician
    Sep 25 at 6:11







2




2




Maybe you should think about using decorated paths (with dot-like markers), but then you would not need to draw every circle, only the "paths".
– TeXnician
Sep 25 at 5:57





Maybe you should think about using decorated paths (with dot-like markers), but then you would not need to draw every circle, only the "paths".
– TeXnician
Sep 25 at 5:57













Thank you. Can you please post your suggested code. I do not know how to do it.
– Hany
Sep 25 at 6:02





Thank you. Can you please post your suggested code. I do not know how to do it.
– Hany
Sep 25 at 6:02













Unfortunately, I do not have that much experience in markers, but that's what a manual is for.
– TeXnician
Sep 25 at 6:11




Unfortunately, I do not have that much experience in markers, but that's what a manual is for.
– TeXnician
Sep 25 at 6:11










2 Answers
2






active

oldest

votes

















up vote
7
down vote



accepted










Very simple suggestion: use only one TikZpicture and only draw what is needed accounting the duplication of some nodes in the different stages.



documentclass[svgnames]beamer
setbeamertemplatenavigation symbols
usepackagetikz
begindocument
beginframe[fragile,t]
frametitle
begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
foreach y in 0,.25,.5,.75,1,...,4
fill[draw=brown, fill=yellow] (x,-y) circle (3pt);


only<2-4>
foreach x in .75,1,1.25,...,4.25
fill[draw=DarkGreen, fill=green] (x,-.25) circle (3pt);
fill[draw=DarkGreen, fill=green] (x,-3.75) circle (3pt);


only<2,4>
foreach x in -.5,-.75,-1,...,-2
pgfmathsetmacroyx-1.75
fill[draw=DarkGreen, fill=green] (.75,x) circle (3pt);
fill[draw=DarkGreen, fill=green] (4.25,y) circle (3pt);


only<2-3>
foreach x in -.5,-.75,-1,...,-2
pgfmathsetmacroyx-1.75
fill[draw=DarkGreen, fill=green] (4.25,x) circle (3pt);
fill[draw=DarkGreen, fill=green] (.75,y) circle (3pt);


only<3-4>
foreach x in .75,1,1.25,...,4.25
fill[draw=DarkGreen, fill=green] (x,-2) circle (3pt);


endtikzpicture
endframe
enddocument





share|improve this answer




















  • Thank you very much. Just one enquiry. What is [svgnames] used for?
    – Hany
    Sep 25 at 6:17










  • @Hany DarkGreen.
    – TeXnician
    Sep 25 at 6:20










  • Thank you for your time and effort.
    – Hany
    Sep 25 at 6:22

















up vote
9
down vote













You can cheat:



  1. Fill a rectangle.

  2. Draw the path.

  3. Fill everything but the rectangles circles white.

Code:



documentclassbeamer
setbeamertemplatenavigation symbols
usepackagetikz
begindocument
beginframe[fragile,t]
frametitleSome dotted path
only<1>Fill a rectangle
only<2>Draw the path
only<3>Fill everything but the circles white

begintikzpicture
clip (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
fill[yellow] (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
pause
draw[line width=7pt,green!40!black] (3*8pt,1*8pt) rectangle (22*8pt,24*8pt);
pause
draw[brown,fill=white,even odd rule]
(-5pt,-5pt) rectangle (25.5*8pt+1pt,25.5*8pt+1pt)
foreach X in 0,...,25
foreach Y in 0,...,25
(X*8pt,Y*8pt) circle (3.5pt)

;
endtikzpicture
endframe

beginframe[fragile,t]
frametitleSome dotted path (cont'd)

begintikzpicture
clip (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
fill[yellow] (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
draw[line width=7pt,green!40!black,line cap=round] (3*8pt,24*8pt)
-- (22*8pt,24*8pt) -- (22*8pt,13*8pt)
-- (3*8pt,13*8pt) -- (3*8pt,1*8pt) -- (22*8pt,1*8pt);
draw[brown,fill=white,even odd rule]
(-5pt,-5pt) rectangle (25.5*8pt+1pt,25.5*8pt+1pt)
foreach X in 0,...,25
foreach Y in 0,...,25
(X*8pt,Y*8pt) circle (3.5pt)

;
endtikzpicture
endframe

beginframe[fragile,t]
frametitleSome dotted path (cont'd)

begintikzpicture[xscale=-1]
clip (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
fill[yellow] (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
draw[line width=7pt,green!40!black,line cap=round] (3*8pt,24*8pt)
-- (22*8pt,24*8pt) -- (22*8pt,13*8pt)
-- (3*8pt,13*8pt) -- (3*8pt,1*8pt) -- (22*8pt,1*8pt);
draw[brown,fill=white,even odd rule]
(-5pt,-5pt) rectangle (25.5*8pt+1pt,25.5*8pt+1pt)
foreach X in 0,...,25
foreach Y in 0,...,25
(X*8pt,Y*8pt) circle (3.5pt)

;
endtikzpicture
endframe
enddocument


Result:



enter image description here






share|improve this answer






















  • Thank you very much. How to draw the other figures (2) and (5)?
    – Hany
    Sep 25 at 6:21






  • 2




    That's a great idea :)
    – TeXnician
    Sep 25 at 6:21






  • 2




    @Hany I added them. I guess this method becomes more advantageous the more complex the curve is.
    – marmot
    Sep 25 at 6:28










  • Thank you very much.
    – Hany
    Sep 25 at 6:34






  • 1




    @BlackMild Yes, it is an animated gif, created by convert -density 300 -delay 96 -loop 0 -alpha remove multipage.pdf animated.gif, see this answer.
    – marmot
    Sep 25 at 12:43










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',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
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%2f452369%2fsimplifying-foreach-to-repeat-a-drawing%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
7
down vote



accepted










Very simple suggestion: use only one TikZpicture and only draw what is needed accounting the duplication of some nodes in the different stages.



documentclass[svgnames]beamer
setbeamertemplatenavigation symbols
usepackagetikz
begindocument
beginframe[fragile,t]
frametitle
begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
foreach y in 0,.25,.5,.75,1,...,4
fill[draw=brown, fill=yellow] (x,-y) circle (3pt);


only<2-4>
foreach x in .75,1,1.25,...,4.25
fill[draw=DarkGreen, fill=green] (x,-.25) circle (3pt);
fill[draw=DarkGreen, fill=green] (x,-3.75) circle (3pt);


only<2,4>
foreach x in -.5,-.75,-1,...,-2
pgfmathsetmacroyx-1.75
fill[draw=DarkGreen, fill=green] (.75,x) circle (3pt);
fill[draw=DarkGreen, fill=green] (4.25,y) circle (3pt);


only<2-3>
foreach x in -.5,-.75,-1,...,-2
pgfmathsetmacroyx-1.75
fill[draw=DarkGreen, fill=green] (4.25,x) circle (3pt);
fill[draw=DarkGreen, fill=green] (.75,y) circle (3pt);


only<3-4>
foreach x in .75,1,1.25,...,4.25
fill[draw=DarkGreen, fill=green] (x,-2) circle (3pt);


endtikzpicture
endframe
enddocument





share|improve this answer




















  • Thank you very much. Just one enquiry. What is [svgnames] used for?
    – Hany
    Sep 25 at 6:17










  • @Hany DarkGreen.
    – TeXnician
    Sep 25 at 6:20










  • Thank you for your time and effort.
    – Hany
    Sep 25 at 6:22














up vote
7
down vote



accepted










Very simple suggestion: use only one TikZpicture and only draw what is needed accounting the duplication of some nodes in the different stages.



documentclass[svgnames]beamer
setbeamertemplatenavigation symbols
usepackagetikz
begindocument
beginframe[fragile,t]
frametitle
begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
foreach y in 0,.25,.5,.75,1,...,4
fill[draw=brown, fill=yellow] (x,-y) circle (3pt);


only<2-4>
foreach x in .75,1,1.25,...,4.25
fill[draw=DarkGreen, fill=green] (x,-.25) circle (3pt);
fill[draw=DarkGreen, fill=green] (x,-3.75) circle (3pt);


only<2,4>
foreach x in -.5,-.75,-1,...,-2
pgfmathsetmacroyx-1.75
fill[draw=DarkGreen, fill=green] (.75,x) circle (3pt);
fill[draw=DarkGreen, fill=green] (4.25,y) circle (3pt);


only<2-3>
foreach x in -.5,-.75,-1,...,-2
pgfmathsetmacroyx-1.75
fill[draw=DarkGreen, fill=green] (4.25,x) circle (3pt);
fill[draw=DarkGreen, fill=green] (.75,y) circle (3pt);


only<3-4>
foreach x in .75,1,1.25,...,4.25
fill[draw=DarkGreen, fill=green] (x,-2) circle (3pt);


endtikzpicture
endframe
enddocument





share|improve this answer




















  • Thank you very much. Just one enquiry. What is [svgnames] used for?
    – Hany
    Sep 25 at 6:17










  • @Hany DarkGreen.
    – TeXnician
    Sep 25 at 6:20










  • Thank you for your time and effort.
    – Hany
    Sep 25 at 6:22












up vote
7
down vote



accepted







up vote
7
down vote



accepted






Very simple suggestion: use only one TikZpicture and only draw what is needed accounting the duplication of some nodes in the different stages.



documentclass[svgnames]beamer
setbeamertemplatenavigation symbols
usepackagetikz
begindocument
beginframe[fragile,t]
frametitle
begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
foreach y in 0,.25,.5,.75,1,...,4
fill[draw=brown, fill=yellow] (x,-y) circle (3pt);


only<2-4>
foreach x in .75,1,1.25,...,4.25
fill[draw=DarkGreen, fill=green] (x,-.25) circle (3pt);
fill[draw=DarkGreen, fill=green] (x,-3.75) circle (3pt);


only<2,4>
foreach x in -.5,-.75,-1,...,-2
pgfmathsetmacroyx-1.75
fill[draw=DarkGreen, fill=green] (.75,x) circle (3pt);
fill[draw=DarkGreen, fill=green] (4.25,y) circle (3pt);


only<2-3>
foreach x in -.5,-.75,-1,...,-2
pgfmathsetmacroyx-1.75
fill[draw=DarkGreen, fill=green] (4.25,x) circle (3pt);
fill[draw=DarkGreen, fill=green] (.75,y) circle (3pt);


only<3-4>
foreach x in .75,1,1.25,...,4.25
fill[draw=DarkGreen, fill=green] (x,-2) circle (3pt);


endtikzpicture
endframe
enddocument





share|improve this answer












Very simple suggestion: use only one TikZpicture and only draw what is needed accounting the duplication of some nodes in the different stages.



documentclass[svgnames]beamer
setbeamertemplatenavigation symbols
usepackagetikz
begindocument
beginframe[fragile,t]
frametitle
begintikzpicture
foreach x in 0,.25,.5,.75,1,...,5
foreach y in 0,.25,.5,.75,1,...,4
fill[draw=brown, fill=yellow] (x,-y) circle (3pt);


only<2-4>
foreach x in .75,1,1.25,...,4.25
fill[draw=DarkGreen, fill=green] (x,-.25) circle (3pt);
fill[draw=DarkGreen, fill=green] (x,-3.75) circle (3pt);


only<2,4>
foreach x in -.5,-.75,-1,...,-2
pgfmathsetmacroyx-1.75
fill[draw=DarkGreen, fill=green] (.75,x) circle (3pt);
fill[draw=DarkGreen, fill=green] (4.25,y) circle (3pt);


only<2-3>
foreach x in -.5,-.75,-1,...,-2
pgfmathsetmacroyx-1.75
fill[draw=DarkGreen, fill=green] (4.25,x) circle (3pt);
fill[draw=DarkGreen, fill=green] (.75,y) circle (3pt);


only<3-4>
foreach x in .75,1,1.25,...,4.25
fill[draw=DarkGreen, fill=green] (x,-2) circle (3pt);


endtikzpicture
endframe
enddocument






share|improve this answer












share|improve this answer



share|improve this answer










answered Sep 25 at 6:11









TeXnician

22.1k52882




22.1k52882











  • Thank you very much. Just one enquiry. What is [svgnames] used for?
    – Hany
    Sep 25 at 6:17










  • @Hany DarkGreen.
    – TeXnician
    Sep 25 at 6:20










  • Thank you for your time and effort.
    – Hany
    Sep 25 at 6:22
















  • Thank you very much. Just one enquiry. What is [svgnames] used for?
    – Hany
    Sep 25 at 6:17










  • @Hany DarkGreen.
    – TeXnician
    Sep 25 at 6:20










  • Thank you for your time and effort.
    – Hany
    Sep 25 at 6:22















Thank you very much. Just one enquiry. What is [svgnames] used for?
– Hany
Sep 25 at 6:17




Thank you very much. Just one enquiry. What is [svgnames] used for?
– Hany
Sep 25 at 6:17












@Hany DarkGreen.
– TeXnician
Sep 25 at 6:20




@Hany DarkGreen.
– TeXnician
Sep 25 at 6:20












Thank you for your time and effort.
– Hany
Sep 25 at 6:22




Thank you for your time and effort.
– Hany
Sep 25 at 6:22










up vote
9
down vote













You can cheat:



  1. Fill a rectangle.

  2. Draw the path.

  3. Fill everything but the rectangles circles white.

Code:



documentclassbeamer
setbeamertemplatenavigation symbols
usepackagetikz
begindocument
beginframe[fragile,t]
frametitleSome dotted path
only<1>Fill a rectangle
only<2>Draw the path
only<3>Fill everything but the circles white

begintikzpicture
clip (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
fill[yellow] (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
pause
draw[line width=7pt,green!40!black] (3*8pt,1*8pt) rectangle (22*8pt,24*8pt);
pause
draw[brown,fill=white,even odd rule]
(-5pt,-5pt) rectangle (25.5*8pt+1pt,25.5*8pt+1pt)
foreach X in 0,...,25
foreach Y in 0,...,25
(X*8pt,Y*8pt) circle (3.5pt)

;
endtikzpicture
endframe

beginframe[fragile,t]
frametitleSome dotted path (cont'd)

begintikzpicture
clip (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
fill[yellow] (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
draw[line width=7pt,green!40!black,line cap=round] (3*8pt,24*8pt)
-- (22*8pt,24*8pt) -- (22*8pt,13*8pt)
-- (3*8pt,13*8pt) -- (3*8pt,1*8pt) -- (22*8pt,1*8pt);
draw[brown,fill=white,even odd rule]
(-5pt,-5pt) rectangle (25.5*8pt+1pt,25.5*8pt+1pt)
foreach X in 0,...,25
foreach Y in 0,...,25
(X*8pt,Y*8pt) circle (3.5pt)

;
endtikzpicture
endframe

beginframe[fragile,t]
frametitleSome dotted path (cont'd)

begintikzpicture[xscale=-1]
clip (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
fill[yellow] (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
draw[line width=7pt,green!40!black,line cap=round] (3*8pt,24*8pt)
-- (22*8pt,24*8pt) -- (22*8pt,13*8pt)
-- (3*8pt,13*8pt) -- (3*8pt,1*8pt) -- (22*8pt,1*8pt);
draw[brown,fill=white,even odd rule]
(-5pt,-5pt) rectangle (25.5*8pt+1pt,25.5*8pt+1pt)
foreach X in 0,...,25
foreach Y in 0,...,25
(X*8pt,Y*8pt) circle (3.5pt)

;
endtikzpicture
endframe
enddocument


Result:



enter image description here






share|improve this answer






















  • Thank you very much. How to draw the other figures (2) and (5)?
    – Hany
    Sep 25 at 6:21






  • 2




    That's a great idea :)
    – TeXnician
    Sep 25 at 6:21






  • 2




    @Hany I added them. I guess this method becomes more advantageous the more complex the curve is.
    – marmot
    Sep 25 at 6:28










  • Thank you very much.
    – Hany
    Sep 25 at 6:34






  • 1




    @BlackMild Yes, it is an animated gif, created by convert -density 300 -delay 96 -loop 0 -alpha remove multipage.pdf animated.gif, see this answer.
    – marmot
    Sep 25 at 12:43














up vote
9
down vote













You can cheat:



  1. Fill a rectangle.

  2. Draw the path.

  3. Fill everything but the rectangles circles white.

Code:



documentclassbeamer
setbeamertemplatenavigation symbols
usepackagetikz
begindocument
beginframe[fragile,t]
frametitleSome dotted path
only<1>Fill a rectangle
only<2>Draw the path
only<3>Fill everything but the circles white

begintikzpicture
clip (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
fill[yellow] (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
pause
draw[line width=7pt,green!40!black] (3*8pt,1*8pt) rectangle (22*8pt,24*8pt);
pause
draw[brown,fill=white,even odd rule]
(-5pt,-5pt) rectangle (25.5*8pt+1pt,25.5*8pt+1pt)
foreach X in 0,...,25
foreach Y in 0,...,25
(X*8pt,Y*8pt) circle (3.5pt)

;
endtikzpicture
endframe

beginframe[fragile,t]
frametitleSome dotted path (cont'd)

begintikzpicture
clip (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
fill[yellow] (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
draw[line width=7pt,green!40!black,line cap=round] (3*8pt,24*8pt)
-- (22*8pt,24*8pt) -- (22*8pt,13*8pt)
-- (3*8pt,13*8pt) -- (3*8pt,1*8pt) -- (22*8pt,1*8pt);
draw[brown,fill=white,even odd rule]
(-5pt,-5pt) rectangle (25.5*8pt+1pt,25.5*8pt+1pt)
foreach X in 0,...,25
foreach Y in 0,...,25
(X*8pt,Y*8pt) circle (3.5pt)

;
endtikzpicture
endframe

beginframe[fragile,t]
frametitleSome dotted path (cont'd)

begintikzpicture[xscale=-1]
clip (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
fill[yellow] (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
draw[line width=7pt,green!40!black,line cap=round] (3*8pt,24*8pt)
-- (22*8pt,24*8pt) -- (22*8pt,13*8pt)
-- (3*8pt,13*8pt) -- (3*8pt,1*8pt) -- (22*8pt,1*8pt);
draw[brown,fill=white,even odd rule]
(-5pt,-5pt) rectangle (25.5*8pt+1pt,25.5*8pt+1pt)
foreach X in 0,...,25
foreach Y in 0,...,25
(X*8pt,Y*8pt) circle (3.5pt)

;
endtikzpicture
endframe
enddocument


Result:



enter image description here






share|improve this answer






















  • Thank you very much. How to draw the other figures (2) and (5)?
    – Hany
    Sep 25 at 6:21






  • 2




    That's a great idea :)
    – TeXnician
    Sep 25 at 6:21






  • 2




    @Hany I added them. I guess this method becomes more advantageous the more complex the curve is.
    – marmot
    Sep 25 at 6:28










  • Thank you very much.
    – Hany
    Sep 25 at 6:34






  • 1




    @BlackMild Yes, it is an animated gif, created by convert -density 300 -delay 96 -loop 0 -alpha remove multipage.pdf animated.gif, see this answer.
    – marmot
    Sep 25 at 12:43












up vote
9
down vote










up vote
9
down vote









You can cheat:



  1. Fill a rectangle.

  2. Draw the path.

  3. Fill everything but the rectangles circles white.

Code:



documentclassbeamer
setbeamertemplatenavigation symbols
usepackagetikz
begindocument
beginframe[fragile,t]
frametitleSome dotted path
only<1>Fill a rectangle
only<2>Draw the path
only<3>Fill everything but the circles white

begintikzpicture
clip (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
fill[yellow] (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
pause
draw[line width=7pt,green!40!black] (3*8pt,1*8pt) rectangle (22*8pt,24*8pt);
pause
draw[brown,fill=white,even odd rule]
(-5pt,-5pt) rectangle (25.5*8pt+1pt,25.5*8pt+1pt)
foreach X in 0,...,25
foreach Y in 0,...,25
(X*8pt,Y*8pt) circle (3.5pt)

;
endtikzpicture
endframe

beginframe[fragile,t]
frametitleSome dotted path (cont'd)

begintikzpicture
clip (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
fill[yellow] (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
draw[line width=7pt,green!40!black,line cap=round] (3*8pt,24*8pt)
-- (22*8pt,24*8pt) -- (22*8pt,13*8pt)
-- (3*8pt,13*8pt) -- (3*8pt,1*8pt) -- (22*8pt,1*8pt);
draw[brown,fill=white,even odd rule]
(-5pt,-5pt) rectangle (25.5*8pt+1pt,25.5*8pt+1pt)
foreach X in 0,...,25
foreach Y in 0,...,25
(X*8pt,Y*8pt) circle (3.5pt)

;
endtikzpicture
endframe

beginframe[fragile,t]
frametitleSome dotted path (cont'd)

begintikzpicture[xscale=-1]
clip (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
fill[yellow] (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
draw[line width=7pt,green!40!black,line cap=round] (3*8pt,24*8pt)
-- (22*8pt,24*8pt) -- (22*8pt,13*8pt)
-- (3*8pt,13*8pt) -- (3*8pt,1*8pt) -- (22*8pt,1*8pt);
draw[brown,fill=white,even odd rule]
(-5pt,-5pt) rectangle (25.5*8pt+1pt,25.5*8pt+1pt)
foreach X in 0,...,25
foreach Y in 0,...,25
(X*8pt,Y*8pt) circle (3.5pt)

;
endtikzpicture
endframe
enddocument


Result:



enter image description here






share|improve this answer














You can cheat:



  1. Fill a rectangle.

  2. Draw the path.

  3. Fill everything but the rectangles circles white.

Code:



documentclassbeamer
setbeamertemplatenavigation symbols
usepackagetikz
begindocument
beginframe[fragile,t]
frametitleSome dotted path
only<1>Fill a rectangle
only<2>Draw the path
only<3>Fill everything but the circles white

begintikzpicture
clip (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
fill[yellow] (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
pause
draw[line width=7pt,green!40!black] (3*8pt,1*8pt) rectangle (22*8pt,24*8pt);
pause
draw[brown,fill=white,even odd rule]
(-5pt,-5pt) rectangle (25.5*8pt+1pt,25.5*8pt+1pt)
foreach X in 0,...,25
foreach Y in 0,...,25
(X*8pt,Y*8pt) circle (3.5pt)

;
endtikzpicture
endframe

beginframe[fragile,t]
frametitleSome dotted path (cont'd)

begintikzpicture
clip (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
fill[yellow] (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
draw[line width=7pt,green!40!black,line cap=round] (3*8pt,24*8pt)
-- (22*8pt,24*8pt) -- (22*8pt,13*8pt)
-- (3*8pt,13*8pt) -- (3*8pt,1*8pt) -- (22*8pt,1*8pt);
draw[brown,fill=white,even odd rule]
(-5pt,-5pt) rectangle (25.5*8pt+1pt,25.5*8pt+1pt)
foreach X in 0,...,25
foreach Y in 0,...,25
(X*8pt,Y*8pt) circle (3.5pt)

;
endtikzpicture
endframe

beginframe[fragile,t]
frametitleSome dotted path (cont'd)

begintikzpicture[xscale=-1]
clip (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
fill[yellow] (-4pt,-4pt) rectangle (25.5*8pt,25.5*8pt);
draw[line width=7pt,green!40!black,line cap=round] (3*8pt,24*8pt)
-- (22*8pt,24*8pt) -- (22*8pt,13*8pt)
-- (3*8pt,13*8pt) -- (3*8pt,1*8pt) -- (22*8pt,1*8pt);
draw[brown,fill=white,even odd rule]
(-5pt,-5pt) rectangle (25.5*8pt+1pt,25.5*8pt+1pt)
foreach X in 0,...,25
foreach Y in 0,...,25
(X*8pt,Y*8pt) circle (3.5pt)

;
endtikzpicture
endframe
enddocument


Result:



enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 25 at 14:24

























answered Sep 25 at 6:15









marmot

62.7k468135




62.7k468135











  • Thank you very much. How to draw the other figures (2) and (5)?
    – Hany
    Sep 25 at 6:21






  • 2




    That's a great idea :)
    – TeXnician
    Sep 25 at 6:21






  • 2




    @Hany I added them. I guess this method becomes more advantageous the more complex the curve is.
    – marmot
    Sep 25 at 6:28










  • Thank you very much.
    – Hany
    Sep 25 at 6:34






  • 1




    @BlackMild Yes, it is an animated gif, created by convert -density 300 -delay 96 -loop 0 -alpha remove multipage.pdf animated.gif, see this answer.
    – marmot
    Sep 25 at 12:43
















  • Thank you very much. How to draw the other figures (2) and (5)?
    – Hany
    Sep 25 at 6:21






  • 2




    That's a great idea :)
    – TeXnician
    Sep 25 at 6:21






  • 2




    @Hany I added them. I guess this method becomes more advantageous the more complex the curve is.
    – marmot
    Sep 25 at 6:28










  • Thank you very much.
    – Hany
    Sep 25 at 6:34






  • 1




    @BlackMild Yes, it is an animated gif, created by convert -density 300 -delay 96 -loop 0 -alpha remove multipage.pdf animated.gif, see this answer.
    – marmot
    Sep 25 at 12:43















Thank you very much. How to draw the other figures (2) and (5)?
– Hany
Sep 25 at 6:21




Thank you very much. How to draw the other figures (2) and (5)?
– Hany
Sep 25 at 6:21




2




2




That's a great idea :)
– TeXnician
Sep 25 at 6:21




That's a great idea :)
– TeXnician
Sep 25 at 6:21




2




2




@Hany I added them. I guess this method becomes more advantageous the more complex the curve is.
– marmot
Sep 25 at 6:28




@Hany I added them. I guess this method becomes more advantageous the more complex the curve is.
– marmot
Sep 25 at 6:28












Thank you very much.
– Hany
Sep 25 at 6:34




Thank you very much.
– Hany
Sep 25 at 6:34




1




1




@BlackMild Yes, it is an animated gif, created by convert -density 300 -delay 96 -loop 0 -alpha remove multipage.pdf animated.gif, see this answer.
– marmot
Sep 25 at 12:43




@BlackMild Yes, it is an animated gif, created by convert -density 300 -delay 96 -loop 0 -alpha remove multipage.pdf animated.gif, see this answer.
– marmot
Sep 25 at 12:43

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f452369%2fsimplifying-foreach-to-repeat-a-drawing%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

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

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay