|
|
@ -1,49 +1,48 @@ |
|
|
|
use std::default::Default; |
|
|
|
use std::default::Default; |
|
|
|
|
|
|
|
use rusttype::{Scale, FontCollection, Font}; |
|
|
|
|
|
|
|
use imageproc::drawing; |
|
|
|
|
|
|
|
use image::{GrayImage, RgbImage, Rgb, Luma}; |
|
|
|
|
|
|
|
use std::path::Path; |
|
|
|
|
|
|
|
use imageproc::rect::Rect; |
|
|
|
|
|
|
|
|
|
|
|
mod bgm { |
|
|
|
use std::fmt; |
|
|
|
use std::fmt; |
|
|
|
use std::fmt::Display; |
|
|
|
use std::default::Default; |
|
|
|
|
|
|
|
use std::fmt::Display; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use image::{Rgb, RgbImage}; |
|
|
|
#[derive(Debug,Clone,Copy,Eq,PartialEq)] |
|
|
|
use imageproc::drawing::draw_text_mut; |
|
|
|
pub enum PlayerSide { |
|
|
|
use rusttype::{FontCollection, Scale}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug,Clone,Copy,Eq,PartialEq)] |
|
|
|
|
|
|
|
pub enum Color { |
|
|
|
|
|
|
|
Black = 0, |
|
|
|
Black = 0, |
|
|
|
White = 1, |
|
|
|
White = 1, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug,Clone,Copy)] |
|
|
|
#[derive(Debug,Clone,Copy)] |
|
|
|
pub enum Phase { |
|
|
|
pub enum Phase { |
|
|
|
PickSides, |
|
|
|
PickSides, |
|
|
|
Turn(Color), |
|
|
|
Turn(PlayerSide), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug,Clone,Default)] |
|
|
|
#[derive(Debug,Clone,Default)] |
|
|
|
pub struct Player { |
|
|
|
pub struct Player { |
|
|
|
pub born_off: u32, |
|
|
|
pub born_off: u32, |
|
|
|
pub on_bar: u32, |
|
|
|
pub on_bar: u32, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug,Clone,Copy)] |
|
|
|
#[derive(Debug,Clone,Copy)] |
|
|
|
pub enum Bin { |
|
|
|
pub enum Bin { |
|
|
|
Free, |
|
|
|
Free, |
|
|
|
Black(u32), |
|
|
|
Black(u32), |
|
|
|
White(u32), |
|
|
|
White(u32), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)] |
|
|
|
#[derive(Debug)] |
|
|
|
pub struct Game { |
|
|
|
pub struct Game { |
|
|
|
pub phase : Phase, |
|
|
|
pub phase : Phase, |
|
|
|
pub multiplier : u32, |
|
|
|
pub multiplier : u32, |
|
|
|
pub roll : [u8; 2], |
|
|
|
pub roll : [u8; 2], |
|
|
|
pub players : [Player; 2], |
|
|
|
pub players : [Player; 2], |
|
|
|
pub bins : [Bin; 24], |
|
|
|
pub bins : [Bin; 24], |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl Default for Game { |
|
|
|
impl Default for Game { |
|
|
|
fn default() -> Self { |
|
|
|
fn default() -> Self { |
|
|
|
Game { |
|
|
|
Game { |
|
|
|
phase: Phase::PickSides, |
|
|
|
phase: Phase::PickSides, |
|
|
@ -56,71 +55,10 @@ mod bgm { |
|
|
|
bins: [Bin::Free; 24], |
|
|
|
bins: [Bin::Free; 24], |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl Display for Game { |
|
|
|
impl Display for Game { |
|
|
|
fn fmt(&self, f : &mut fmt::Formatter<'_>) -> fmt::Result { |
|
|
|
fn fmt(&self, f : &mut fmt::Formatter<'_>) -> fmt::Result { |
|
|
|
/* |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const BLACK_DIGITS : [char; 20] = [ |
|
|
|
|
|
|
|
'❶', '❷', '❸', '❹', '❺', '❻', '❼', '❽', '❾', '❿', |
|
|
|
|
|
|
|
'⓫', '⓬', '⓭', '⓮', '⓯', '⓰', '⓱', '⓲', '⓳', '⓴', |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const WHITE_DIGITS : [char; 20] = [ |
|
|
|
|
|
|
|
'➀', '➁', '➂', '➃', '➄', '➅', '➆', '➇', '➈', '➉', |
|
|
|
|
|
|
|
'⑪', '⑫', '⑬', '⑭', '⑮', '⑯', '⑰', '⑱', '⑲', '⑳', |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
write!(f, "13 14 15 16 17 18 19 20 21 22 23 24\n")?; |
|
|
|
|
|
|
|
for b in &self.bins[12..=23] { |
|
|
|
|
|
|
|
match *b { |
|
|
|
|
|
|
|
Bin::Free => write!(f, "-- ")?, |
|
|
|
|
|
|
|
Bin::Black(n) => { |
|
|
|
|
|
|
|
if n > 0 && n <= BLACK_DIGITS.len() as u32 { |
|
|
|
|
|
|
|
write!(f, "{} ", BLACK_DIGITS[(n-1) as usize])?; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
write!(f, "{} ", n)?; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Bin::White(n) => { |
|
|
|
|
|
|
|
if n > 0 && n <= WHITE_DIGITS.len() as u32 { |
|
|
|
|
|
|
|
write!(f, "{} ", WHITE_DIGITS[(n-1) as usize])?; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
write!(f, "{} ", n)?; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
write!(f, "\n")?; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for b in (&self.bins[0..=11]).iter().rev() { |
|
|
|
|
|
|
|
match *b { |
|
|
|
|
|
|
|
Bin::Free => write!(f, "-- ")?, |
|
|
|
|
|
|
|
Bin::Black(n) => { |
|
|
|
|
|
|
|
if n > 0 && n <= BLACK_DIGITS.len() as u32 { |
|
|
|
|
|
|
|
write!(f, "{} ", BLACK_DIGITS[(n-1) as usize])?; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
write!(f, "{} ", n)?; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Bin::White(n) => { |
|
|
|
|
|
|
|
if n > 0 && n <= WHITE_DIGITS.len() as u32 { |
|
|
|
|
|
|
|
write!(f, "{} ", WHITE_DIGITS[(n-1) as usize])?; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
write!(f, "{} ", n)?; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
write!(f, "\n")?;
|
|
|
|
|
|
|
|
write!(f, "12 11 10 9 8 7 6 5 4 3 2 1\n")?; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//*
|
|
|
|
|
|
|
|
write!(f, " ")?; |
|
|
|
write!(f, " ")?; |
|
|
|
for n in (13..=24).rev() { write!(f, "{:2}. ", n)?; } |
|
|
|
for n in (13..=24).rev() { write!(f, "{:2}. ", n)?; } |
|
|
|
write!(f, "\n╭ ")?; |
|
|
|
write!(f, "\n╭ ")?; |
|
|
@ -145,54 +83,219 @@ mod bgm { |
|
|
|
write!(f, "╴\n ")?; |
|
|
|
write!(f, "╴\n ")?; |
|
|
|
for n in (1..=12).rev() { write!(f, "{:2}. ", n)?; } |
|
|
|
for n in (1..=12).rev() { write!(f, "{:2}. ", n)?; } |
|
|
|
write!(f, "\n")?; |
|
|
|
write!(f, "\n")?; |
|
|
|
//*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
Ok(()) |
|
|
|
const DIGITS : &[u8; 36] = b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
write!(f, " 14 16 18 20 22 24\n")?; |
|
|
|
fn main() { |
|
|
|
write!(f, " 13╲╱15╲╱17╲╱19╲╱21╲╱23╲╱\n")?; |
|
|
|
let mut board = Game::default(); |
|
|
|
write!(f, "╭")?; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for b in &self.bins[12..=23] { |
|
|
|
board.bins[4] = Bin::Black(5); |
|
|
|
match *b { |
|
|
|
board.bins[5] = Bin::Black(2); |
|
|
|
Bin::Free => write!(f, "──")?, |
|
|
|
board.bins[6] = Bin::Black(7); |
|
|
|
Bin::Black(n) => write!(f, "{}█", DIGITS[n as usize] as char)?, |
|
|
|
|
|
|
|
Bin::White(n) => write!(f, "{}░", DIGITS[n as usize] as char)? |
|
|
|
board.bins[14] = Bin::White(9); |
|
|
|
|
|
|
|
board.bins[15] = Bin::White(10); |
|
|
|
|
|
|
|
board.bins[16] = Bin::White(11); |
|
|
|
|
|
|
|
board.bins[2] = Bin::White(2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // let mut image = RgbImage::new(200, 200);
|
|
|
|
|
|
|
|
// let mut image : RgbImage = RgbImage::new(200, 200);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// let font = Vec::from(include_bytes!("DejaVuSans.ttf") as &[u8]);
|
|
|
|
|
|
|
|
// let font = FontCollection::from_bytes(font)
|
|
|
|
|
|
|
|
// .unwrap()
|
|
|
|
|
|
|
|
// .into_font()
|
|
|
|
|
|
|
|
// .unwrap();
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// let height = 12.0;
|
|
|
|
|
|
|
|
// let scale = Scale {
|
|
|
|
|
|
|
|
// x: height,
|
|
|
|
|
|
|
|
// y: height,
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// let white = Rgb([255u8, 255u8, 255u8]);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// draw_text_mut(
|
|
|
|
|
|
|
|
// &mut image,
|
|
|
|
|
|
|
|
// white,
|
|
|
|
|
|
|
|
// 0,
|
|
|
|
|
|
|
|
// 0,
|
|
|
|
|
|
|
|
// scale,
|
|
|
|
|
|
|
|
// &font,
|
|
|
|
|
|
|
|
// "Hello, world!",
|
|
|
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// imageproc::drawing::draw_line_segment_mut(&mut image, (0.0, 0.0), (200.0,200.0), white);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// let _ = image.save("out.gif").unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut image = CrispImage::new(250, 60); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
image.fill(BG); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn draw_disc(image : &mut CrispImage, pos: (i32, i32), bin : Bin) { |
|
|
|
|
|
|
|
match bin { |
|
|
|
|
|
|
|
Bin::Free => { |
|
|
|
|
|
|
|
image.circle_filled(GRAY, pos, 7); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
Bin::Black(n) => { |
|
|
|
|
|
|
|
let s = n.to_string(); |
|
|
|
|
|
|
|
// image.circle_filled(BLACK, pos, 7);
|
|
|
|
|
|
|
|
image.circle(WHITE, pos, 7); |
|
|
|
|
|
|
|
image.text(WHITE, (pos.0 - (s.len() as i32 * 5)/2, pos.1 - 3), &s); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
Bin::White(n) => { |
|
|
|
|
|
|
|
let s = n.to_string(); |
|
|
|
|
|
|
|
image.circle_filled(WHITE, pos, 7); |
|
|
|
|
|
|
|
image.circle(WHITE, pos, 7); |
|
|
|
|
|
|
|
image.text(BLACK, (pos.0 - (s.len() as i32 * 5)/2, pos.1 - 3), &s); |
|
|
|
|
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
write!(f, "─┘\n╰")?; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for b in (&self.bins[0..=11]).iter().rev() { |
|
|
|
for (i, n) in (13..=24).enumerate() { |
|
|
|
match *b { |
|
|
|
let s = n.to_string(); |
|
|
|
Bin::Free => write!(f, "──")?, |
|
|
|
image.text(YELLOW, (10 + 20 * i as i32 - (s.len() as i32 * 5)/2, 2), &s); |
|
|
|
Bin::Black(n) => write!(f, "{}█", DIGITS[n as usize] as char)?, |
|
|
|
|
|
|
|
Bin::White(n) => write!(f, "{}░", DIGITS[n as usize] as char)? |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i, n) in (1..=12).rev().enumerate() { |
|
|
|
|
|
|
|
let s = n.to_string(); |
|
|
|
|
|
|
|
image.text(YELLOW, (10 + 20 * i as i32 - (s.len() as i32 * 5)/2, 51), &s); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
write!(f, "─┐\n")?; |
|
|
|
//
|
|
|
|
write!(f, " 12╱╲10╱╲8.╱╲6.╱╲4.╱╲2.╱╲\n")?; |
|
|
|
// let s = "1";
|
|
|
|
write!(f, " 11 9. 7. 5. 3. 1.\n")?; |
|
|
|
// image.text(YELLOW, (10 - (s.len() as i32 * 5)/2, 2), &s);
|
|
|
|
*/ |
|
|
|
//
|
|
|
|
|
|
|
|
// let s = "13";
|
|
|
|
|
|
|
|
// image.text(YELLOW, (30 - (s.len() as i32 * 5)/2, 2), &s);
|
|
|
|
|
|
|
|
|
|
|
|
Ok(()) |
|
|
|
draw_disc(&mut image, (10, 20), Bin::Black(7)); |
|
|
|
|
|
|
|
draw_disc(&mut image, (30, 20), Bin::Black(13)); |
|
|
|
|
|
|
|
draw_disc(&mut image, (50, 20), Bin::Free); |
|
|
|
|
|
|
|
draw_disc(&mut image, (70, 20), Bin::White(69)); |
|
|
|
|
|
|
|
draw_disc(&mut image, (90, 20), Bin::White(9)); |
|
|
|
|
|
|
|
for n in 1..=7 { |
|
|
|
|
|
|
|
draw_disc(&mut image, (90+n*20, 20), Bin::Free); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for n in 0..=11 { |
|
|
|
|
|
|
|
draw_disc(&mut image, (10 + n*20, 40), Bin::Free); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
image.render("out.png"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
println!("{}", board); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn main() { |
|
|
|
type Color = Rgb<u8>; |
|
|
|
let mut board = bgm::Game::default(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
board.bins[4] = bgm::Bin::Black(5); |
|
|
|
struct CrispImage<'a> { |
|
|
|
board.bins[5] = bgm::Bin::Black(2); |
|
|
|
image : RgbImage, |
|
|
|
board.bins[6] = bgm::Bin::Black(7);
|
|
|
|
font: Font<'a>, |
|
|
|
|
|
|
|
width: u32, |
|
|
|
|
|
|
|
height: u32, |
|
|
|
|
|
|
|
font_scale: Scale, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
board.bins[14] = bgm::Bin::White(9); |
|
|
|
const BG : Color = Rgb([18, 26, 36]); |
|
|
|
board.bins[15] = bgm::Bin::White(10); |
|
|
|
|
|
|
|
board.bins[16] = bgm::Bin::White(11); |
|
|
|
|
|
|
|
board.bins[2] = bgm::Bin::White(2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const BLACK : Color = Rgb([0, 0, 0]); |
|
|
|
|
|
|
|
const GRAY : Color = Rgb([67, 83, 104]); |
|
|
|
|
|
|
|
const WHITE : Color = Rgb([255, 255, 255]); |
|
|
|
|
|
|
|
const RED : Color = Rgb([255, 0, 0]); |
|
|
|
|
|
|
|
const YELLOW : Color = Rgb([255, 255, 0]); |
|
|
|
|
|
|
|
const GREEN : Color = Rgb([0, 255, 0]); |
|
|
|
|
|
|
|
const BLUE : Color = Rgb([0, 0, 255]); |
|
|
|
|
|
|
|
const CYAN : Color = Rgb([0, 255, 255]); |
|
|
|
|
|
|
|
const MAGENTA : Color = Rgb([255, 0, 255]); |
|
|
|
|
|
|
|
|
|
|
|
println!("{}", board); |
|
|
|
impl<'a> CrispImage<'a> { |
|
|
|
|
|
|
|
fn new(width: u32, height: u32) -> Self { |
|
|
|
|
|
|
|
let mut image : RgbImage = RgbImage::new(width, height); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// let font_bytes = include_bytes!("DejaVuSans.ttf");
|
|
|
|
|
|
|
|
// let font_bytes = include_bytes!("lilliput steps.ttf");
|
|
|
|
|
|
|
|
// let font_bytes = include_bytes!("fixedsys.ttf"); // 16.2
|
|
|
|
|
|
|
|
// let font_bytes = include_bytes!("DOSVGA.ttf"); // 16
|
|
|
|
|
|
|
|
let font_bytes = include_bytes!("coders_crux.ttf"); // 8.86
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let font = Vec::from(font_bytes as &[u8]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let font = FontCollection::from_bytes(font) |
|
|
|
|
|
|
|
.unwrap() |
|
|
|
|
|
|
|
.into_font() |
|
|
|
|
|
|
|
.unwrap(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Self { |
|
|
|
|
|
|
|
image, |
|
|
|
|
|
|
|
font, |
|
|
|
|
|
|
|
width, |
|
|
|
|
|
|
|
height, |
|
|
|
|
|
|
|
font_scale: Scale { |
|
|
|
|
|
|
|
/* x: 16.,
|
|
|
|
|
|
|
|
y: 16.,*/ |
|
|
|
|
|
|
|
x: 8.86, |
|
|
|
|
|
|
|
y: 8.86, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn fill(&mut self, color: Color) { |
|
|
|
|
|
|
|
self.rect_filled(color, (0,0), (self.width, self.height)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn render(&self, path : impl AsRef<Path>) { |
|
|
|
|
|
|
|
let _ = self.image.save(path).unwrap(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn font_scale(&mut self, f : f32) { |
|
|
|
|
|
|
|
self.font_scale.x = f; |
|
|
|
|
|
|
|
self.font_scale.y = f; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn text(&mut self, color: Color, pos : (i32, i32), text: &str) { |
|
|
|
|
|
|
|
assert!(pos.0 >= 0); |
|
|
|
|
|
|
|
assert!(pos.1 >= 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
drawing::draw_text_mut( |
|
|
|
|
|
|
|
&mut self.image, |
|
|
|
|
|
|
|
color, |
|
|
|
|
|
|
|
pos.0 as u32, |
|
|
|
|
|
|
|
pos.1 as u32, |
|
|
|
|
|
|
|
self.font_scale, |
|
|
|
|
|
|
|
&self.font, |
|
|
|
|
|
|
|
text, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn circle(&mut self, color: Color, center: (i32, i32), radius: i32) { |
|
|
|
|
|
|
|
drawing::draw_hollow_circle_mut(&mut self.image, center, radius, color); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn circle_filled(&mut self, color: Color, center: (i32, i32), radius: i32) { |
|
|
|
|
|
|
|
drawing::draw_filled_circle_mut(&mut self.image, center, radius, color); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn line(&mut self, color: Color, from: (i32, i32), to: (i32, i32)) { |
|
|
|
|
|
|
|
drawing::draw_line_segment_mut(&mut self.image, |
|
|
|
|
|
|
|
(from.0 as f32, from.1 as f32), |
|
|
|
|
|
|
|
(to.0 as f32, to.1 as f32), |
|
|
|
|
|
|
|
color); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn rect(&mut self, color: Color, tl: (i32, i32), size: (u32, u32)) { |
|
|
|
|
|
|
|
drawing::draw_hollow_rect_mut(&mut self.image, |
|
|
|
|
|
|
|
Rect::at(tl.0, tl.1).of_size(size.0, size.1), |
|
|
|
|
|
|
|
color); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn rect_filled(&mut self, color: Color, tl: (i32, i32), size: (u32, u32)) { |
|
|
|
|
|
|
|
drawing::draw_filled_rect_mut(&mut self.image, |
|
|
|
|
|
|
|
Rect::at(tl.0, tl.1).of_size(size.0, size.1), |
|
|
|
|
|
|
|
color); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|