Function create_path_from_string

Source
pub fn create_path_from_string(svg_raw_path: &str) -> Path
Expand description

Create a raqote::Path from a Svg path data string

§Arguments

  • svg_raw_path - A string slice that holds the Svg path data

supports the following Svg path data commands: m,M,l,L,v,V,h,H,c,C,s,S

§Example

use raqote_utils::create_path_from_string;
 
let Letter = create_path_from_string("M105 57.0273V453.751H252.659C448.259 461.723 428.124 276.022 352.856 253.513V243.197C424.768 204.274 423.809 54.6826 252.659 57.0273H105Z");
Examples found in repository?
examples/simple.rs (line 11)
4pub fn main() {
5    let mut dt = DrawTarget::new(512, 512);
6
7    let font_path = "/usr/share/fonts/FiraCodeNerdFont-Retina.ttf";
8
9    let circle = build_circle(100.0, 256.0, 256.0);
10
11    let logo1 = create_path_from_string("M105 57.0273V453.751H252.659C448.259 461.723 428.124 276.022 352.856 253.513V243.197C424.768 204.274 423.809 54.6826 252.659 57.0273H105Z");
12
13    dt.fill(
14        &circle,
15        &Source::Solid(SolidSource {
16            r: 0x00,
17            g: 0x00,
18            b: 0x00,
19            a: 0xFF,
20        }),
21        &DrawOptions::new(),
22    );
23
24    dt.fill(
25        &logo1,
26        &Source::Solid(SolidSource {
27            r: 0x81,
28            g: 0x0E,
29            b: 0x68,
30            a: 0xFF,
31        }),
32        &DrawOptions::new(),
33    );
34
35    create_text_ligatures(
36        "Hello, World\nline2\n==>\n#[",
37        50.,
38        50.,
39        &font_path,
40        20.,
41        &mut dt,
42        &Source::Solid(SolidSource {
43            r: 0xff,
44            g: 0xff,
45            b: 0xff,
46            a: 0xFF,
47        }),
48    );
49
50    let _ = dt.write_png("png.png");
51}