Skip to main content

vec4

This class represents a four dimensional vector (x, y, z, and w). It is often used to represent colors (red, green, blue, and alpha).

When using it to represent a color, each value should between 0 and 1. For example, this is how you would represent a fully opaque red color:

local red = vec4(1, 0, 0, 1)

And this is how you would represent a half-transparent purplish color:

local purplish = vec4(0.52, 0.07, 0.93, 0.5)

Color channels (between 0 and 1):

  • x -> red
  • y -> green
  • z -> blue
  • w -> alpha

Constructor: vec4(x, y, z, w)

Use this constructor to create new vec4 instances.

local myVec = vec4(5, 2, 8, 4)

Properties

vec4 has four properties: x, y, z, and w.

Example:

local myVec = vec4(5, 2, 8, 4)
print(myVec.x) -- Prints 5
print(myVec.y) -- Prints 2
print(myVec.z) -- Prints 8
print(myVec.w) -- Prints 4