Skip to content

Commit 76169e7

Browse files
committed
Add Image::get_pixel
1 parent c1695a8 commit 76169e7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

raylib/src/core/texture.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ impl Image {
8585
self.0.data
8686
}
8787

88+
pub fn get_pixel(&self, x: i32, y: i32) -> Option<Color> {
89+
if x < 0 || y < 0 || x >= self.width() || y >= self.height() {
90+
None
91+
} else {
92+
unsafe { Some(ffi::GetImageColor(self.0, x, y)) }
93+
}
94+
}
95+
8896
#[inline]
8997
pub fn format(&self) -> PixelFormat {
9098
let i: u32 = self.0.format as u32;

0 commit comments

Comments
 (0)