Vector.opBinary

Returns a new vector with binary operator applied to all elements and scalar

Examples

Vec2 a = [1, 2];
assert(a + 1 == [1f + 1f, 2f + 1f]);
assert(a - 1 == [1f - 1f, 2f - 1f]);
assert(a * 2 == [1f * 2f, 2f * 2f]);
assert(a / 2 == [1f / 2f, 2f / 2f]);
assert(a % 2 == [1f % 2f, 2f % 2f]);
assert(a ^^ 2 == [1f ^^ 2f, 2f ^^ 2f]);

Vec2i b = [1, 2];
assert((b & 1) == [1 & 1, 2 & 1]);
assert((b | 1) == [1 | 1, 2 | 1]);
assert((b ^ 1) == [1 ^ 1, 2 ^ 1]);

Meta