pub fn draw_point(&mut self, x: usize, y: usize, color: [u8; 4]) {
        let base = self.stride * y + self.pixel_size * x;
        if self.endianness == Endian::Little {
            if color[0] == 255 {
                self.buffer[base + 3] = color[0];
                self.buffer[base + 2] = color[1];
                self.buffer[base + 1] = color[2];
                self.buffer[base] = color[3];
            } else {
                for c in 0..3 {
                    let alpha = f32::from(color[0]) / 255.0;
                    let color_diff =
                        (color[3 - c] as isize - self.buffer[base + c] as isize) as f32 * alpha;
                    let new_color = (f32::from(self.buffer[base + c]) + color_diff) as u8;
                    self.buffer[base + c] = new_color as u8;
                }
                self.buffer[base + 3] = 255 as u8;
            }
        } else if color[0] == 255 {
            self.buffer[base] = color[0];
            self.buffer[base + 1] = color[1];
            self.buffer[base + 2] = color[2];
            self.buffer[base + 3] = color[3];
        } else {
            for c in 1..4 {
                let alpha = f32::from(color[0]) / 255.0;
                let color_diff =
                    (color[c] as isize - self.buffer[base + c] as isize) as f32 * alpha;
                let new_color = (f32::from(self.buffer[base + c]) + color_diff) as u8;
                self.buffer[base + c] = new_color as u8;
            }
            self.buffer[base] = 255 as u8;
        }
    }
/// Draws a pixel at the x and y coordinate
Draws a pixel at the x and y coordinate
Draws a pixel at the x and y coordinate
pub fn draw_point(&mut self, x: usize, y: usize, color: [u8; 4]) {
        let base = self.stride * y + self.pixel_size * x;
        if self.endianness == Endian::Little {
            if color[0] == 255 {
                self.buffer[base + 3] = color[0];
                self.buffer[base + 2] = color[1];
                self.buffer[base + 1] = color[2];
                self.buffer[base] = color[3];
            } else {
                for c in 0..3 {
                    let alpha = f32::from(color[0]) / 255.0;
                    let color_diff =
                        (color[3 - c] as isize - self.buffer[base + c] as isize) as f32 * alpha;
                    let new_color = (f32::from(self.buffer[base + c]) + color_diff) as u8;
                    self.buffer[base + c] = new_color as u8;
                }
                self.buffer[base + 3] = 255 as u8;
            }
        } else if color[0] == 255 {
            self.buffer[base] = color[0];
            self.buffer[base + 1] = color[1];
            self.buffer[base + 2] = color[2];
            self.buffer[base + 3] = color[3];
        } else {
            for c in 1..4 {
                let alpha = f32::from(color[0]) / 255.0;
                let color_diff =
                    (color[c] as isize - self.buffer[base + c] as isize) as f32 * alpha;
                let new_color = (f32::from(self.buffer[base + c]) + color_diff) as u8;
                self.buffer[base + c] = new_color as u8;
            }
            self.buffer[base] = 255 as u8;
        }
    }
pub fn draw_point ( & mut self , x : usize , y : usize , color : [ u8 ; 4 ] ) { let base = self . stride * y + self . pixel_size * x ; if self . endianness == Endian :: Little { if color [ 0 ] == 255 { self . buffer [ base + 3 ] = color [ 0 ] ; self . buffer [ base + 2 ] = color [ 1 ] ; self . buffer [ base + 1 ] = color [ 2 ] ; self . buffer [ base ] = color [ 3 ] ; } else { for c in 0 .. 3 { let alpha = f32 :: from ( color [ 0 ] ) / 255.0 ; let color_diff = ( color [ 3 - c ] as isize - self . buffer [ base + c ] as isize ) as f32 * alpha ; let new_color = ( f32 :: from ( self . buffer [ base + c ] ) + color_diff ) as u8 ; self . buffer [ base + c ] = new_color as u8 ; } self . buffer [ base + 3 ] = 255 as u8 ; } } else if color [ 0 ] == 255 { self . buffer [ base ] = color [ 0 ] ; self . buffer [ base + 1 ] = color [ 1 ] ; self . buffer [ base + 2 ] = color [ 2 ] ; self . buffer [ base + 3 ] = color [ 3 ] ; } else { for c in 1 .. 4 { let alpha = f32 :: from ( color [ 0 ] ) / 255.0 ; let color_diff = ( color [ c ] as isize - self . buffer [ base + c ] as isize ) as f32 * alpha ; let new_color = ( f32 :: from ( self . buffer [ base + c ] ) + color_diff ) as u8 ; self . buffer [ base + c ] = new_color as u8 ; } self . buffer [ base ] = 255 as u8 ; } }
Draws a pixel at the x and y coordinate
Draws a pixel at the x and y coordinate
&mut self
x
usize
y
usize
color
[u8; 4]
&mut self
x
usize
y
usize
color
[u8; 4]