Skip to main content

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

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

Parameters:

NameTypeDescription
xnumberThe x coordinate of the pixel to get. The range is 0 through (texture width - 1).
ynumberThe y coordinate of the pixel to get. The range is 0 through (texture height - 1).
mipLevelnumberThe mipmap level to sample. The range is 0 through the texture's Texture.mipmapCount. The default value is 0.

Returns:

typeDescription
ColorThe 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.