I was always missing the easy option to make simple gearwheels. So today i wrote a very simple implementation in Scriptographer.
Hopefully someone finds use for it as well ;)
Suggestions are welcome
http://fuqr.de/dump/gear.js
Nice, what do you think about that? :
var numTeeth = 15;
var radius = numTeeth*Math.PI/2;
var thinning = 0.2;
var depth = 5;
function onMouseDrag(event){
var pt=event.point;
var pos= pt.subtract(path.bounds.center);
path.transform(new Matrix().translate(pos));
}
I modified your script (with chris' addition) to make a gear drawing tool - the gears are rotated to make it possible for the gears to actually turn (i.e. they don't overlap).
The overlap finding is done brute force - must be possible to do it with pure geometry, but this is a very quick try out..
Let me know if it works for you - I'm using a newer prerelease version of Scriptographer..
Neat :) I actually though about implementing that myself, but at the time the purpose of the script was just to create the outlines to later reuse them in a Flash animation.
Sadly in my version of ScriptoGrapher the gears are placed all over the place, not like in your screenshot.
But, if my assumptions are correct, you could just do something like this:
globalRotation += Math.PI * 2 / numTeeth;
gear.rotate( globalRotation );
Bot most likely that doesn't take the movement vector into account. If i could try with your version of ScriptoGrapher i could definitely fix up the code.
But it runs quite smooth right now anyway :) Good work :D
Okay thats happening because the old version of scripto rotates around the 0,0 position - I've put in a small workaround in the script which moves the gears back to the right position, it should work now..
your solution for the rotation doesn't work - would need something with the movement vector indeed..