How to create the random syntax with PSTricks?
up vote
4
down vote
favorite
The TikZ code of Schulte Table (Tran Le Nam's author):
documentclass[12pt,tikz,border=3mm]{standalone}
usetikzlibrary{calc}
usepackage{xstring}
begin{document}
large
begin{tikzpicture}
defn{5}
defmylist{}
pgfmathsetmacro{numbermax}{n*n}
foreach x in {1,...,numbermax}{
xdefmylist{mylistnoexpand{xnoexpand}}
}
begin{scope}
pgfmathsetmacro{nt}{n-1}
foreach i in {0,...,nt}
{
foreach j in {0,...,nt}
{ pgfmathdeclarerandomlist{mynum}{mylist}
pgfmathrandomitem{mynum}{mynum}
StrSubstitute{mylist}{{mynum}}{}[sublist]
globalletmylistsublist
pgfmathparse{0.9*rnd+0.3} pgfmathsetmacro{maum}{pgfmathresult}
pgfmathparse{0.8*rnd} pgfmathsetmacro{mauh}{pgfmathresult}
definecolor{mau}{rgb}{maum,mauh,0.1}
node[color=mau] at ($ (i+0.5, j+0.5 ) $) {mynum};
}
}
draw (0,0) grid (n,n);
end{scope}
end{tikzpicture}
end{document}
Truly, until now, I don't know about "the random syntax" in any PSTricks documentations. Can I find "the random syntax" in where?
macros pstricks
add a comment |
up vote
4
down vote
favorite
The TikZ code of Schulte Table (Tran Le Nam's author):
documentclass[12pt,tikz,border=3mm]{standalone}
usetikzlibrary{calc}
usepackage{xstring}
begin{document}
large
begin{tikzpicture}
defn{5}
defmylist{}
pgfmathsetmacro{numbermax}{n*n}
foreach x in {1,...,numbermax}{
xdefmylist{mylistnoexpand{xnoexpand}}
}
begin{scope}
pgfmathsetmacro{nt}{n-1}
foreach i in {0,...,nt}
{
foreach j in {0,...,nt}
{ pgfmathdeclarerandomlist{mynum}{mylist}
pgfmathrandomitem{mynum}{mynum}
StrSubstitute{mylist}{{mynum}}{}[sublist]
globalletmylistsublist
pgfmathparse{0.9*rnd+0.3} pgfmathsetmacro{maum}{pgfmathresult}
pgfmathparse{0.8*rnd} pgfmathsetmacro{mauh}{pgfmathresult}
definecolor{mau}{rgb}{maum,mauh,0.1}
node[color=mau] at ($ (i+0.5, j+0.5 ) $) {mynum};
}
}
draw (0,0) grid (n,n);
end{scope}
end{tikzpicture}
end{document}
Truly, until now, I don't know about "the random syntax" in any PSTricks documentations. Can I find "the random syntax" in where?
macros pstricks
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
The TikZ code of Schulte Table (Tran Le Nam's author):
documentclass[12pt,tikz,border=3mm]{standalone}
usetikzlibrary{calc}
usepackage{xstring}
begin{document}
large
begin{tikzpicture}
defn{5}
defmylist{}
pgfmathsetmacro{numbermax}{n*n}
foreach x in {1,...,numbermax}{
xdefmylist{mylistnoexpand{xnoexpand}}
}
begin{scope}
pgfmathsetmacro{nt}{n-1}
foreach i in {0,...,nt}
{
foreach j in {0,...,nt}
{ pgfmathdeclarerandomlist{mynum}{mylist}
pgfmathrandomitem{mynum}{mynum}
StrSubstitute{mylist}{{mynum}}{}[sublist]
globalletmylistsublist
pgfmathparse{0.9*rnd+0.3} pgfmathsetmacro{maum}{pgfmathresult}
pgfmathparse{0.8*rnd} pgfmathsetmacro{mauh}{pgfmathresult}
definecolor{mau}{rgb}{maum,mauh,0.1}
node[color=mau] at ($ (i+0.5, j+0.5 ) $) {mynum};
}
}
draw (0,0) grid (n,n);
end{scope}
end{tikzpicture}
end{document}
Truly, until now, I don't know about "the random syntax" in any PSTricks documentations. Can I find "the random syntax" in where?
macros pstricks
The TikZ code of Schulte Table (Tran Le Nam's author):
documentclass[12pt,tikz,border=3mm]{standalone}
usetikzlibrary{calc}
usepackage{xstring}
begin{document}
large
begin{tikzpicture}
defn{5}
defmylist{}
pgfmathsetmacro{numbermax}{n*n}
foreach x in {1,...,numbermax}{
xdefmylist{mylistnoexpand{xnoexpand}}
}
begin{scope}
pgfmathsetmacro{nt}{n-1}
foreach i in {0,...,nt}
{
foreach j in {0,...,nt}
{ pgfmathdeclarerandomlist{mynum}{mylist}
pgfmathrandomitem{mynum}{mynum}
StrSubstitute{mylist}{{mynum}}{}[sublist]
globalletmylistsublist
pgfmathparse{0.9*rnd+0.3} pgfmathsetmacro{maum}{pgfmathresult}
pgfmathparse{0.8*rnd} pgfmathsetmacro{mauh}{pgfmathresult}
definecolor{mau}{rgb}{maum,mauh,0.1}
node[color=mau] at ($ (i+0.5, j+0.5 ) $) {mynum};
}
}
draw (0,0) grid (n,n);
end{scope}
end{tikzpicture}
end{document}
Truly, until now, I don't know about "the random syntax" in any PSTricks documentations. Can I find "the random syntax" in where?
macros pstricks
macros pstricks
edited 2 hours ago
asked 17 hours ago
chishimotoji
582212
582212
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
Does not work with xelatex
(it doesn't know the random function)
documentclass[12pt]{article}
usepackage{pstricks,pst-calculate,multido}
usepackage{auto-pst-pdf}
definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
begin{document}
defn{5}
begin{pspicture}(n,n)
psgrid[subgriddiv=0,gridlabels=0pt]
resetcolorseries[25]{test}
multido{rRow=0.5+1.0}{n}{%
multido{rCol=0.5+1.0}{n}{%
rput(rCol,rRow){textcolor{test!!+}{pscalculate{randint(1,25)}}}
}}
end{pspicture}
end{document}
And a solution with single random numbers. The random stuff will move into the
pst-math
package tomorrow. Then the code will be easier.
documentclass[12pt]{article}
usepackage{pst-calculate}
usepackage{pstricks,multido}
definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
newcounter{RandNo}setcounter{RandNo}{1}
edefNumbers{pscalculate{randint(1,25)}}
defgetNoList{%
edefNumber{pscalculate{randint(1,25)}}% Zufallszahl
addNumber{Number}Numbers!!}
defaddNumber#1#2!!{edefx{noexpandaddNumberA#1;#2}x,,relax}
defaddNumberA#1;#2,#3,#4relax{%
ifxrelax#2relax % we found new number
xdefNumbers{Numbers,#1}%
stepcounter{RandNo}%
ifnumtheRandNo>25 defnext{}% Neue Zahl?
else defnext{getNoList}fi%
else
ifnum#1=#2 % no new number
defnext{getNoList}%
else
ifxrelax#3relax
defnext{addNumberA#1;,,relax}%
else %
defnext{addNumberA#1;#3,#4relax}%
fi
fi
fi
ifnumtheRandNo<25 next fi
}
defgetRandomNo#1{%
globalcount0 = 1
edefx{noexpandgetIndex#1;Numbers,,relax}x}
defgetIndex#1;#2,#3,#4relax{%
ifnumthecount0=#1
defnext{#2}%
else
globaladvancecount0 by 1
defnext{getIndex#1;#3,#4relax}%
fi
next
}
begin{document}
defn{5}getNoList
setcounter{RandNo}{1}
begin{pspicture}(n,n)
psgrid[subgriddiv=0,gridlabels=0pt]
resetcolorseries[thenumexprn*n]{test}
multido{rRow=0.5+1.0}{n}{%
multido{rCol=0.5+1.0}{n}{%
rput(rCol,rRow){textcolor{test!!+}{getRandomNo{theRandNo}}}%
stepcounter{RandNo}%
}}
end{pspicture}
end{document}
What is the syntax random in your answer?
– chishimotoji
15 hours ago
1
pscalculate{randint(1,25)}
get an integer random between 1 and 25
– Herbert
15 hours ago
Ohh, I see. Thanks.
– chishimotoji
15 hours ago
@chishimotoji: a solution with only numbers from 1..25 after lunch ...
– Herbert
15 hours ago
@Herbert Great!
– chishimotoji
15 hours ago
|
show 5 more comments
up vote
1
down vote
A pure PSTricks solution is also possible but we should not reinvent the wheel.
documentclass[12pt,pstricks,border=1pt]{standalone}
usepackage{tikz,xstring}
usetikzlibrary{calc}
defn{5}defmylist{}
pgfmathsetmacro{numbermax}{n*n}
foreach x in {1,...,numbermax}{
xdefmylist{mylistnoexpand{xnoexpand}}
}
pgfmathsetmacro{nt}{n-1}
newpsstyle{gridstyle}{griddots=0,subgriddiv=1}
begin{document}
large
begin{pspicture}[showgrid](n,n)
foreach i in {0,...,nt}
{
foreach j in {0,...,nt}
{ pgfmathdeclarerandomlist{mynum}{mylist}
pgfmathrandomitem{mynum}{mynum}
StrSubstitute{mylist}{{mynum}}{}[sublist]
globalletmylistsublist
pgfmathparse{0.9*rnd+0.3} pgfmathsetmacro{maum}{pgfmathresult}
pgfmathparse{0.8*rnd} pgfmathsetmacro{mauh}{pgfmathresult}
definecolor{mau}{rgb}{maum,mauh,0.1}
rput(!ispace .5 add jspace .5 add){color{mau}mynum}
}
}
end{pspicture}
end{document}
About Pseudo random generator
Rand
produces a floating point random number between 0 and 1 inclusive and rand
produces a "huge" integer.
documentclass[pstricks,border=12pt,12pt]{standalone}
pstVerb{realtime srand}
begin{document}
begin{pspicture}[showgrid](6,6)
psLoop{5}{qdisk(!Rand 6 mul Rand 6 mul){!Rand 4 div}}
end{pspicture}
end{document}
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Does not work with xelatex
(it doesn't know the random function)
documentclass[12pt]{article}
usepackage{pstricks,pst-calculate,multido}
usepackage{auto-pst-pdf}
definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
begin{document}
defn{5}
begin{pspicture}(n,n)
psgrid[subgriddiv=0,gridlabels=0pt]
resetcolorseries[25]{test}
multido{rRow=0.5+1.0}{n}{%
multido{rCol=0.5+1.0}{n}{%
rput(rCol,rRow){textcolor{test!!+}{pscalculate{randint(1,25)}}}
}}
end{pspicture}
end{document}
And a solution with single random numbers. The random stuff will move into the
pst-math
package tomorrow. Then the code will be easier.
documentclass[12pt]{article}
usepackage{pst-calculate}
usepackage{pstricks,multido}
definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
newcounter{RandNo}setcounter{RandNo}{1}
edefNumbers{pscalculate{randint(1,25)}}
defgetNoList{%
edefNumber{pscalculate{randint(1,25)}}% Zufallszahl
addNumber{Number}Numbers!!}
defaddNumber#1#2!!{edefx{noexpandaddNumberA#1;#2}x,,relax}
defaddNumberA#1;#2,#3,#4relax{%
ifxrelax#2relax % we found new number
xdefNumbers{Numbers,#1}%
stepcounter{RandNo}%
ifnumtheRandNo>25 defnext{}% Neue Zahl?
else defnext{getNoList}fi%
else
ifnum#1=#2 % no new number
defnext{getNoList}%
else
ifxrelax#3relax
defnext{addNumberA#1;,,relax}%
else %
defnext{addNumberA#1;#3,#4relax}%
fi
fi
fi
ifnumtheRandNo<25 next fi
}
defgetRandomNo#1{%
globalcount0 = 1
edefx{noexpandgetIndex#1;Numbers,,relax}x}
defgetIndex#1;#2,#3,#4relax{%
ifnumthecount0=#1
defnext{#2}%
else
globaladvancecount0 by 1
defnext{getIndex#1;#3,#4relax}%
fi
next
}
begin{document}
defn{5}getNoList
setcounter{RandNo}{1}
begin{pspicture}(n,n)
psgrid[subgriddiv=0,gridlabels=0pt]
resetcolorseries[thenumexprn*n]{test}
multido{rRow=0.5+1.0}{n}{%
multido{rCol=0.5+1.0}{n}{%
rput(rCol,rRow){textcolor{test!!+}{getRandomNo{theRandNo}}}%
stepcounter{RandNo}%
}}
end{pspicture}
end{document}
What is the syntax random in your answer?
– chishimotoji
15 hours ago
1
pscalculate{randint(1,25)}
get an integer random between 1 and 25
– Herbert
15 hours ago
Ohh, I see. Thanks.
– chishimotoji
15 hours ago
@chishimotoji: a solution with only numbers from 1..25 after lunch ...
– Herbert
15 hours ago
@Herbert Great!
– chishimotoji
15 hours ago
|
show 5 more comments
up vote
2
down vote
accepted
Does not work with xelatex
(it doesn't know the random function)
documentclass[12pt]{article}
usepackage{pstricks,pst-calculate,multido}
usepackage{auto-pst-pdf}
definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
begin{document}
defn{5}
begin{pspicture}(n,n)
psgrid[subgriddiv=0,gridlabels=0pt]
resetcolorseries[25]{test}
multido{rRow=0.5+1.0}{n}{%
multido{rCol=0.5+1.0}{n}{%
rput(rCol,rRow){textcolor{test!!+}{pscalculate{randint(1,25)}}}
}}
end{pspicture}
end{document}
And a solution with single random numbers. The random stuff will move into the
pst-math
package tomorrow. Then the code will be easier.
documentclass[12pt]{article}
usepackage{pst-calculate}
usepackage{pstricks,multido}
definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
newcounter{RandNo}setcounter{RandNo}{1}
edefNumbers{pscalculate{randint(1,25)}}
defgetNoList{%
edefNumber{pscalculate{randint(1,25)}}% Zufallszahl
addNumber{Number}Numbers!!}
defaddNumber#1#2!!{edefx{noexpandaddNumberA#1;#2}x,,relax}
defaddNumberA#1;#2,#3,#4relax{%
ifxrelax#2relax % we found new number
xdefNumbers{Numbers,#1}%
stepcounter{RandNo}%
ifnumtheRandNo>25 defnext{}% Neue Zahl?
else defnext{getNoList}fi%
else
ifnum#1=#2 % no new number
defnext{getNoList}%
else
ifxrelax#3relax
defnext{addNumberA#1;,,relax}%
else %
defnext{addNumberA#1;#3,#4relax}%
fi
fi
fi
ifnumtheRandNo<25 next fi
}
defgetRandomNo#1{%
globalcount0 = 1
edefx{noexpandgetIndex#1;Numbers,,relax}x}
defgetIndex#1;#2,#3,#4relax{%
ifnumthecount0=#1
defnext{#2}%
else
globaladvancecount0 by 1
defnext{getIndex#1;#3,#4relax}%
fi
next
}
begin{document}
defn{5}getNoList
setcounter{RandNo}{1}
begin{pspicture}(n,n)
psgrid[subgriddiv=0,gridlabels=0pt]
resetcolorseries[thenumexprn*n]{test}
multido{rRow=0.5+1.0}{n}{%
multido{rCol=0.5+1.0}{n}{%
rput(rCol,rRow){textcolor{test!!+}{getRandomNo{theRandNo}}}%
stepcounter{RandNo}%
}}
end{pspicture}
end{document}
What is the syntax random in your answer?
– chishimotoji
15 hours ago
1
pscalculate{randint(1,25)}
get an integer random between 1 and 25
– Herbert
15 hours ago
Ohh, I see. Thanks.
– chishimotoji
15 hours ago
@chishimotoji: a solution with only numbers from 1..25 after lunch ...
– Herbert
15 hours ago
@Herbert Great!
– chishimotoji
15 hours ago
|
show 5 more comments
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Does not work with xelatex
(it doesn't know the random function)
documentclass[12pt]{article}
usepackage{pstricks,pst-calculate,multido}
usepackage{auto-pst-pdf}
definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
begin{document}
defn{5}
begin{pspicture}(n,n)
psgrid[subgriddiv=0,gridlabels=0pt]
resetcolorseries[25]{test}
multido{rRow=0.5+1.0}{n}{%
multido{rCol=0.5+1.0}{n}{%
rput(rCol,rRow){textcolor{test!!+}{pscalculate{randint(1,25)}}}
}}
end{pspicture}
end{document}
And a solution with single random numbers. The random stuff will move into the
pst-math
package tomorrow. Then the code will be easier.
documentclass[12pt]{article}
usepackage{pst-calculate}
usepackage{pstricks,multido}
definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
newcounter{RandNo}setcounter{RandNo}{1}
edefNumbers{pscalculate{randint(1,25)}}
defgetNoList{%
edefNumber{pscalculate{randint(1,25)}}% Zufallszahl
addNumber{Number}Numbers!!}
defaddNumber#1#2!!{edefx{noexpandaddNumberA#1;#2}x,,relax}
defaddNumberA#1;#2,#3,#4relax{%
ifxrelax#2relax % we found new number
xdefNumbers{Numbers,#1}%
stepcounter{RandNo}%
ifnumtheRandNo>25 defnext{}% Neue Zahl?
else defnext{getNoList}fi%
else
ifnum#1=#2 % no new number
defnext{getNoList}%
else
ifxrelax#3relax
defnext{addNumberA#1;,,relax}%
else %
defnext{addNumberA#1;#3,#4relax}%
fi
fi
fi
ifnumtheRandNo<25 next fi
}
defgetRandomNo#1{%
globalcount0 = 1
edefx{noexpandgetIndex#1;Numbers,,relax}x}
defgetIndex#1;#2,#3,#4relax{%
ifnumthecount0=#1
defnext{#2}%
else
globaladvancecount0 by 1
defnext{getIndex#1;#3,#4relax}%
fi
next
}
begin{document}
defn{5}getNoList
setcounter{RandNo}{1}
begin{pspicture}(n,n)
psgrid[subgriddiv=0,gridlabels=0pt]
resetcolorseries[thenumexprn*n]{test}
multido{rRow=0.5+1.0}{n}{%
multido{rCol=0.5+1.0}{n}{%
rput(rCol,rRow){textcolor{test!!+}{getRandomNo{theRandNo}}}%
stepcounter{RandNo}%
}}
end{pspicture}
end{document}
Does not work with xelatex
(it doesn't know the random function)
documentclass[12pt]{article}
usepackage{pstricks,pst-calculate,multido}
usepackage{auto-pst-pdf}
definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
begin{document}
defn{5}
begin{pspicture}(n,n)
psgrid[subgriddiv=0,gridlabels=0pt]
resetcolorseries[25]{test}
multido{rRow=0.5+1.0}{n}{%
multido{rCol=0.5+1.0}{n}{%
rput(rCol,rRow){textcolor{test!!+}{pscalculate{randint(1,25)}}}
}}
end{pspicture}
end{document}
And a solution with single random numbers. The random stuff will move into the
pst-math
package tomorrow. Then the code will be easier.
documentclass[12pt]{article}
usepackage{pst-calculate}
usepackage{pstricks,multido}
definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
newcounter{RandNo}setcounter{RandNo}{1}
edefNumbers{pscalculate{randint(1,25)}}
defgetNoList{%
edefNumber{pscalculate{randint(1,25)}}% Zufallszahl
addNumber{Number}Numbers!!}
defaddNumber#1#2!!{edefx{noexpandaddNumberA#1;#2}x,,relax}
defaddNumberA#1;#2,#3,#4relax{%
ifxrelax#2relax % we found new number
xdefNumbers{Numbers,#1}%
stepcounter{RandNo}%
ifnumtheRandNo>25 defnext{}% Neue Zahl?
else defnext{getNoList}fi%
else
ifnum#1=#2 % no new number
defnext{getNoList}%
else
ifxrelax#3relax
defnext{addNumberA#1;,,relax}%
else %
defnext{addNumberA#1;#3,#4relax}%
fi
fi
fi
ifnumtheRandNo<25 next fi
}
defgetRandomNo#1{%
globalcount0 = 1
edefx{noexpandgetIndex#1;Numbers,,relax}x}
defgetIndex#1;#2,#3,#4relax{%
ifnumthecount0=#1
defnext{#2}%
else
globaladvancecount0 by 1
defnext{getIndex#1;#3,#4relax}%
fi
next
}
begin{document}
defn{5}getNoList
setcounter{RandNo}{1}
begin{pspicture}(n,n)
psgrid[subgriddiv=0,gridlabels=0pt]
resetcolorseries[thenumexprn*n]{test}
multido{rRow=0.5+1.0}{n}{%
multido{rCol=0.5+1.0}{n}{%
rput(rCol,rRow){textcolor{test!!+}{getRandomNo{theRandNo}}}%
stepcounter{RandNo}%
}}
end{pspicture}
end{document}
edited 4 hours ago
answered 15 hours ago
Herbert
267k23406716
267k23406716
What is the syntax random in your answer?
– chishimotoji
15 hours ago
1
pscalculate{randint(1,25)}
get an integer random between 1 and 25
– Herbert
15 hours ago
Ohh, I see. Thanks.
– chishimotoji
15 hours ago
@chishimotoji: a solution with only numbers from 1..25 after lunch ...
– Herbert
15 hours ago
@Herbert Great!
– chishimotoji
15 hours ago
|
show 5 more comments
What is the syntax random in your answer?
– chishimotoji
15 hours ago
1
pscalculate{randint(1,25)}
get an integer random between 1 and 25
– Herbert
15 hours ago
Ohh, I see. Thanks.
– chishimotoji
15 hours ago
@chishimotoji: a solution with only numbers from 1..25 after lunch ...
– Herbert
15 hours ago
@Herbert Great!
– chishimotoji
15 hours ago
What is the syntax random in your answer?
– chishimotoji
15 hours ago
What is the syntax random in your answer?
– chishimotoji
15 hours ago
1
1
pscalculate{randint(1,25)}
get an integer random between 1 and 25– Herbert
15 hours ago
pscalculate{randint(1,25)}
get an integer random between 1 and 25– Herbert
15 hours ago
Ohh, I see. Thanks.
– chishimotoji
15 hours ago
Ohh, I see. Thanks.
– chishimotoji
15 hours ago
@chishimotoji: a solution with only numbers from 1..25 after lunch ...
– Herbert
15 hours ago
@chishimotoji: a solution with only numbers from 1..25 after lunch ...
– Herbert
15 hours ago
@Herbert Great!
– chishimotoji
15 hours ago
@Herbert Great!
– chishimotoji
15 hours ago
|
show 5 more comments
up vote
1
down vote
A pure PSTricks solution is also possible but we should not reinvent the wheel.
documentclass[12pt,pstricks,border=1pt]{standalone}
usepackage{tikz,xstring}
usetikzlibrary{calc}
defn{5}defmylist{}
pgfmathsetmacro{numbermax}{n*n}
foreach x in {1,...,numbermax}{
xdefmylist{mylistnoexpand{xnoexpand}}
}
pgfmathsetmacro{nt}{n-1}
newpsstyle{gridstyle}{griddots=0,subgriddiv=1}
begin{document}
large
begin{pspicture}[showgrid](n,n)
foreach i in {0,...,nt}
{
foreach j in {0,...,nt}
{ pgfmathdeclarerandomlist{mynum}{mylist}
pgfmathrandomitem{mynum}{mynum}
StrSubstitute{mylist}{{mynum}}{}[sublist]
globalletmylistsublist
pgfmathparse{0.9*rnd+0.3} pgfmathsetmacro{maum}{pgfmathresult}
pgfmathparse{0.8*rnd} pgfmathsetmacro{mauh}{pgfmathresult}
definecolor{mau}{rgb}{maum,mauh,0.1}
rput(!ispace .5 add jspace .5 add){color{mau}mynum}
}
}
end{pspicture}
end{document}
About Pseudo random generator
Rand
produces a floating point random number between 0 and 1 inclusive and rand
produces a "huge" integer.
documentclass[pstricks,border=12pt,12pt]{standalone}
pstVerb{realtime srand}
begin{document}
begin{pspicture}[showgrid](6,6)
psLoop{5}{qdisk(!Rand 6 mul Rand 6 mul){!Rand 4 div}}
end{pspicture}
end{document}
add a comment |
up vote
1
down vote
A pure PSTricks solution is also possible but we should not reinvent the wheel.
documentclass[12pt,pstricks,border=1pt]{standalone}
usepackage{tikz,xstring}
usetikzlibrary{calc}
defn{5}defmylist{}
pgfmathsetmacro{numbermax}{n*n}
foreach x in {1,...,numbermax}{
xdefmylist{mylistnoexpand{xnoexpand}}
}
pgfmathsetmacro{nt}{n-1}
newpsstyle{gridstyle}{griddots=0,subgriddiv=1}
begin{document}
large
begin{pspicture}[showgrid](n,n)
foreach i in {0,...,nt}
{
foreach j in {0,...,nt}
{ pgfmathdeclarerandomlist{mynum}{mylist}
pgfmathrandomitem{mynum}{mynum}
StrSubstitute{mylist}{{mynum}}{}[sublist]
globalletmylistsublist
pgfmathparse{0.9*rnd+0.3} pgfmathsetmacro{maum}{pgfmathresult}
pgfmathparse{0.8*rnd} pgfmathsetmacro{mauh}{pgfmathresult}
definecolor{mau}{rgb}{maum,mauh,0.1}
rput(!ispace .5 add jspace .5 add){color{mau}mynum}
}
}
end{pspicture}
end{document}
About Pseudo random generator
Rand
produces a floating point random number between 0 and 1 inclusive and rand
produces a "huge" integer.
documentclass[pstricks,border=12pt,12pt]{standalone}
pstVerb{realtime srand}
begin{document}
begin{pspicture}[showgrid](6,6)
psLoop{5}{qdisk(!Rand 6 mul Rand 6 mul){!Rand 4 div}}
end{pspicture}
end{document}
add a comment |
up vote
1
down vote
up vote
1
down vote
A pure PSTricks solution is also possible but we should not reinvent the wheel.
documentclass[12pt,pstricks,border=1pt]{standalone}
usepackage{tikz,xstring}
usetikzlibrary{calc}
defn{5}defmylist{}
pgfmathsetmacro{numbermax}{n*n}
foreach x in {1,...,numbermax}{
xdefmylist{mylistnoexpand{xnoexpand}}
}
pgfmathsetmacro{nt}{n-1}
newpsstyle{gridstyle}{griddots=0,subgriddiv=1}
begin{document}
large
begin{pspicture}[showgrid](n,n)
foreach i in {0,...,nt}
{
foreach j in {0,...,nt}
{ pgfmathdeclarerandomlist{mynum}{mylist}
pgfmathrandomitem{mynum}{mynum}
StrSubstitute{mylist}{{mynum}}{}[sublist]
globalletmylistsublist
pgfmathparse{0.9*rnd+0.3} pgfmathsetmacro{maum}{pgfmathresult}
pgfmathparse{0.8*rnd} pgfmathsetmacro{mauh}{pgfmathresult}
definecolor{mau}{rgb}{maum,mauh,0.1}
rput(!ispace .5 add jspace .5 add){color{mau}mynum}
}
}
end{pspicture}
end{document}
About Pseudo random generator
Rand
produces a floating point random number between 0 and 1 inclusive and rand
produces a "huge" integer.
documentclass[pstricks,border=12pt,12pt]{standalone}
pstVerb{realtime srand}
begin{document}
begin{pspicture}[showgrid](6,6)
psLoop{5}{qdisk(!Rand 6 mul Rand 6 mul){!Rand 4 div}}
end{pspicture}
end{document}
A pure PSTricks solution is also possible but we should not reinvent the wheel.
documentclass[12pt,pstricks,border=1pt]{standalone}
usepackage{tikz,xstring}
usetikzlibrary{calc}
defn{5}defmylist{}
pgfmathsetmacro{numbermax}{n*n}
foreach x in {1,...,numbermax}{
xdefmylist{mylistnoexpand{xnoexpand}}
}
pgfmathsetmacro{nt}{n-1}
newpsstyle{gridstyle}{griddots=0,subgriddiv=1}
begin{document}
large
begin{pspicture}[showgrid](n,n)
foreach i in {0,...,nt}
{
foreach j in {0,...,nt}
{ pgfmathdeclarerandomlist{mynum}{mylist}
pgfmathrandomitem{mynum}{mynum}
StrSubstitute{mylist}{{mynum}}{}[sublist]
globalletmylistsublist
pgfmathparse{0.9*rnd+0.3} pgfmathsetmacro{maum}{pgfmathresult}
pgfmathparse{0.8*rnd} pgfmathsetmacro{mauh}{pgfmathresult}
definecolor{mau}{rgb}{maum,mauh,0.1}
rput(!ispace .5 add jspace .5 add){color{mau}mynum}
}
}
end{pspicture}
end{document}
About Pseudo random generator
Rand
produces a floating point random number between 0 and 1 inclusive and rand
produces a "huge" integer.
documentclass[pstricks,border=12pt,12pt]{standalone}
pstVerb{realtime srand}
begin{document}
begin{pspicture}[showgrid](6,6)
psLoop{5}{qdisk(!Rand 6 mul Rand 6 mul){!Rand 4 div}}
end{pspicture}
end{document}
edited 16 hours ago
answered 16 hours ago
Artificial Stupidity
4,90111039
4,90111039
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f464486%2fhow-to-create-the-random-syntax-with-pstricks%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