Giter Site home page Giter Site logo

purescript-p5's Introduction

purescript-p5

p5.js bindings for PureScript

Disclaimer: This project has just been started and the API is still very unstable.

Documentation

Module documentation is published on Pursuit.

purescript-p5 implements a subset of the p5.js API (see Project Status).

Installation

bower install purescript-p5

This library depends on p5.js. This dependency may be satisfied by installing the NPM p5.js package.

npm install p5 --save

Running the examples

The examples use the webpack DLLPlugin to improve build performance. To run the examples, first build the dll bundle with:

npm run webpack:dll

This creates a separate webpack bundle for dependencies so that they don't need to be regenerated each time the app is changed.

To start webpack dev server, run:

npm run webpack:server

With webpack dev server running, examples can be viewed in a browser by visiting localhost:4008/examples/path-to-example.

Project Status

Completed:

  • wrappers for most methods defined on the p5 class

TODO:

  • generate methods for classes other than p5 (e.g. p5.Vector, p5.Image)
  • create easier-to-use interfaces for functions with numeric suffixes
  • use Reader monad to implicitly pass the p5 argument

References

Many of the examples are based on the p5.js examples on the p5.js reference site, and are licensed under CC BY-NC-SA 4.0.

purescript-p5's People

Contributors

derektmueller avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

purescript-p5's Issues

Re-exports in `P5` for most common modules

Currently it may be a bit annoying for the user to import all the needed modules one by one.

What do you think, would it be a good idea to have re-exports in the P5 module, so that this module is the only one that needs to be imported?

'easier-to-use interfaces for functions with numeric suffixes'

As noted in the TODO section on the Readme:

Would this be the pattern?

-- | [p5js.org documentation](https://p5js.org/reference/#/p5/loadFont)
loadFont4 :: P5 -> String -> Maybe (Effect Unit) -> Maybe (Effect Unit) -> Font
loadFont4 p5 path callback onError = runFn4 loadFontImpl p5 path callback onError

-- | [p5js.org documentation](https://p5js.org/reference/#/p5/loadFont)
loadFont3 :: P5 -> String -> Maybe (Effect Unit) -> Font
loadFont3 p5 path callback = runFn4 loadFontImpl p5 path callback Nothing

-- | [p5js.org documentation](https://p5js.org/reference/#/p5/loadFont)
loadFont2 :: P5 -> String -> Font
loadFont2 p5 path = runFn4 loadFontImpl p5 path Nothing Nothing

Another way would be to omit the necessary first arg 'P5` in the counting :/

Make the `image` function draw `Graphics`

The function P5.Image.LoadingAndDisplaying.image currently has this signature:

image :: P5 -> ElementOrImage -> Number -> Number -> (Maybe Number) -> (Maybe Number) -> (Effect Unit)

This aligns with the P5 documentation: p5.Image|p5.Element: the image to display

However, it's also possible to draw 'Graphics' to the canvas with this function.

In P5 Graphics are subsumed under the 'base class' Element. Looks weird to me because as far as I understand, a 'graphics' object is not an HTML object, rather some internal representation of a layer on the canvas.

The suggestion would be to have a type GraphicsOrImageOrElement and change the above image function to accept this as argument.

Any plans to add frameCount?

I've just started playing p5. Are you planning to add frameCount or any idea where would be the best place to add it if I was to send a PR?

`keyPressed` should be implemented like `setup` or `draw`

keyPressed in P5 is a function name that should be implemented by the user like setup or draw. Confused by the type signature I found on pursuit, I started browsing this source code and it seems like keyPressed (and similiar functions like keyReleased) are implemented like ordinary callable functions like background or rect.

Since these bindings are still under heavy development I don't know if this is a bug or just not finished yet. If there is interest in that, I will contribute a fix for a bug.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.