Use f32 instead of i32 for lengths

This allows users to use logical coordinates instead of physical ones.
This commit is contained in:
Héctor Ramón Jiménez 2023-02-04 11:13:53 +01:00
parent f08bea22ed
commit 4320ae6329
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
15 changed files with 203 additions and 155 deletions

View file

@ -12,7 +12,7 @@ fn main() {
let mut swash_cache = SwashCache::new(&font_system);
// Text metrics indicate the font size and line height of a buffer
let metrics = Metrics::new(14, 20);
let metrics = Metrics::new(14.0, 20.0);
// A Buffer provides shaping and layout for a UTF-8 string, create one per text widget
let mut buffer = Buffer::new(&font_system, metrics);
@ -20,7 +20,7 @@ fn main() {
// Set a size for the text buffer, in pixels
let width = 80u16;
let height = 25u16;
buffer.set_size(width as i32, height as i32);
buffer.set_size(width as f32, height as f32);
// Attributes indicate what font to choose
let attrs = Attrs::new();
@ -39,7 +39,7 @@ fn main() {
// Clear buffer with black background
for _y in 0..height {
for _x in 0..buffer.size().0 {
for _x in 0..(buffer.size().0 as i32) {
print!(
"{} {}",
color::Bg(color::Rgb(0, 0, 0)),