Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
42 lines (30 sloc) 985 Bytes
/*
This a sample on how to use the JSTCodeSketcher class, which add experimental processing.org like functionality to JSTalk.
*/
var sketcher = [JSTCodeSketcher codeSketcherWithName:"Draw"];
sketcher.setup = function() {
[sketcher setSize:NSMakeSize(600, 300)];
[sketcher clear];
};
sketcher.draw = function() {
[sketcher fillWithColor:[NSColor colorWithCalibratedWhite:1 alpha:.05]];
}
sketcher.mouseDown = function() {
// reset our points
m1 = m2 = m3 = m4 = null;
};
sketcher.mouseDrag = function() {
var m0 = [sketcher mouseLocation];
if (m4) {
[[NSColor colorWithCalibratedWhite:0 alpha:.1] set];
[NSBezierPath strokeLineFromPoint:m0 toPoint:m4]
[NSBezierPath strokeLineFromPoint:m1 toPoint:m4]
[NSBezierPath strokeLineFromPoint:m2 toPoint:m4]
[NSBezierPath strokeLineFromPoint:m3 toPoint:m4]
}
m4 = m3;
m3 = m2;
m2 = m1;
m1 = m0;
};
[sketcher setFrameRate:30]
Something went wrong with that request. Please try again.