pub fn draw_box(&self, renderer: &mut Renderer, rect: Rect) {
        let mut src_rect = Rect::new(0, 0, self.piece_size, self.piece_size);

        // Top-left border
        src_rect.x = 0 * self.piece_size;
        let mut dst_rect = Rect::new(rect.x, rect.y, self.scaled_size(), self.scaled_size());
        renderer.copy(&self.texture, Some(src_rect.to_sdl()), Some(dst_rect.to_sdl()));

        // Top border
        src_rect.x = 1 * self.piece_size;
        dst_rect.x += self.scaled_size();
        while dst_rect.x + self.scaled_size() < rect.x + rect.width {
            renderer.copy(&self.texture, Some(src_rect.to_sdl()), Some(dst_rect.to_sdl()));
            dst_rect.x += self.scaled_size();
        }

        // Top-right border
        src_rect.x = 2 * self.piece_size;
        renderer.copy(&self.texture, Some(src_rect.to_sdl()), Some(dst_rect.to_sdl()));

        // Left border
        src_rect.x = 3 * self.piece_size;
        dst_rect.y = rect.y + self.scaled_size();
        dst_rect.x = rect.x;
        while dst_rect.y + self.scaled_size() < rect.y + rect.height {
            renderer.copy(&self.texture, Some(src_rect.to_sdl()), Some(dst_rect.to_sdl()));
            dst_rect.y += self.scaled_size();
        }

        // Right border
        src_rect.x = 3 * self.piece_size;
        dst_rect.y = rect.y + self.scaled_size();
        dst_rect.x = rect.x + rect.width - self.scaled_size();
        while dst_rect.y + self.scaled_size() < rect.y + rect.height {
            renderer.copy(&self.texture, Some(src_rect.to_sdl()), Some(dst_rect.to_sdl()));
            dst_rect.y += self.scaled_size();
        }

        // Bottom-left border
        src_rect.x = 4 * self.piece_size;
        dst_rect.x = rect.x;
        renderer.copy(&self.texture, Some(src_rect.to_sdl()), Some(dst_rect.to_sdl()));

        // Bottom border
        src_rect.x = 1 * self.piece_size;
        dst_rect.x += self.scaled_size();
        while dst_rect.x + self.scaled_size() < rect.x + rect.width {
            renderer.copy(&self.texture, Some(src_rect.to_sdl()), Some(dst_rect.to_sdl()));
            dst_rect.x += self.scaled_size();
        }

        // Bottom-right border
        src_rect.x = 5 * self.piece_size;
        renderer.copy(&self.texture, Some(src_rect.to_sdl()), Some(dst_rect.to_sdl()));
    }
/// Renders a box to a specified rectangle
Renders a box to a specified rectangle
Renders a box to a specified rectangle
pub fn draw_box(&self, renderer: &mut Renderer, rect: Rect) {
        let mut src_rect = Rect::new(0, 0, self.piece_size, self.piece_size);
        // Top-left border
        src_rect.x = 0 * self.piece_size;
        let mut dst_rect = Rect::new(rect.x, rect.y, self.scaled_size(), self.scaled_size());
        renderer.copy(&self.texture, Some(src_rect.to_sdl()), Some(dst_rect.to_sdl()));
        // Top border
        src_rect.x = 1 * self.piece_size;
        dst_rect.x += self.scaled_size();
        while dst_rect.x + self.scaled_size() < rect.x + rect.width {
            renderer.copy(&self.texture, Some(src_rect.to_sdl()), Some(dst_rect.to_sdl()));
            dst_rect.x += self.scaled_size();
        }
        // Top-right border
        src_rect.x = 2 * self.piece_size;
        renderer.copy(&self.texture, Some(src_rect.to_sdl()), Some(dst_rect.to_sdl()));
        // Left border
        src_rect.x = 3 * self.piece_size;
        dst_rect.y = rect.y + self.scaled_size();
        dst_rect.x = rect.x;
        while dst_rect.y + self.scaled_size() < rect.y + rect.height {
            renderer.copy(&self.texture, Some(src_rect.to_sdl()), Some(dst_rect.to_sdl()));
            dst_rect.y += self.scaled_size();
        }
        // Right border
        src_rect.x = 3 * self.piece_size;
        dst_rect.y = rect.y + self.scaled_size();
        dst_rect.x = rect.x + rect.width - self.scaled_size();
        while dst_rect.y + self.scaled_size() < rect.y + rect.height {
            renderer.copy(&self.texture, Some(src_rect.to_sdl()), Some(dst_rect.to_sdl()));
            dst_rect.y += self.scaled_size();
        }
        // Bottom-left border
        src_rect.x = 4 * self.piece_size;
        dst_rect.x = rect.x;
        renderer.copy(&self.texture, Some(src_rect.to_sdl()), Some(dst_rect.to_sdl()));
        // Bottom border
        src_rect.x = 1 * self.piece_size;
        dst_rect.x += self.scaled_size();
        while dst_rect.x + self.scaled_size() < rect.x + rect.width {
            renderer.copy(&self.texture, Some(src_rect.to_sdl()), Some(dst_rect.to_sdl()));
            dst_rect.x += self.scaled_size();
        }
        // Bottom-right border
        src_rect.x = 5 * self.piece_size;
        renderer.copy(&self.texture, Some(src_rect.to_sdl()), Some(dst_rect.to_sdl()));
    }
pub fn draw_box ( & self , renderer : & mut Renderer , rect : Rect ) { let mut src_rect = Rect :: new ( 0 , 0 , self . piece_size , self . piece_size ) ; // Top-left border src_rect . x = 0 * self . piece_size ; let mut dst_rect = Rect :: new ( rect . x , rect . y , self . scaled_size ( ) , self . scaled_size ( ) ) ; renderer . copy ( & self . texture , Some ( src_rect . to_sdl ( ) ) , Some ( dst_rect . to_sdl ( ) ) ) ; // Top border src_rect . x = 1 * self . piece_size ; dst_rect . x += self . scaled_size ( ) ; while dst_rect . x + self . scaled_size ( ) < rect . x + rect . width { renderer . copy ( & self . texture , Some ( src_rect . to_sdl ( ) ) , Some ( dst_rect . to_sdl ( ) ) ) ; dst_rect . x += self . scaled_size ( ) ; } // Top-right border src_rect . x = 2 * self . piece_size ; renderer . copy ( & self . texture , Some ( src_rect . to_sdl ( ) ) , Some ( dst_rect . to_sdl ( ) ) ) ; // Left border src_rect . x = 3 * self . piece_size ; dst_rect . y = rect . y + self . scaled_size ( ) ; dst_rect . x = rect . x ; while dst_rect . y + self . scaled_size ( ) < rect . y + rect . height { renderer . copy ( & self . texture , Some ( src_rect . to_sdl ( ) ) , Some ( dst_rect . to_sdl ( ) ) ) ; dst_rect . y += self . scaled_size ( ) ; } // Right border src_rect . x = 3 * self . piece_size ; dst_rect . y = rect . y + self . scaled_size ( ) ; dst_rect . x = rect . x + rect . width - self . scaled_size ( ) ; while dst_rect . y + self . scaled_size ( ) < rect . y + rect . height { renderer . copy ( & self . texture , Some ( src_rect . to_sdl ( ) ) , Some ( dst_rect . to_sdl ( ) ) ) ; dst_rect . y += self . scaled_size ( ) ; } // Bottom-left border src_rect . x = 4 * self . piece_size ; dst_rect . x = rect . x ; renderer . copy ( & self . texture , Some ( src_rect . to_sdl ( ) ) , Some ( dst_rect . to_sdl ( ) ) ) ; // Bottom border src_rect . x = 1 * self . piece_size ; dst_rect . x += self . scaled_size ( ) ; while dst_rect . x + self . scaled_size ( ) < rect . x + rect . width { renderer . copy ( & self . texture , Some ( src_rect . to_sdl ( ) ) , Some ( dst_rect . to_sdl ( ) ) ) ; dst_rect . x += self . scaled_size ( ) ; } // Bottom-right border src_rect . x = 5 * self . piece_size ; renderer . copy ( & self . texture , Some ( src_rect . to_sdl ( ) ) , Some ( dst_rect . to_sdl ( ) ) ) ; }
Renders a box to a specified rectangle
Renders a box to a specified rectangle
&self
renderer
&mut Renderer
rect
Rect
&self
renderer
&mut Renderer
rect
Rect