Multitouch interactions function

Post Reply
User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Multitouch interactions function

Post by Mr. Kibernetik »

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.

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()
.
wp_ss_20170620_0003.png
wp_ss_20170620_0003.png (25.84 KiB) Viewed 2539 times
wp_ss_20170620_0004.png
wp_ss_20170620_0004.png (49.4 KiB) Viewed 2539 times

Post Reply