fixup feature fest

This commit is contained in:
bunnie 2022-05-27 17:41:22 +08:00
parent 7d020182d4
commit a8e7809087
8 changed files with 23 additions and 21 deletions

View file

@ -45,6 +45,6 @@ utralib = {path = "../../utralib"}
[features] [features]
debugprint = [] debugprint = []
tts = [] tts = []
ditherpunk = [] ditherpunk = ["dither", "image"]
# default = ["debugprint"] # "debugprint" # default = ["debugprint"] # "debugprint"
default = [] default = []

View file

@ -1,7 +1,6 @@
use core::cmp::{max, min}; use core::cmp::{max, min};
use dither::prelude::{Dither, Img, RGB}; use dither::prelude::{Dither, Img, RGB};
use graphics_server::api::shapes; use graphics_server::api::*;
use graphics_server::api::{Point, Rectangle, Tile};
use graphics_server::PixelColor; use graphics_server::PixelColor;
use std::convert::TryInto; use std::convert::TryInto;
use std::ops::Deref; use std::ops::Deref;
@ -62,17 +61,17 @@ impl Bitmap {
fn tile_spec(bm_size: Point) -> (Point, i16) { fn tile_spec(bm_size: Point) -> (Point, i16) {
let bm_width_bits = 1 + bm_size.x as usize; let bm_width_bits = 1 + bm_size.x as usize;
let mut tile_width_bits = bm_width_bits; let mut tile_width_bits = bm_width_bits;
let tile_width_words = if bm_width_bits > shapes::BITS_PER_TILE { let tile_width_words = if bm_width_bits > BITS_PER_TILE {
log::warn!("Bitmap max width exceeded"); log::warn!("Bitmap max width exceeded");
tile_width_bits = shapes::WORDS_PER_TILE * shapes::BITS_PER_WORD; tile_width_bits = WORDS_PER_TILE * BITS_PER_WORD;
shapes::WORDS_PER_TILE WORDS_PER_TILE
} else { } else {
match bm_width_bits % shapes::BITS_PER_WORD { match bm_width_bits % BITS_PER_WORD {
0 => bm_width_bits / shapes::BITS_PER_WORD, 0 => bm_width_bits / BITS_PER_WORD,
_ => bm_width_bits / shapes::BITS_PER_WORD + 1, _ => bm_width_bits / BITS_PER_WORD + 1,
} }
}; };
let tile_height_bits = shapes::WORDS_PER_TILE / tile_width_words; let tile_height_bits = WORDS_PER_TILE / tile_width_words;
let tile_size = Point::new(tile_width_bits as i16, tile_height_bits as i16); let tile_size = Point::new(tile_width_bits as i16, tile_height_bits as i16);
(tile_size, tile_width_words as i16) (tile_size, tile_width_words as i16)
} }
@ -134,12 +133,12 @@ impl Bitmap {
&mut self.mosaic.as_mut_slice()[tile] &mut self.mosaic.as_mut_slice()[tile]
} }
pub fn get_line(&self, point: Point) -> Vec<shapes::Word> { pub fn get_line(&self, point: Point) -> Vec<Word> {
self.get_tile(point).get_line(point) self.get_tile(point).get_line(point)
} }
#[allow(dead_code)] #[allow(dead_code)]
fn get_word(&self, point: Point) -> shapes::Word { fn get_word(&self, point: Point) -> Word {
self.get_tile(point).get_word(point) self.get_tile(point).get_word(point)
} }

View file

@ -1,10 +1,6 @@
use crate::api::{ClipRect, DrawStyle, Point}; use crate::api::{ClipRect, DrawStyle, Point};
use crate::op::{HEIGHT, WIDTH}; use crate::op::{HEIGHT, WIDTH};
use core::cmp::{max, min}; use core::cmp::{max, min};
#[cfg(feature="ditherpunk")]
use crate::api::PixelColor;
#[cfg(feature="ditherpunk")]
use std::convert::TryInto;
#[derive(Debug, Clone, Copy, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] #[derive(Debug, Clone, Copy, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
pub struct Rectangle { pub struct Rectangle {

View file

@ -1,3 +1,5 @@
use crate::api::*;
use std::convert::TryInto;
//////////////////////// Tile -------- author: nworbnhoj //////////////////////// Tile -------- author: nworbnhoj
/* /*

View file

@ -590,9 +590,10 @@ pub fn rounded_rectangle(fb: &mut LcdFB, rr: RoundedRectangle, clip: Option<Rect
* author: nworbnhoj * author: nworbnhoj
*/ */
#[cfg(feature="ditherpunk")] #[cfg(feature="ditherpunk")]
use crate::api::Tile;
#[cfg(feature="ditherpunk")]
pub fn tile(fb: &mut LcdFB, tile: Tile, clip: Option<Rectangle>) { pub fn tile(fb: &mut LcdFB, tile: Tile, clip: Option<Rectangle>) {
use std::cmp::min; use std::cmp::min;
use crate::api::Tile;
// prepare the clip boundries: min (LCD, clip, tile) // prepare the clip boundries: min (LCD, clip, tile)
let bound = tile.bound(); let bound = tile.bound();
let tl_x = bound.tl.x as usize; let tl_x = bound.tl.x as usize;

View file

@ -33,5 +33,5 @@ utralib = { path = "../../utralib"}
[features] [features]
tts = [] tts = []
ditherpunk = [] ditherpunk = ["image", "dither", "fast_image_resize"]
default = [] default = []

View file

@ -198,12 +198,14 @@ impl Modals {
Ok(()) Ok(())
} }
#[cfg(feature="ditherpunk")]
const MODAL_WIDTH: u32 = 300;
#[cfg(feature="ditherpunk")]
const MODAL_HEIGHT: u32 = 370;
/// this blocks until the image has been dismissed. /// this blocks until the image has been dismissed.
#[cfg(feature="ditherpunk")] #[cfg(feature="ditherpunk")]
pub fn show_image(&self, img: &RgbImage) -> Result<(), xous::Error> { pub fn show_image(&self, img: &RgbImage) -> Result<(), xous::Error> {
self.lock(); self.lock();
const MODAL_WIDTH: u32 = 300;
const MODAL_HEIGHT: u32 = 370;
// resize and/or rotate // resize and/or rotate
let (modal_width, modal_height) = (Modals::MODAL_WIDTH as f32, Modals::MODAL_HEIGHT as f32); let (modal_width, modal_height) = (Modals::MODAL_WIDTH as f32, Modals::MODAL_HEIGHT as f32);

View file

@ -457,7 +457,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
&pkgs, &pkgs,
lkey, lkey,
kkey, kkey,
None, Some(&[
"--features", "ditherpunk",
]),
&[], &[],
None, None,
)? )?