MCPcopy Create free account
hub / github.com/cpmech/plotpy / test_text

Function test_text

tests/test_text.rs:9–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7
8#[test]
9fn test_text() -> Result<(), StrError> {
10 // text object and options
11 let mut text = Text::new();
12 text.set_color("blue")
13 .set_align_horizontal("center")
14 .set_align_vertical("center")
15 .set_fontsize(40.0)
16 .set_rotation(45.0)
17 .set_bbox(true)
18 .set_bbox_facecolor("pink")
19 .set_bbox_edgecolor("black")
20 .set_bbox_alpha(0.3)
21 // .set_bbox_style("square,pad=0.3");
22 // .set_bbox_style("circle,pad=0.3");
23 // .set_bbox_style("larrow,pad=0.3");
24 // .set_bbox_style("rarrow,pad=0.3");
25 // .set_bbox_style("darrow,pad=0.3");
26 // .set_bbox_style("round,pad=0.3,rounding_size=0.15");
27 // .set_bbox_style("round4,pad=0.3,rounding_size=0.2");
28 .set_bbox_style("sawtooth,pad=0.3,tooth_size=0.1")
29 .set_extra("fontweight=10");
30 // .set_bbox_style("roundtooth,pad=0.3,tooth_size=0.2");
31
32 // draw text
33 text.draw(0.5, 0.5, "message: $\\frac{\\alpha}{\\beta} = \\gamma$");
34
35 // add text to plot
36 let mut plot = Plot::new();
37 plot.add(&text);
38
39 // save figure
40 let path = Path::new(OUT_DIR).join("integ_text.svg");
41 plot.set_show_errors(true).save(&path)?;
42
43 // check number of lines
44 let file = File::open(path).map_err(|_| "cannot open file")?;
45 let buffered = BufReader::new(file);
46 let lines_iter = buffered.lines();
47 assert!(lines_iter.count() > 560);
48 Ok(())
49}
50
51#[test]
52fn test_text_negative_rotation() -> Result<(), StrError> {

Callers

nothing calls this directly

Calls 15

set_bbox_styleMethod · 0.80
set_bbox_alphaMethod · 0.80
set_bbox_edgecolorMethod · 0.80
set_bbox_facecolorMethod · 0.80
set_bboxMethod · 0.80
set_rotationMethod · 0.80
saveMethod · 0.80
set_show_errorsMethod · 0.80
set_extraMethod · 0.45
set_fontsizeMethod · 0.45
set_align_verticalMethod · 0.45
set_align_horizontalMethod · 0.45

Tested by

no test coverage detected