Skip to content

p5.js compatibility wrappers #336

Description

@ffd8

I'd like to wake up issue #252 – which discussed push() and pop(), in relation of how to make basil.js as compatible as possible with p5.js. The more I use p5.js, the more I find little nooks and crannies that are missing. Last fall I had students complain about how slow/etc it was to code purely in basil.js/inDesign and we found p5.js to be a great sandbox environment allowing code to quickly be copy + pasted + tweaked to basil.js (bummer ES6 isn't implemented). For that reason, I realize lots of little things that could be added/modified to make it that much smoother. Nevertheless I think we need a consensus about where these functions should sit and how their documentation should work. For speed of implementing this, I suggest we avoid new functions (ie. pushStyle()- unless time/interest allows), but put a priority on code compatibility that avoids error messages of non-existing functions = just mirrors/wrappers.

DOCUMENTATION (wrapper functions)

  • own description (clear when reading docs, but tricky if alpha-order doesn't keep side-by-side)
  • implemented but no documentation (confusing when appearing in code examples)
  • separate section called 'p5.js wrappers or compatibility' where they are listed and link to the main function
  • ______________

SRC (where do these wrappers go?)

  • right next to the function it's wrapping
  • new src doc called wrappers/compatibility (within that, /* SECTION HEADERS of src pages */ )
  • ______________

EXAMPLE (wrappers)

  • createCanvas() » size()
  • frameCount » new global frameCount = 1
  • textAlign() » needs same constants linked to TOP, BOTTOM, LEFT, CENTER, RIGHT
  • textSize » needs to allow 0 and not break.. could use abs() and <= 0 becomes .1
  • text() » work with just 3 params.. text(txt, x, y) (use width, height as default size)
  • circle() + square() + ellipse(x, y, w) <- ellipse with just 3 params = circle
  • color()/fill()/stroke() » allow a 2nd or 4th value for opacity = probably not so easy to implement...
  • textToPoints() » had based function name on Processing's Geomerative, but p5.js style makes more sense now
  • ...

Of course the list can slowly be implemented after a 2.0 release, but it would be nice to launch w/ main ones that would trip up beginners. Please feel free to add to the list and once we decide how/where to put them and documentation style, I'd get started.

Re: neverending launch of 2.0, this adds a decent reason for further delay... I'd aim for start of new year, or anniversary of 1.0 = Feb and schedule how to make that happen?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions