p5_sys/lib.rs
1#![feature(unboxed_closures)]
2#![feature(fn_traits)]
3
4//! `p5-sys` crate(library) is bindings to [p5.js](https://p5js.org/) for Rust/Wasm.
5//!
6//! *** Nightly rustc is required ***
7//!
8//! Currently,almost all global function works. The instance methods and properties don't work.
9//! For example, `vector.add()` will not work. You are advised to use rust types for such tasks.
10//! Also functions that take arrays and modify them will not work.
11//!
12//! The documentation is taken from p5.js reference and are not ported to rust yet.
13//!
14//! # Example
15//! ```no_run
16//! use p5::*;
17//!
18//! pub struct State {
19//! x: f64,
20//! }
21//!
22//! #[wasm_bindgen]
23//! pub fn setup() -> State {
24//! createCanvas(400., 400., RENDERER::Webgl);
25//! background(123., 234., 124.);
26//! return State {
27//! x: 10.,
28//! }
29//! }
30//!
31//! #[wasm_bindgen]
32//! pub fn draw(state: &mut State) {
33//! state.x += 1;
34//! rect(state.x, 40., 100., 120.);
35//! }
36//! ```
37//!
38//! We don't have mutable global variable in Rust, so we have to use state.
39//! setup creates the state. draw and other event handlers recieve
40//! a mutable reference to it, means that they can change it.
41
42pub mod global;
43pub mod constants;
44pub mod types;
45
46pub use global::*;
47pub use types::*;
48pub use constants::*;
49pub use wasm_bindgen::prelude::*;