OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "services/prediction/key_set.h" |
| 6 |
| 7 namespace prediction { |
| 8 |
| 9 const Key KeySet::A(97, 43, 58, 29, 58, 4, 9); |
| 10 const Key KeySet::B(98, 188, 116, 29, 58, 4, 9); |
| 11 const Key KeySet::C(99, 130, 116, 29, 58, 4, 9); |
| 12 const Key KeySet::D(100, 101, 58, 29, 58, 4, 9); |
| 13 const Key KeySet::E(101, 87, 0, 29, 58, 4, 9); |
| 14 const Key KeySet::F(102, 130, 58, 29, 58, 4, 9); |
| 15 const Key KeySet::G(103, 159, 58, 29, 58, 4, 9); |
| 16 const Key KeySet::H(104, 188, 58, 29, 58, 4, 9); |
| 17 const Key KeySet::I(105, 232, 0, 29, 58, 4, 9); |
| 18 const Key KeySet::J(106, 217, 58, 29, 58, 4, 9); |
| 19 const Key KeySet::K(107, 246, 58, 29, 58, 4, 9); |
| 20 const Key KeySet::L(108, 275, 58, 29, 58, 4, 9); |
| 21 const Key KeySet::M(109, 246, 116, 29, 58, 4, 9); |
| 22 const Key KeySet::N(110, 217, 116, 29, 58, 4, 9); |
| 23 const Key KeySet::O(111, 261, 0, 29, 58, 4, 9); |
| 24 const Key KeySet::P(112, 290, 0, 29, 58, 4, 9); |
| 25 const Key KeySet::Q(113, 29, 0, 29, 58, 4, 9); |
| 26 const Key KeySet::R(114, 116, 0, 29, 58, 4, 9); |
| 27 const Key KeySet::S(115, 72, 58, 29, 58, 4, 9); |
| 28 const Key KeySet::T(116, 145, 0, 29, 58, 4, 9); |
| 29 const Key KeySet::U(117, 203, 0, 29, 58, 4, 9); |
| 30 const Key KeySet::V(118, 159, 116, 29, 58, 4, 9); |
| 31 const Key KeySet::W(119, 58, 0, 29, 58, 4, 9); |
| 32 const Key KeySet::X(120, 101, 116, 29, 58, 4, 9); |
| 33 const Key KeySet::Y(121, 174, 0, 29, 58, 4, 9); |
| 34 const Key KeySet::Z(122, 72, 116, 29, 58, 4, 9); |
| 35 |
| 36 const Key KeySet::key_set[] = { |
| 37 KeySet::Q, KeySet::W, KeySet::E, KeySet::R, KeySet::T, KeySet::Y, KeySet::U, |
| 38 KeySet::I, KeySet::O, KeySet::P, KeySet::A, KeySet::S, KeySet::D, KeySet::F, |
| 39 KeySet::G, KeySet::H, KeySet::J, KeySet::K, KeySet::L, KeySet::Z, KeySet::X, |
| 40 KeySet::C, KeySet::V, KeySet::B, KeySet::N, KeySet::M}; |
| 41 |
| 42 const int KeySet::key_count = 26; |
| 43 |
| 44 int KeySet::SquaredDistanceToEdge(int x, int y, Key k) { |
| 45 const int left = k.kx; |
| 46 const int right = left + k.kwidth; |
| 47 const int top = k.ky; |
| 48 const int bottom = top + k.kheight; |
| 49 const int edge_x = x < left ? left : (x > right ? right : x); |
| 50 const int edge_y = y < top ? top : (y > bottom ? bottom : y); |
| 51 const int dx = x - edge_x; |
| 52 const int dy = y - edge_y; |
| 53 return dx * dx + dy * dy; |
| 54 } |
| 55 |
| 56 } // namespace prediction |
OLD | NEW |