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