notecrumbs

a nostr opengraph server build on nostrdb and egui
git clone git://jb55.com/notecrumbs
Log | Files | Refs | README | LICENSE

commit 2745a1be8b9454f2730b60d0d7dddf6c17ff6bee
parent 83fcf805c25d6bbed6b8f321460762dac142fdb0
Author: William Casarin <jb55@jb55.com>
Date:   Mon, 18 Dec 2023 07:57:35 -0800

ui: move note ui to its own function

it's a bit cleaner

Diffstat:
Msrc/main.rs | 39+++++++++++++++++++--------------------
1 file changed, 19 insertions(+), 20 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -44,30 +44,29 @@ fn nip19_target(nip19: &Nip19) -> Option<Target> { } } -fn render_note<'a>(_app_ctx: &Context, content: &'a str) -> Vec<u8> { +fn note_ui(ctx: &egui::Context, content: &str) { use egui::{FontId, RichText}; + + egui::CentralPanel::default().show(&ctx, |ui| { + ui.horizontal(|ui| { + ui.label(RichText::new("✏").font(FontId::proportional(120.0))); + ui.vertical(|ui| { + ui.label(RichText::new(content).font(FontId::proportional(40.0))); + }); + }) + }); +} + +fn render_note(_app_ctx: &Context, content: &str) -> Vec<u8> { use egui_skia::{rasterize, RasterizeOptions}; use skia_safe::EncodedImageFormat; - let mut surface = rasterize( - (1200, 630), - |ctx| { - //setup_fonts(&app_ctx.font_data, ctx); - - egui::CentralPanel::default().show(&ctx, |ui| { - ui.horizontal(|ui| { - ui.label(RichText::new("✏").font(FontId::proportional(120.0))); - ui.vertical(|ui| { - ui.label(RichText::new(content).font(FontId::proportional(40.0))); - }); - }) - }); - }, - Some(RasterizeOptions { - pixels_per_point: 1.0, - frames_before_screenshot: 1, - }), - ); + let options = RasterizeOptions { + pixels_per_point: 1.0, + frames_before_screenshot: 1, + }; + + let mut surface = rasterize((1200, 630), |ctx| note_ui(ctx, content), Some(options)); surface .image_snapshot()