First a few words about iPath & stretchsketch..
stretchsketch is a website (developed and maintained by me) where you can view, modify and edit graphics which are scripted with (or rather in) iPath. In contrast with iPath, stretchsketch' source is not on github because, it is not something I'm very proud of and it I think it is not interesting to anyone. In case you're interested you're of course free to inspect its source etc.
Once an image has been selected, you can
Now.. let us formalize a path for a square in iPath:
var square = new iPath().line(20,0).line(0,20)
.line(-20,0).line(0,-20);
to create the same square with a more configurable dimension:var length = 20;
var square = new iPath().line(length,0).line(0,length)
.line(-length,0).line(0,-length);
If you want to move the pen (or nozzle) without leaving a trace use move:
var window = new iPath().line(length,0).line(0,length)
.line(-length,0).line(0,-length).move(2*length,0);
And if you want to create an "array of x windows"
var x = 3;
window.repeat(x);
and convert to a path's d-attribute window.dPath(3);
The coordinate system above is just in x,y also known as Cartesian system. An alternative to the Cartesian system is the polar coordinate system. iPath supports this also and one should not use line but turtleLine:
var turtleWindow = new iPath().turtleLine({r: lenght, a: Math.PI/2})
Turtle line comes from Logo, and it presents the idea of guiding a turtle on the screen, with supplying an direction and length. The argument to turtleLine is a Javascript object with an r and a attribute. The r stands for radius and is equal to the length, a is the angle (in radians). Again the repitition can be applied:turtleWindow.repeat(4);Which will show our square again. Using this technique we can create a gear-wheel quite "simple" (or relative little code):
gear.r = 70;
gear.n = 15;
gear.h = 2.7;
gear.ribbon = gear.r * Math.sin(Math.PI/gear.n) * 2 ;
gear.toothAngle = Math.atan(2* gear.h, gear.ribbon);
gear.toothSide = gear.ribbon / (2*Math.cos(gear.toothAngle));
gear.iPath = new iPath().turtleLine({a: (2*Math.PI / gear.n) - gear.toothAngle, r: gear.toothSide})
.turtleLine({a: 2*gear.toothAngle, r: gear.toothSide}).turtleLine({a:-gear.toothAngle})
.repeat(gear.n);
Will produce an image like:
Thank you for your question, and it is a very relevant one indeed. Openjscad is a terrific project, and if I would have known about it’s existence before I started with iPat's predecessor I probably would have considered using and possibly contributing to it.
Having said that, iPath is now a relatively independent small javascript library focussing on scripting pen movements. It can be included in your own website without any trouble. I also think that iPath is in its domain (2D graphics) faster and easier than openjscad.
Above thatiPath has more possibilities for cnc-specific functionality like overcut, fillet, reflection. bezier and bezier to poly conversion. I’m not sure that openjscad can export to dxf, my - or rather my CNC shop’s- preferred format. Not sure how well the openjscad format’s like STL or X3D are accepted in 2D oriented CNC shops. iPath has also more cnc materialised example objects, like stools, cupboards tables etc.
I’m still planning an export builder to generate openjscad paths from iPath, so I can make 3D models with extrusion etc, but this is still on my backlog.
Hope this answers your question.