//@includepath "~/Documents/;%USERPROFILE%Documents";
//@include "basiljs/bundle/basil.js";
function draw(){
// code goes here -----------
var num = 100;
var minDist = 30;
var maxDist = 100;
var gutter = 5;
var doc = b.doc();
b.clear(doc);
b.units(b.MM);
doc.documentPreferences.properties = {
pageWidth:200,
pageHeight:200
};
var points = [[b.random(gutter, b.width -gutter ),b.random(gutter, b.height -gutter)]];
for(var n = 0; n < num; n++){
var newPoint = [b.random(gutter, b.width -gutter ), b.random(gutter, b.height -gutter)];
for(var i = 0; i < points.length;i++){
while(b.dist(points[i][0],points[i][1], newPoint[0], newPoint[1]) < minDist){
b.println(b.dist(points[i][0],points[i][1], newPoint[0], newPoint[1]));
newPoint = [b.random(gutter, b.width -gutter ), b.random(gutter, b.height -gutter)];
}
}
points.push(newPoint);
}
b.println('------\n' +points);
for(var j = 0; j < points.length;j++){
var px = points[j][0];
var py = points[j][1];
var ell = b.ellipse(px,py, gutter,gutter);
b.line(px, py,
(j === points.length - 1 ? points[0][0] : points[j + 1][0]),
(j === points.length - 1 ? points[0][1] : points[j + 1][1])
);
}
var fname = File($.fileName).parent.fsName + '/' + ($.fileName.split('/')[$.fileName.split('/').length - 1]).split('.')[0] + '.indd';
b.println(fname);
doc.save(fname, false, 'basil', true);
b.savePNG('out.png');
}
b.go();