0
Contributor
,
/t5/animate-discussions/random-mountains-script-how-to-implement-in-animate/td-p/12888706
Apr 19, 2022
Apr 19, 2022
Copy link to clipboard
Copied
var arr=[],N=10,H=100,S=25,B=0.1,pts=[];
for(i=0;i<N;i++)arr.push(Math.random()*H);
for(var i=-S;i<=H+S;i++)pts.push([i,f(i)]);
pts.push([H+S,-S],[-S,-S])
app.activeDocument.pathItems.add().setEntirePath(pts)
function f(x){
var d,y=0;
for(var i=0;i<N;i++)if((d=S-Math.abs(arr[i]-x))>0)y+=d*B;
return y;
} // #dtp
TOPICS
ActionScript
,
Code
,
Exchange extensions
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 Correct answer
Community Expert
,
Apr 19, 2022
Apr 19, 2022
Hi.
A suggestion:
var dom = fl.getDocumentDOM();
var arr = [];
var N = 10;
var H = 100;
var S = 25;
var B = 0.1;
var pts = [];
var i, myPath;
function f(x)
{
var y = 0;
var d, i;
for (i = 0; i < N; i++)
if ((d = S - Math.abs(arr[i] - x)) > 0) y += d * B;
return y;
}
for (i = 0; i < N; i++)
arr.push(Math.random() * H);
for (i = -S; i <= H + S; i++)
pts.push([i, f(i)]);
path = fl.drawingLayer.newPath();
for (i = 0; i < pts.length; i++)
path.addPoint(-pts[i][0], -pts[i][1]
...
kqskcm
AUTHOR
Contributor
,
/t5/animate-discussions/random-mountains-script-how-to-implement-in-animate/m-p/12888711#M353419
Apr 19, 2022
Apr 19, 2022
Copy link to clipboard
Copied
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
/t5/animate-discussions/random-mountains-script-how-to-implement-in-animate/m-p/12889366#M353425
Apr 19, 2022
Apr 19, 2022
Copy link to clipboard
Copied
Hi.
A suggestion:
var dom = fl.getDocumentDOM();
var arr = [];
var N = 10;
var H = 100;
var S = 25;
var B = 0.1;
var pts = [];
var i, myPath;
function f(x)
{
var y = 0;
var d, i;
for (i = 0; i < N; i++)
if ((d = S - Math.abs(arr[i] - x)) > 0) y += d * B;
return y;
}
for (i = 0; i < N; i++)
arr.push(Math.random() * H);
for (i = -S; i <= H + S; i++)
pts.push([i, f(i)]);
path = fl.drawingLayer.newPath();
for (i = 0; i < pts.length; i++)
path.addPoint(-pts[i][0], -pts[i][1]);
path.addPoint(-pts[0][0], -pts[0][1]);
path.makeShape();
Just remember to put the code in a .jsfl file.
I hope it helps.
Regards,
JC
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
kqskcm
AUTHOR
Contributor
,
/t5/animate-discussions/random-mountains-script-how-to-implement-in-animate/m-p/12889628#M353431
Apr 19, 2022
Apr 19, 2022
Copy link to clipboard
Copied
Thankyou, works perfectly.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
LATEST
/t5/animate-discussions/random-mountains-script-how-to-implement-in-animate/m-p/12889836#M353435
Apr 19, 2022
Apr 19, 2022
Copy link to clipboard
Copied
You're welcome.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

