Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Quick example on using Code Sketcher.

  • Loading branch information...
commit 564e5e66adc677be4721838f0a8c6c7d8ca9fa37 1 parent 2cd7ff9
@ccgus authored
Showing with 35 additions and 0 deletions.
  1. +35 −0 example_scripts/Code Sketcher Draw.jstalk
View
35 example_scripts/Code Sketcher Draw.jstalk
@@ -0,0 +1,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;
+};
+
Please sign in to comment.
Something went wrong with that request. Please try again.