Lumitronix_Iflex_Pro_Workshop
Library to interact with the iFlexPro
ColumnMajorLayout.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2 ColumnMajorLayout provides a collection of class objects that are used with NeoTopology
3 object.
4 They define the specific layout of pixels and do the math to change the 2d
5 cordinate space to 1d cordinate space
6 
7 Written by Michael C. Miller.
8 
9 I invest time and resources providing this open source code,
10 please support me by dontating (see https://github.com/Makuna)
11 
12 -------------------------------------------------------------------------
13 This file is part of the LUMITRONIX_iFlex_Workshop library.
14 
15 LumitronixIFlexBus is free software: you can redistribute it and/or modify
16 it under the terms of the GNU Lesser General Public License as
17 published by the Free Software Foundation, either version 3 of
18 the License, or (at your option) any later version.
19 
20 LumitronixIFlexBus is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU Lesser General Public License for more details.
24 
25 You should have received a copy of the GNU Lesser General Public
26 License along with LumitronixIFlex. If not, see
27 <http://www.gnu.org/licenses/>.
28 -------------------------------------------------------------------------*/
29 #pragma once
30 
31 
32 class ColumnMajorLayout;
36 
38 {
39 public:
44 };
45 
46 // layout example of 4x4
47 // 00 04 08 12
48 // 01 05 09 13
49 // 02 06 10 14
50 // 03 07 11 15
51 //
53 {
54 public:
55  static uint16_t Map(uint16_t /* width */, uint16_t height, uint16_t x, uint16_t y)
56  {
57  return x * height + y;
58  }
59 };
60 
61 // layout example of 4x4
62 // 03 02 01 00
63 // 07 06 05 04
64 // 11 10 09 08
65 // 15 14 13 12
66 //
68 {
69 public:
70  static uint16_t Map(uint16_t width, uint16_t /* height */, uint16_t x, uint16_t y)
71  {
72  return (width - 1 - x) + y * width;
73  }
74 };
75 
76 // layout example of 4x4
77 // 15 11 07 03
78 // 14 10 06 02
79 // 13 09 05 01
80 // 12 08 04 00
81 //
83 {
84 public:
85  static uint16_t Map(uint16_t width, uint16_t height, uint16_t x, uint16_t y)
86  {
87  return (width - 1 - x) * height + (height - 1 - y);
88  }
89 };
90 
91 // layout example of 4x4
92 // 12 13 14 15
93 // 08 09 10 11
94 // 04 05 06 07
95 // 00 01 02 03
96 //
98 {
99 public:
100  static uint16_t Map(uint16_t width, uint16_t height, uint16_t x, uint16_t y)
101  {
102  return x + (height - 1 - y) * width;
103  }
104 };
Definition: ColumnMajorLayout.h:83
static uint16_t Map(uint16_t width, uint16_t height, uint16_t x, uint16_t y)
Definition: ColumnMajorLayout.h:85
Definition: ColumnMajorLayout.h:98
static uint16_t Map(uint16_t width, uint16_t height, uint16_t x, uint16_t y)
Definition: ColumnMajorLayout.h:100
Definition: ColumnMajorLayout.h:68
static uint16_t Map(uint16_t width, uint16_t, uint16_t x, uint16_t y)
Definition: ColumnMajorLayout.h:70
Definition: ColumnMajorLayout.h:53
static uint16_t Map(uint16_t, uint16_t height, uint16_t x, uint16_t y)
Definition: ColumnMajorLayout.h:55
Definition: ColumnMajorLayout.h:38
ColumnMajor180Layout OddRowOddColumnLayout
Definition: ColumnMajorLayout.h:43
ColumnMajor270Layout EvenRowOddColumnLayout
Definition: ColumnMajorLayout.h:41
ColumnMajorLayout EvenRowEvenColumnLayout
Definition: ColumnMajorLayout.h:40
ColumnMajor90Layout OddRowEvenColumnLayout
Definition: ColumnMajorLayout.h:42