From 6f34278423590e0e94df2cfd9d2ccca92510dcf6 Mon Sep 17 00:00:00 2001 From: emilis Date: Sat, 7 Jan 2023 23:04:33 +0000 Subject: [PATCH] removed AsRef<> --- cowgen/src/lib.rs | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/cowgen/src/lib.rs b/cowgen/src/lib.rs index e439e37..53c0967 100644 --- a/cowgen/src/lib.rs +++ b/cowgen/src/lib.rs @@ -1,13 +1,12 @@ use ril::prelude::*; -use std::path::Path; -pub struct Generate, V: AsRef> { - elements: Vec>, +pub struct Generate { + elements: Vec, base: Image, } -impl, V: AsRef> Generate { - pub fn new(base: Vec, elements: Vec>) -> Result { +impl Generate { + pub fn new(base: Vec, elements: Vec) -> Result { Ok(Self { base: Image::::from_bytes_inferred(&base)?, elements, @@ -38,14 +37,14 @@ impl, V: AsRef> Generate { } } -pub struct Element, V: AsRef> { +pub struct Element { position: (i32, i32), dimensions: (u32, u32), - media: Media, + media: Media, } -impl, V: AsRef> Element { - pub fn new(media: Media, position: (i32, i32), dimensions: (u32, u32)) -> Self { +impl Element { + pub fn new(media: Media, position: (i32, i32), dimensions: (u32, u32)) -> Self { Self { position, dimensions, @@ -67,7 +66,7 @@ impl, V: AsRef> Element { ) .with( &TextSegment::new( - &Font::open(text.font, 12.0).unwrap(), + &Font::from_bytes(&text.font, 12.0).unwrap(), text.text, Dynamic::Rgba(Rgba::new( text.fill.0, @@ -82,20 +81,20 @@ impl, V: AsRef> Element { } } -pub enum Media, V: AsRef> { - Text(Text), +pub enum Media { + Text(Text), Image(Vec), } -pub struct Text, V: AsRef> { - text: T, - font: V, +pub struct Text { + text: String, + font: Box>, size: f32, fill: (u8, u8, u8, u8), } -impl, V: AsRef> Text { - pub fn new(text: T, font: V, size: f32, fill: (u8, u8, u8, u8)) -> Self { +impl Text { + pub fn new(text: String, font: Box>, size: f32, fill: (u8, u8, u8, u8)) -> Self { Self { text, font,