Multitouch interactions function
Posted: Tue Jun 20, 2017 3:58 pm
There is #.pan function in SPL, which detects multitouch user unteraction with the screen - simultaneous moving, scaling and rotation.
As an example of how #.pan function works, this program allows user to interactively move, scale and rotate a cross on the screen using common multitouch gestures.
As an example of how #.pan function works, this program allows user to interactively move, scale and rotate a cross on the screen using common multitouch gestures.
Code: Select all
xc,yc = #.scrsize()
xc /= 2; yc /= 2
sc = 1; ac = 0
moved = 0
#.scroff()
drawlines(xc,yc,sc,ac)
>
? #.pan()
moved = 1
dx,dy,ds,da = #.pan(4)
drawlines(xc+dx,yc+dy,sc*ds,ac+da)
!
? moved
moved = 0
xc += dx; yc += dy; sc *= ds; ac += da
.
.
<
drawlines(xc,yc,sc,ac)=
s = 50*sc
ss = s*#.sin(ac)
cs = s*#.cos(ac)
#.scrclear()
#.drawsize(4)
#.drawline(xc+ss,yc-cs,xc-ss,yc+cs)
#.drawline(xc-cs,yc-ss,xc+cs,yc+ss)
#.scr()
.