Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 36 lines (26 sloc) 0.848 kb
564e5e6 @ccgus Quick example on using Code Sketcher.
authored
1 /*
2 This a sample on how to use the JSTCodeSketcher class, which add experimental processing.org like functionality to JSTalk.
3 */
4
5 var sketcher = [JSTCodeSketcher codeSketcherWithName:"Draw"];
6
7 sketcher.setup = function() {
8 [sketcher setSize:NSMakeSize(600, 300)];
9 [sketcher clear];
10 };
11
12 sketcher.mouseDown = function() {
13 // reset our points
14 m1 = m2 = m3 = m4 = null;
15 };
16
17 sketcher.mouseDrag = function() {
18
19 var m0 = [sketcher mouseLocation];
20
21 if (m4) {
22 [[NSColor colorWithCalibratedWhite:0 alpha:.1] set];
23
24 [NSBezierPath strokeLineFromPoint:m0 toPoint:m4]
25 [NSBezierPath strokeLineFromPoint:m1 toPoint:m4]
26 [NSBezierPath strokeLineFromPoint:m2 toPoint:m4]
27 [NSBezierPath strokeLineFromPoint:m3 toPoint:m4]
28 }
29
30 m4 = m3;
31 m3 = m2;
32 m2 = m1;
33 m1 = m0;
34 };
35
Something went wrong with that request. Please try again.