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

Method assert_xy_size_in_range

std/src/gfx/lcd/buffered/mod.rs:200–218  ·  view source on GitHub ↗

Make sure that the coordinates and size are within the LCD space. This is only used to validate input parameters for those functions that are internal to the console (such as `move_pixels`). Functions subject to user input (such as `draw_rect`) must not use this.

(&mut self, xy: PixelsXY, size: SizeInPixels)

Source from the content-addressed store, hash-verified

198 /// console (such as `move_pixels`). Functions subject to user input (such as `draw_rect`) must
199 /// not use this.
200 fn assert_xy_size_in_range(&mut self, xy: PixelsXY, size: SizeInPixels) {
201 if cfg!(test) {
202 self.assert_xy_in_range(xy);
203 let x = xy.x as usize;
204 let y = xy.y as usize;
205
206 let width = usize::from(size.width);
207 let height = usize::from(size.height);
208
209 debug_assert!(
210 x + width - 1 < self.size_pixels.width,
211 "x + width must be within the LCD width"
212 );
213 debug_assert!(
214 y + height - 1 < self.size_pixels.height,
215 "y + height must be within the LCD height"
216 );
217 }
218 }
219
220 /// Gets the start address of the pixel `x`/`y` in the framebuffer.
221 fn fb_addr(&self, x: usize, y: usize) -> usize {

Callers 2

read_pixelsMethod · 0.80
move_pixelsMethod · 0.80

Calls 1

assert_xy_in_rangeMethod · 0.80

Tested by

no test coverage detected