Just a path

Basil.js, form
Fabian Morón Zirfas

Some path.


#includepath "~/Documents/;%USERPROFILE%Documents";
#include "basiljs/bundle/basil.js";
// simple sketch showing the usage of some primitive forms

var w = 10; // we use this for easier calculation


var radius = 50;
function draw(){
  b.clear(b.doc()); // clear the current document
  b.units(b.MM); // we want to print. use MM intead of default pixels
  var doc = b.doc(); // a reference to the current document
  // set some preferneces of the document for better handling
  doc.documentPreferences.properties = {pageWidth:200,pageHeight:200};
  doc.viewPreferences.rulerOrigin = RulerOrigin.SPREAD_ORIGIN;
  var step = b.width/3;
  b.noFill();
  b.beginShape();
  var counter = 0;
  for(var x = 0; x <= b.width; x+=step){
    var y = null;
    if(counter%2 === 0){
      y = b.height/2 - step*2;
      b.vertex(x,y,x - step/2,y -step/2,0,b.height);
    }else{
      y = b.height/2 + step*2;
      b.vertex(x,y,x - step/2,y -step/2,b.width,0);
    }
    counter++;
  }
  b.endShape();
 // --------
 // the next lines save the file and create an PNG
  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();