---
title: "colorAt(x:y:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsbitmapimagerep/colorat(x:y:)"
---

# colorAt(x:y:)

Returns the color of the pixel at the specified coordinates.

## Declaration

```swift
func colorAt(x: Int, y: Int) -> NSColor?
```

## Parameters

- `x`: The x-axis coordinate.
- `y`: The y-axis coordinate.

## Return Value

Return Value A color object representing the color at the specified coordinates.

## Discussion

Discussion Calling this method creates a new NSColor object. The overhead of object creation means this method is best suited for infrequent color sampling. If you instead need to work with large numbers of pixels, access the bitmap data directly using the bitmapData property or the getPixel(_:atX:y:) method for better performance.

## See Also

### Managing Pixel Values

- [setColor(_:atX:y:)](appkit/nsbitmapimagerep/setcolor(_:atx:y:).md)
- [setPixel(_:atX:y:)](appkit/nsbitmapimagerep/setpixel(_:atx:y:).md)
- [getPixel(_:atX:y:)](appkit/nsbitmapimagerep/getpixel(_:atx:y:).md)
