p5js_gleam

Types

A reference to the P5js library. Primarily used to access the P5js APIs for drawing.

pub type P5

Configuration to start a sketch. Requires an init function to create the initial model, and a draw function to draw the model. Other handlers can also be provided to update the model based on different user events. Use the create_sketch function and the set_* helpers to initialize your config.

pub opaque type SketchConfig(model, ignored)

Functions

pub fn create_sketch(
  init init: fn(P5) -> a,
  draw draw: fn(P5, a) -> b,
) -> SketchConfig(a, b)

Creates a minimal sketch configuration.

pub fn set_on_key_pressed(
  s: SketchConfig(a, b),
  on_key_pressed: fn(String, Int, a) -> a,
) -> SketchConfig(a, b)

Sets the on_key_pressed function to be called.

pub fn set_on_key_released(
  s: SketchConfig(a, b),
  on_key_released: fn(String, Int, a) -> a,
) -> SketchConfig(a, b)

Sets the on_key_released function to be called.

pub fn set_on_mouse_clicked(
  s: SketchConfig(a, b),
  on_mouse_clicked: fn(Float, Float, a) -> a,
) -> SketchConfig(a, b)

Sets the on_mouse_clicked function to be called.

pub fn set_on_mouse_moved(
  s: SketchConfig(a, b),
  on_mouse_moved: fn(Float, Float, a) -> a,
) -> SketchConfig(a, b)

Sets the on_mouse_moved function to be called.

pub fn set_on_tick(
  s: SketchConfig(a, b),
  on_tick: fn(a) -> a,
) -> SketchConfig(a, b)

Sets the on_tick function to be called.

Search Document