Skip to content

Api > Texture2D > GetPixel()


Texture2D.GetPixel(number x, number y, number mipLevel = 0)⚓︎

Gets the pixel color at coordinates (x, y).

Parameters:⚓︎

Name Type Description
x number The x coordinate of the pixel to get. The range is 0 through (texture width - 1).
y number The y coordinate of the pixel to get. The range is 0 through (texture height - 1).
mipLevel number The mipmap level to sample. The range is 0 through the texture's Texture.mipmapCount. The default value is 0.

Returns:⚓︎

type Description
Color The pixel color.

Usage⚓︎

---@type Texture2D
local texture2d;

---@type number
local x;

---@type number
local y;

---@type number
local mipLevel;


local val0 = texture2d.GetPixel(x, y, mipLevel)

Extra Detail⚓︎

This method gets pixel data from the texture in CPU memory. Texture.isReadable must be true.