Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 36 lines (26 sloc) 0.848 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
/*
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.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;
};

Something went wrong with that request. Please try again.