pub fn load() -> InkviewExamples found in repository?
examples/hello_world.rs (line 6)
5fn main() {
6 let iv = Box::leak(Box::new(inkview::load())) as &_;
7 const FONT_SIZE: c_int = 42;
8
9 inkview::iv_main(&iv, move |event| {
10 match event {
11 Event::Init => unsafe {
12 iv.SetCurrentApplicationAttribute(APPLICATION_ATTRIBUTE_APPLICATION_READER, 1);
13
14 let font_name = CString::new("LiberationSans").unwrap();
15 let text = CString::new("Hello world!").unwrap();
16
17 let font = iv.OpenFont(font_name.as_ptr(), FONT_SIZE, 0);
18 iv.ClearScreen();
19
20 iv.SetFont(font, bindings::BLACK as c_int);
21 iv.DrawLine(
22 25,
23 iv.ScreenHeight() - 25,
24 iv.ScreenWidth() - 25,
25 iv.ScreenHeight() - 25,
26 0x00666666,
27 );
28 iv.FillArea(
29 50,
30 250,
31 iv.ScreenWidth() - 50 * 2,
32 iv.ScreenHeight() - 250 * 2,
33 0x00E0E0E0,
34 );
35 iv.FillArea(
36 100,
37 300,
38 iv.ScreenWidth() - 100 * 2,
39 iv.ScreenHeight() - 300 * 2,
40 0x00A0A0A0,
41 );
42 iv.DrawTextRect(
43 0,
44 iv.ScreenHeight() / 2 - FONT_SIZE / 2,
45 iv.ScreenWidth(),
46 FONT_SIZE,
47 text.as_ptr(),
48 bindings::ALIGN_CENTER as c_int,
49 );
50
51 // Copies the buffer to the real screen
52 iv.FullUpdate();
53
54 iv.CloseFont(font);
55 },
56 Event::KeyDown { .. } => unsafe {
57 iv.CloseApp();
58 },
59 _ => {}
60 }
61 Some(())
62 });
63}More examples
examples/orientation.rs (line 6)
5fn main() {
6 let iv = Box::leak(Box::new(inkview::load())) as &_;
7 const FONT_SIZE: c_int = 24;
8 let mut orientation = 0;
9 let draw = |iv: &inkview::bindings::Inkview| unsafe {
10 let font_name = CString::new("LiberationSans").unwrap();
11 let text = CString::new("Press Menu to toggle the orientation!").unwrap();
12
13 let font = iv.OpenFont(font_name.as_ptr(), FONT_SIZE, 0);
14 iv.ClearScreen();
15 iv.SetFont(font, bindings::BLACK as c_int);
16 iv.FillArea(
17 50,
18 250,
19 iv.ScreenWidth() - 50 * 2,
20 iv.ScreenHeight() - 250 * 2,
21 0x00E0E0E0,
22 );
23 iv.FillArea(
24 100,
25 300,
26 iv.ScreenWidth() - 100 * 2,
27 iv.ScreenHeight() - 300 * 2,
28 0x00A0A0A0,
29 );
30 iv.DrawTextRect(
31 0,
32 iv.ScreenHeight() / 2 - FONT_SIZE / 2,
33 iv.ScreenWidth(),
34 FONT_SIZE,
35 text.as_ptr(),
36 bindings::ALIGN_CENTER as c_int,
37 );
38 iv.FullUpdate();
39 iv.CloseFont(font);
40 };
41
42 inkview::iv_main(&iv, move |event| {
43 match event {
44 Event::Init => {
45 unsafe {
46 iv.SetCurrentApplicationAttribute(APPLICATION_ATTRIBUTE_APPLICATION_READER, 1);
47 iv.SetOrientation(orientation);
48 }
49 draw(iv);
50 }
51 Event::KeyDown { key } => match key {
52 inkview::event::Key::Menu => {
53 orientation = match orientation {
54 0 => 2,
55 2 => 3,
56 3 => 1,
57 1 => 0,
58 _ => unreachable!(),
59 };
60 unsafe {
61 iv.SetOrientation(orientation);
62 }
63 draw(iv);
64 }
65 _ => unsafe {
66 iv.CloseApp();
67 },
68 },
69 _ => {}
70 }
71 Some(())
72 });
73}