add Bitmap texture coordinate sampling convenience method
his has some off-by-one issues ... ? looks like it mostly works fine, but i need to investigate more
This commit is contained in:
parent
a106228517
commit
ed58dc39cd
|
@ -66,6 +66,13 @@ impl<PixelType: Pixel> Bitmap<PixelType> {
|
||||||
*(self.pixels_at_ptr_unchecked(x, y))
|
*(self.pixels_at_ptr_unchecked(x, y))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn sample_at(&self, u: f32, v: f32) -> PixelType {
|
||||||
|
let x = (u * self.width as f32) as i32 % self.width as i32;
|
||||||
|
let y = (v * self.height as f32) as i32 % self.height as i32;
|
||||||
|
unsafe { self.get_pixel_unchecked(x, y) }
|
||||||
|
}
|
||||||
|
|
||||||
/// Renders a single character using the font given.
|
/// Renders a single character using the font given.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn print_char<T: Font>(&mut self, ch: char, x: i32, y: i32, opts: FontRenderOpts<PixelType>, font: &T) {
|
pub fn print_char<T: Font>(&mut self, ch: char, x: i32, y: i32, opts: FontRenderOpts<PixelType>, font: &T) {
|
||||||
|
|
Loading…
Reference in a new issue