MCPcopy Index your code
hub / github.com/endbasic/endbasic / peek_pixel

Method peek_pixel

sdl/src/host.rs:441–452  ·  view source on GitHub ↗
(&self, xy: PixelsXY)

Source from the content-addressed store, hash-verified

439 }
440
441 fn peek_pixel(&self, xy: PixelsXY) -> io::Result<Option<u8>> {
442 if !self.contains_pixel(xy) {
443 return Ok(None);
444 }
445
446 let rect = rect_origin_size(xy, SizeInPixels::new(1, 1));
447 let data = self
448 .canvas
449 .read_pixels(rect, PixelFormatEnum::RGB24)
450 .map_err(string_error_to_io_error)?;
451 Ok(rgb_to_ansi_color((data[0], data[1], data[2])))
452 }
453
454 fn read_pixels(&mut self, xy: PixelsXY, size: SizeInPixels) -> io::Result<Self::ID> {
455 let rect = rect_origin_size(xy, size);

Callers 1

runFunction · 0.45

Calls 4

rect_origin_sizeFunction · 0.85
rgb_to_ansi_colorFunction · 0.85
contains_pixelMethod · 0.45
read_pixelsMethod · 0.45

Tested by

no test coverage detected