Garry's Mod Wiki

IMaterial:GetColor

  table IMaterial:GetColor( number x, number y )

Description

Returns the color of the specified pixel of the $basetexture, only works for materials created from PNG files.

Basically identical to ITexture:GetColor used on IMaterial:GetTexture( "$basetexture" ).

The returned color will not have the color metatable.

Issue Tracker: 2407

Arguments

1 number x
The X coordinate.
2 number y
The Y coordinate.

Returns

1 table
The color of the pixel as a Color.

Example

Identical functionality.

local m = Material( "gui/colors_dark.png" ) local t = m:GetTexture("$basetexture") PrintTable( t:GetColor( 5, 5 ) ) PrintTable( m:GetColor( 5, 5 ) )
Output: Both printouts will return identical color, which at the time of testing is RGBA - 255, 244, 242, 255.