You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

49 lines
1.0 KiB

<title>JavaScript <=> PaperScript example</title>
<code mode="text/html">
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="paper.js"></script>
<script type="text/paperscript" canvas="myCanvas">
var nx = 3;
var ny = 3;
var scale = 170;
var space = 30;
var num_steps = 10;
var num_lines = 5;
for(var xx=0; xx<nx; xx++) {
for(var yy=0; yy<nx; yy++) {
var xstart = Math.random();
var ystart = Math.random();
var lines = [];
for(var i=0; i<num_lines; i++) {
var x = xstart + i*0.0001;
var y = ystart + i*0.0001;
var path = new Path({strokeWidth: 1, strokeColor: 'black'});
for(var s=0; s<num_steps; s++) {
x = (4*x*(1-x)) % 1;
y = (x+y) % 1;
var p = new Point(x*scale + xx*(scale+space), y*scale + yy*(scale+space));
path.add(p);
console.log(p);
}
lines.push(path);
}
}
}
</script>
</head>
<body>
<canvas id="myCanvas" style="width: 600px; height: 600px;" resize></canvas>
</body>
</html>