Get pixel data from image layer at coordinates
✓ Published0🌍 Public
KKevinGutowski
Last edited Jul 20, 2021
Created on Jul 20, 2021
This example demonstrates how to extract the color of a specific pixel from an image that is part of a Sketch document. It grabs the first selected layer, converts its image data into an `NSBitmapImageRep`, and then calls `colorAtX_y` to read the RGB value at coordinates (1,2). The result is logged as a CSS string using `MSColor.colorWithNSColor`, showing the pixel’s color in a web-friendly format. The code relies on Sketch’s scripting API and the Cocoa/AppKit `NSBitmapImageRep` class for image decoding.
AI-generated description