removed AsRef<>
This commit is contained in:
parent
85c2c528a7
commit
6f34278423
|
@ -1,13 +1,12 @@
|
|||
use ril::prelude::*;
|
||||
use std::path::Path;
|
||||
|
||||
pub struct Generate<T: AsRef<str>, V: AsRef<Path>> {
|
||||
elements: Vec<Element<T, V>>,
|
||||
pub struct Generate {
|
||||
elements: Vec<Element>,
|
||||
base: Image<Rgba>,
|
||||
}
|
||||
|
||||
impl<T: AsRef<str>, V: AsRef<Path>> Generate<T, V> {
|
||||
pub fn new(base: Vec<u8>, elements: Vec<Element<T, V>>) -> Result<Self, CowError> {
|
||||
impl Generate {
|
||||
pub fn new(base: Vec<u8>, elements: Vec<Element>) -> Result<Self, CowError> {
|
||||
Ok(Self {
|
||||
base: Image::<Rgba>::from_bytes_inferred(&base)?,
|
||||
elements,
|
||||
|
@ -38,14 +37,14 @@ impl<T: AsRef<str>, V: AsRef<Path>> Generate<T, V> {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct Element<T: AsRef<str>, V: AsRef<Path>> {
|
||||
pub struct Element {
|
||||
position: (i32, i32),
|
||||
dimensions: (u32, u32),
|
||||
media: Media<T, V>,
|
||||
media: Media,
|
||||
}
|
||||
|
||||
impl<T: AsRef<str>, V: AsRef<Path>> Element<T, V> {
|
||||
pub fn new(media: Media<T, V>, 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<T: AsRef<str>, V: AsRef<Path>> Element<T, V> {
|
|||
)
|
||||
.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<T: AsRef<str>, V: AsRef<Path>> Element<T, V> {
|
|||
}
|
||||
}
|
||||
|
||||
pub enum Media<T: AsRef<str>, V: AsRef<Path>> {
|
||||
Text(Text<T, V>),
|
||||
pub enum Media {
|
||||
Text(Text),
|
||||
Image(Vec<u8>),
|
||||
}
|
||||
|
||||
pub struct Text<T: AsRef<str>, V: AsRef<Path>> {
|
||||
text: T,
|
||||
font: V,
|
||||
pub struct Text {
|
||||
text: String,
|
||||
font: Box<Vec<u8>>,
|
||||
size: f32,
|
||||
fill: (u8, u8, u8, u8),
|
||||
}
|
||||
|
||||
impl<T: AsRef<str>, V: AsRef<Path>> Text<T, V> {
|
||||
pub fn new(text: T, font: V, size: f32, fill: (u8, u8, u8, u8)) -> Self {
|
||||
impl Text {
|
||||
pub fn new(text: String, font: Box<Vec<u8>>, size: f32, fill: (u8, u8, u8, u8)) -> Self {
|
||||
Self {
|
||||
text,
|
||||
font,
|
||||
|
|
Loading…
Reference in New Issue