Skip to content

Api > Texture2D > SetPixel()


Texture2D.SetPixel(number x, number y, Color color, number mipLevel = 0)⚓︎

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

Parameters:⚓︎

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

Usage⚓︎

---@type Texture2D
local texture2d;

---@type number
local x;

---@type number
local y;

---@type Color
local color;

---@type number
local mipLevel;


texture2d.SetPixel(x, y, color, mipLevel)

Extra Detail⚓︎

This method sets pixel data for the texture in CPU memory. Texture.isReadable must be true, and you must call Apply after SetPixel to upload the changed pixels to the GPU.