How to get color pixel under cursor?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By daniel500013

How to get pixel color under cursor?
I saw similar question as mine but those answers are in the gdscript when I programming in c#

:bust_in_silhouette: Reply From: wombatstampede

I don’t use the Mono version of Godot but I guess it would be just similar to GDScript. API differences to GDScript — Godot Engine (3.1) documentation in English

So something like: (inside a node)

GetViewport().GetTexture().GetData().GetPixel(x,y);

x,y should be retrievable from the mouse event.

If you intend to work with/change many pixels often then it might be advisable to use a screen shader. (Depends on your specific use case.)