This commit is contained in:
parent
035f8896f1
commit
fae83aedc5
5 changed files with 44 additions and 40 deletions
36
src/main.rs
36
src/main.rs
|
@ -201,23 +201,23 @@ impl cosmic::Application for App {
|
|||
}
|
||||
};
|
||||
|
||||
// let items: Vec<ServiceItem> = items
|
||||
// .into_par_iter()
|
||||
// .map(|mut item| {
|
||||
// item.slides = item
|
||||
// .slides
|
||||
// .into_par_iter()
|
||||
// .map(|mut slide| {
|
||||
// text_svg::text_svg_generator(
|
||||
// &mut slide,
|
||||
// Arc::clone(&fontdb),
|
||||
// );
|
||||
// slide
|
||||
// })
|
||||
// .collect();
|
||||
// item
|
||||
// })
|
||||
// .collect();
|
||||
let items: Vec<ServiceItem> = items
|
||||
.into_par_iter()
|
||||
.map(|mut item| {
|
||||
item.slides = item
|
||||
.slides
|
||||
.into_par_iter()
|
||||
.map(|mut slide| {
|
||||
text_svg::text_svg_generator(
|
||||
&mut slide,
|
||||
Arc::clone(&fontdb),
|
||||
);
|
||||
slide
|
||||
})
|
||||
.collect();
|
||||
item
|
||||
})
|
||||
.collect();
|
||||
|
||||
let presenter = Presenter::with_items(items.clone());
|
||||
let song_editor = SongEditor::new(Arc::clone(&fontdb));
|
||||
|
@ -258,7 +258,7 @@ impl cosmic::Application for App {
|
|||
};
|
||||
|
||||
batch.push(app.add_library());
|
||||
batch.push(app.add_service(items, Arc::clone(&fontdb)));
|
||||
// batch.push(app.add_service(items, Arc::clone(&fontdb)));
|
||||
let batch = Task::batch(batch);
|
||||
(app, batch)
|
||||
}
|
||||
|
|
|
@ -812,10 +812,10 @@ pub(crate) fn slide_view(
|
|||
let text: Element<Message> =
|
||||
if let Some(text) = &slide.text_svg {
|
||||
if let Some(handle) = &text.handle {
|
||||
Image::new(handle)
|
||||
image(handle)
|
||||
.content_fit(ContentFit::Cover)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.width(width)
|
||||
.height(size.height)
|
||||
.into()
|
||||
} else {
|
||||
Space::with_width(0).into()
|
||||
|
|
|
@ -243,6 +243,21 @@ impl TextSvg {
|
|||
|
||||
pub fn build(mut self) -> Self {
|
||||
debug!("starting...");
|
||||
|
||||
let mut path = dirs::data_local_dir().unwrap();
|
||||
path.push(PathBuf::from("lumina"));
|
||||
path.push(PathBuf::from("temp"));
|
||||
let file_title =
|
||||
&self.text.lines().next().unwrap().trim_end();
|
||||
path.push(PathBuf::from(file_title));
|
||||
path.set_extension("png");
|
||||
|
||||
if path.exists() {
|
||||
debug!("cached");
|
||||
let handle = Handle::from_path(path);
|
||||
self.handle = Some(handle);
|
||||
return self;
|
||||
}
|
||||
let shadow = if let Some(shadow) = &self.shadow {
|
||||
format!("<filter id=\"shadow\"><feDropShadow dx=\"{}\" dy=\"{}\" stdDeviation=\"{}\" flood-color=\"{}\"/></filter>",
|
||||
shadow.offset_x,
|
||||
|
@ -260,8 +275,8 @@ impl TextSvg {
|
|||
} else {
|
||||
"".into()
|
||||
};
|
||||
let size = Size::new(3840.0, 2160.0);
|
||||
let font_size = self.font.size as f32 * (size.width / 960.0);
|
||||
let size = Size::new(1920.0, 1080.0);
|
||||
let font_size = self.font.size as f32;
|
||||
let total_lines = self.text.lines().count();
|
||||
let half_lines = (total_lines / 2) as f32;
|
||||
let middle_position = size.height / 2.0;
|
||||
|
@ -307,21 +322,10 @@ impl TextSvg {
|
|||
Pixmap::new(size.width as u32, size.height as u32)
|
||||
.expect("opops");
|
||||
resvg::render(&resvg_tree, transform, &mut pixmap.as_mut());
|
||||
// debug!(?pixmap);
|
||||
// let mut path = dirs::data_local_dir().unwrap();
|
||||
// path.push(PathBuf::from("lumina"));
|
||||
// path.push(PathBuf::from("temp"));
|
||||
// let file_title =
|
||||
// &self.text.lines().next().unwrap().trim_end();
|
||||
// path.push(PathBuf::from(file_title));
|
||||
// path.set_extension("png");
|
||||
// let _ = pixmap.save_png(&path);
|
||||
let _ = pixmap.save_png(&path);
|
||||
|
||||
debug!("rendered");
|
||||
let handle = Handle::from_rgba(
|
||||
size.width as u32,
|
||||
size.height as u32,
|
||||
pixmap.take(),
|
||||
);
|
||||
let handle = Handle::from_path(path);
|
||||
self.handle = Some(handle);
|
||||
debug!("stored");
|
||||
self
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
(slide :background (image :source "~/pics/frodo.jpg" :fit fill)
|
||||
(text "This is frodo" :font-size 90))
|
||||
(text "This is frodo" :font-size 140))
|
||||
(slide (video :source "~/vids/test/camprules2024.mp4" :fit contain))
|
||||
(slide (video :source "~/vids/never give up.mkv" :fit contain))
|
||||
(slide (video :source "~/vids/The promise of Rust.mkv" :fit contain))
|
||||
(song :id 7 :author "North Point Worship"
|
||||
:font "Quicksand Bold" :font-size 60
|
||||
:font "Quicksand" :font-size 140
|
||||
:shadow "" :stroke ""
|
||||
:title "Death Was Arrested"
|
||||
:background (image :source "file:///home/chris/nc/tfc/openlp/CMG - Bright Mountains 01.jpg" :fit cover)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
(song :id 7 :author "North Point Worship"
|
||||
:font "Quicksand Bold" :font-size 60
|
||||
:font "Quicksand" :font-size 140
|
||||
:title "Death Was Arrested"
|
||||
:background (image :source "~/nc/tfc/openlp/CMG - Bright Mountains 01.jpg" :fit cover)
|
||||
:text-alignment center
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue