1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
/** Rearrange the rows of a matrix by the given row identifiers
# Arguments
* `mat`: the matrix to manipulate
* `i...`: variadic comma-seperated list of row selectors. The row selectors are each one of:
* const expression representing the row index of the input to copy. eg: `0` or `2`
* a letter representing the same. you can use `r,g,b,a` or `x,y,z,w` to represent index 0 through 3,
or `u,v` to represent indices 0 through 1.
* an expression in curly braces, representing a value to be copied to an entire row of
the result, eg: `{1.0}` or `{5}`
note that the number of selectors doesnt need to match the height of the input!
# Examples
```
# use vector_victor::{swizzle, Vector};
let myvec = Vector::vec([0, 1, 2, 3]);
// each element can be selected with:
// 0: r, x, u, or 0
// 1: g, y, v, or 1
// 2: b, z, or 2
// 3: a, w, or 3
// or a result row can be filled by a new value
assert_eq!(swizzle!(myvec, a, z, v, 0, {7}), Vector::vec([3, 2, 1, 0, 7]));
```
More often you wont mix and match selector "flavors".
This example unpacks a [DXT5nm](http://wiki.polycount.com/wiki/Normal_Map_Compression) color
into the red and green channels, with blue filled with 0.
```
# use vector_victor::{swizzle, Vector};
let myvec = Vector::vec([0, 120, 0, 255]);
assert_eq!(swizzle!(myvec, a, g, {0}), Vector::vec([255, 120, 0]));
``` */