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