<blocksapp="Snap! 4.1, http://snap.berkeley.edu"version="1"><block-definitions="Leap number of hands"type="reporter"category="other"><header></header><code></code><translations></translations><inputs></inputs><script><blocks="doReport"><blocks="evaluate"><blocks="reportJSFunction"><list></list><l>return window.controller.frame(0).hands.length;</l></block><list></list></block></block></script></block-definition><block-definitions="Leap %'pos' position of hand %'num'"type="reporter"category="other"><header></header><code></code><translations></translations><inputs><inputtype="%txt"readonly="true">x<options>x
z</options></input><inputtype="%n">1</input></inputs><script><blocks="doDeclareVariables"><list><l>a</l></list></block><blocks="doIfElse"><blocks="reportNot"><blocks="reportGreaterThan"><blockvar="num"/><custom-blocks="Leap number of hands"></custom-block></block></block><script><blocks="doReport"><blocks="evaluate"><blocks="reportJSFunction"><list><l>pos</l><l>num</l></list><l>var a = {x:0, y:1, z:2}[pos]; return window.controller.frame(0).hands[num-1].stabilizedPalmPosition[a];</l></block><list><blockvar="pos"/><blockvar="num"/></list></block></block></script><script><blocks="doReport"><l>0</l></block></script></block></script></block-definition><block-definitions="Leap %'pos' rotation of hand %'num'"type="reporter"category="other"><header></header><code></code><translations></translations><inputs><inputtype="%txt"readonly="true">yaw<options>yaw
roll</options></input><inputtype="%n">1</input></inputs><script><blocks="doIfElse"><blocks="reportNot"><blocks="reportGreaterThan"><blockvar="num"/><custom-blocks="Leap number of hands"></custom-block></block></block><script><blocks="doReport"><blocks="evaluate"><blocks="reportJSFunction"><list><l>pos</l><l>num</l></list><l>var f = window.controller.frame(0);
switch (pos){
 case "yaw":
 return f.hands[num-1].yaw();
 case "pitch":
 return f.hands[num-1].pitch();
 case "roll":
 return f.hands[num-1].roll();
};

</l></block><list><blockvar="pos"/><blockvar="num"/></list></block></block></script><script><blocks="doReport"><l>0</l></block></script></block></script></block-definition><block-definitions="Leap %'pos' position of finger %'num'"type="reporter"category="other"><header></header><code></code><translations></translations><inputs><inputtype="%txt"readonly="true">x<options>x
z</options></input><inputtype="%n">1</input></inputs><script><blocks="doIfElse"><blocks="reportNot"><blocks="reportGreaterThan"><blockvar="num"/><blocks="evaluate"><blocks="reportJSFunction"><list></list><l>return window.controller.frame(0).fingers.length;</l></block><list></list></block></block></block><script><blocks="doReport"><blocks="evaluate"><blocks="reportJSFunction"><list><l>pos</l><l>num</l></list><l>var a = {x:0, y:1, z:2}[pos]; return window.controller.frame(0).fingers[num-1].stabilizedTipPosition[a];</l></block><list><blockvar="pos"/><blockvar="num"/></list></block></block></script><script><blocks="doReport"><l>0</l></block></script></block></script></block-definition><block-definitions="Leap hand %'num' is pinching"type="predicate"category="other"><header></header><code></code><translations></translations><inputs><inputtype="%s">1</input></inputs><script><blocks="doIfElse"><blocks="reportNot"><blocks="reportGreaterThan"><blockvar="num"/><custom-blocks="Leap number of hands"></custom-block></block></block><script><blocks="doReport"><blocks="reportGreaterThan"><blocks="evaluate"><blocks="reportJSFunction"><list><l>num</l></list><l>return window.controller.frame(0).hands[num-1].pinchStrength;</l></block><list><blockvar="num"/></list></block><l>0.75</l></block></block></script><script><blocks="doReport"><blocks="reportBoolean"><l><bool>false</bool></l></block></block></script></block></script></block-definition><block-definitions="Leap pinch strength of hand %'num'"type="reporter"category="other"><header></header><code></code><translations></translations><inputs><inputtype="%n">1</input></inputs><script><blocks="doIfElse"><blocks="reportNot"><blocks="reportGreaterThan"><blockvar="num"/><custom-blocks="Leap number of hands"></custom-block></block></block><script><blocks="doReport"><blocks="reportProduct"><blocks="evaluate"><blocks="reportJSFunction"><list><l>num</l></list><l>return window.controller.frame(0).hands[num-1].pinchStrength;</l></block><list><blockvar="num"/></list></block><l>100</l></block></block></script><script><blocks="doReport"><l>0</l></block></script></block></script></block-definition><block-definitions="Leap $flag"type="command"category="other"><header></header><code></code><translations></translations><inputs></inputs><script><blocks="doIf"><blocks="evaluate"><blocks="reportJSFunction"><list></list><l>return window.controller !== undefined</l></block><list></list></block><script><blocks="doStopThis"><l><option>this block</option></l></block></script></block><blocks="doDeclareVariables"><list><l>test</l></list></block><blocks="doSetVar"><l>test</l><blocks="evaluate"><blocks="reportJSFunction"><list></list><l>var leapScript,
 done = false;
leapScript = document.createElement('script'),
leapScript.onload = function () {
 done = true;
 console.log('leap is ready');
};
document.head.appendChild(leapScript);
leapScript.src = 'https://js.leapmotion.com/leap-0.6.4.min.js';
return function () {return done; }</l></block><list></list></block></block><blocks="doWaitUntil"><blocks="evaluate"><blockvar="test"/><list></list></block></block><blocks="doRun"><blocks="reportJSFunction"><list></list><l>window.controller = new Leap.Controller({enableGestures: true, background: true}); window.controller.connect();</l></block><list></list></block></script></block-definition></blocks>