MCPcopy Create free account
hub / github.com/PerroEngine/Perro / social_svg

Function social_svg

perro_website/src/main.rs:206–234  ·  view source on GitHub ↗
(title: &str, label: &str, summary: &str)

Source from the content-addressed store, hash-verified

204 "Perro Engine".to_string(),
205 "Rust Game Engine".to_string(),
206 "Open-source Rust game engine with docs, nodes, examples, and demos.".to_string(),
207 ),
208 }
209}
210
211#[cfg(feature = "ssr")]
212fn svg_to_png(svg: &str) -> Result<Vec<u8>, String> {
213 let opt = resvg::usvg::Options::default();
214 let tree = resvg::usvg::Tree::from_str(svg, &opt).map_err(|err| err.to_string())?;
215 let mut pixmap = resvg::tiny_skia::Pixmap::new(1200, 630).ok_or("could not create pixmap")?;
216 resvg::render(
217 &tree,
218 resvg::tiny_skia::Transform::identity(),
219 &mut pixmap.as_mut(),
220 );
221 pixmap.encode_png().map_err(|err| err.to_string())
222}
223
224#[cfg(feature = "ssr")]
225fn social_svg(title: &str, label: &str, summary: &str) -> String {
226 let title_lines = svg_lines(title, 24, 3);
227 let summary_lines = svg_lines(summary, 54, 2);
228 let title_text = svg_text_lines(&title_lines, 86, 226, 68, 78, "title");
229 let summary_text = svg_text_lines(&summary_lines, 90, 458, 30, 42, "summary");
230 format!(
231 r##"<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="630" viewBox="0 0 1200 630">
232 <defs>
233 <linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
234 <stop offset="0" stop-color="#10151b"/>
235 <stop offset="0.54" stop-color="#18232b"/>
236 <stop offset="1" stop-color="#27313a"/>
237 </linearGradient>

Callers 1

og_imageFunction · 0.85

Calls 2

svg_linesFunction · 0.85
svg_text_linesFunction · 0.85

Tested by

no test coverage detected