「ピンチ」の版間の差分

提供: MonoBook
ナビゲーションに移動 検索に移動
imported>Administrator
(ページの作成:「'''ピンチ'''(英語pinch)とは、日本語に訳すと「挟む」という意味であり、コンピューターの世界では主にマルチ...」)
 
imported>Administrator
(ページの作成:「'''ピンチ'''(英語pinch)とは、日本語に訳すと「挟む」という意味であり、コンピューターの世界では主にマルチ...」)
 
(相違点なし)

2018年8月3日 (金) 02:24時点における最新版

ピンチ英語pinch)とは、日本語に訳すと「挟む」という意味であり、コンピューターの世界では主にマルチタッチにおいて2本の指を開いたり閉じたりする動作を指す。

ピンチに対応する処理はほとんどのアプリで「拡大縮小」となっている。指でクパー感は直感的でわかりやすい。

非常に稀な例だが、お絵かきソフトで「直線を引く」になっていたものもあったが、これはあまり使い勝手の良いものではなかった。

実装例[編集 | ソースを編集]

MonoGameでの実装例を示す。

 0 bool _pinching = false;
 1 float _pinchInitialDistance;
 2 
 3 private void HandleTouchInput() 
 4 {
 5     if (TouchPanel.IsGestureAvailable)
 6     {
 7         GestureSample gesture = TouchPanel.GetGesture();
 8 
 9         if (gesture.GestureType == GestureType.Pinch)
10         {
11             // current positions
12             Vector2 a = gesture.Position;
13             Vector2 b = gesture.Position2;
14             float dist = Vector2.Distance(a, b);
15 
16             // prior positions
17             Vector2 aOld = gesture.Position - gesture.Delta;
18             Vector2 bOld = gesture.Position2 - gesture.Delta2;
19             float distOld = Vector2.Distance(aOld, bOld);
20 
21             if (!_pinching)
22             {
23                 // start of pinch, record original distance
24                 _pinching = true;
25                 _pinchInitialDistance = distOld;
26             }
27 
28             // work out zoom amount based on pinch distance...
29             float scale = (distOld - dist) * 0.05f;
30             ZoomBy(scale);
31         }
32         else if (gesture.GestureType == GestureType.PinchComplete)
33         {
34             // end of pinch
35             _pinching = false;
36         }
37     }
38 }