Skip to content
Will Blanton edited this page Sep 13, 2019 · 1 revision

A Vector4 abstract of Array<Float>!

Usage:

var v1 = Vec4.get(0, 1, 0, 1); // initialize with get()
var v2:Vec4 = [0, 1, 2, 3]; // you can also initialize using an array!

v1 += [0, 5, 10, 20]; // operations with arrays!
trace(v1); // x: 0 | y: 6 | z: 10 | w: 21

v1 += v2; // operations with other Vec2s!
trace(v1); // x: 0 | y: 7 | z: 12 | w: 24

v1 = v2.xxxx; // swizzling!
trace(v1); // x: 0 | y: 0 | z: 0 | w: 0

v1 += 1; // operations with ints/floats!
trace(v1); // x: 1 | y: 1 | z: 1 | w: 1

v1.scale(10); // transform with scalars!
trace(v1); // x: 10 | y: 10 | z: 10 | w: 10

v1 /= 10; // or with regular operations!
trace(v1); // x: 1 | y: 1 | z: 1 | w: 1

// Recycle when done!
v1.put();
v2.put();
Clone this wiki locally