# dxSetPixelColor (Client)

> Changes the colour of one pixel of a `plain` image, in the string itself.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Client
- **Category**: Screen drawing
- **URL**: https://wiki.mymp.gg/en/dxSetPixelColor

## Syntax

```lua
bool dxSetPixelColor(string pixels, int x, y, int r, g, b [, int a = 255])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `pixels` | `string` | The pixels in `plain`. |
| `x, y` | `int` | Position of the pixel, from 0. A vec2 also works. |
| `r, g, b` | `int` | Red, green and blue, from 0 to 255. |
| `a` | `int` | Alpha, from 0 to 255. *(default: `255`)* |

## Returns

`true` when the pixel changed, `false` when the pixels are not `plain`, the point is outside the image or the string is too short.

## Example

```lua
local tex = engineCreateTexture(64, 64)

dxGetTexturePixels(tex, function(pixels)
    if not pixels then return end
    dxSetPixelColor(pixels, 10, 10, 255, 255, 0)
    dxSetTexturePixels(tex, pixels)
end)
```

### Note

The string is changed in place: every variable holding the same string sees the change. Strings of up to 40 bytes cannot be changed and log a warning.

## See also

- [dxGetPixelColor (Client)](https://wiki.mymp.gg/en/dxGetPixelColor.md): Reads the colour of one pixel of a plain image.
- [dxSetTexturePixels (Client)](https://wiki.mymp.gg/en/dxSetTexturePixels.md): Writes pixels into a texture made by a script or into a render target.
- [dxGetTexturePixels (Client)](https://wiki.mymp.gg/en/dxGetTexturePixels.md): Reads an image's pixels and hands them to a function, a few frames later.
