Skip to main content

A static content generator for interactive and parametrisable p5.js canvases.

Project description

Ginpar PyPI

Ginpar is a static website generator for interactive P5.js sketches, awkwardly named after Generative Interactive Parametrisable Canvases.

Key features:

  • Generate an individual page for each sketch in your project.
  • Generate forms to control the parameters of the sketch on the go.
  • Specify what parameters from the sketch you want to control.
  • Generate an index page that links to every sketch.

Ginpar aims to generate portfolios for generative artists.

Contents

How to use

tl;dr:

  1. Install
    $ pip install ginpar
    
  2. Initialize
    $ ginpar-quickstart
    
  3. Build
    $ ginpar
    

Installing

For now the only way to get ginpar running is by installing the PyPi package:

$ pip install ginpar

Initializing

Ginpar has a quickstart project that imports a theme with jinja2 templates, an example sketch, and an initial configuration file config.py:

$ ginpar-quickstart

Preparing sketches

To use an existing sketch, you need to add some constants and functions with tight restrictions.

We suggest to check some examples.

Specifying parameters

First you need to specify the parameters that will be controllable in the sketch page. To do that, you must:

  1. Declare a variable with a string containing JSON valid syntax that also complies with Ginpar API.
  2. Enclose the declaration with the delimiters /* ##ginpar */
/* ##ginpar */
const paramsJSON = `[
  {
    "var": "WIDTH",
    "attrs": {
      "type": "number",
      "value": 2048,
      "min": 0,
      "max": 4096
    }
  },
  {
    "var": "HEIGHT",
    "attrs": {
      "type": "number",
      "value": 2560,
      "min": 0,
      "max": 5120
    }
  },
  {
    "var": "STOP_ODDS",
    "attrs": {
      "type": "range",
      "value": 0.8,
      "step": 0.001,
      "min": 0,
      "max": 1
    }
  }]`
/* ##ginpar */

It's necessary, as for the current version, to only include one declaration between the delimiters. Ginpar relies on this to obtain the JSON string.

Assigning variables to corresponding values

This is optional, since Ginpar will automatically generate the JS script that fetches the values of the form and assign it to the variables.

However, following this step will allow you to keep using the sketch script without needing to use Ginpar.

To do this, declare a new function that converts the paramsJSON string back into variables:

function jsonToVars(json){
  return Object.assign(...json.map(e => {return {[e.var]: e.attrs.value}}))
}

And re-write the declarations of the original variables like this:

const {
  WIDTH,
  HEIGHT,
  // Any other constant you declared in paramsJSON
  STOP_ODDS } = jsonToVars(JSON.parse(paramsJSON))

Note that for this to work, the constant symbol (e.g. WIDTH) must be equal to the value of var in the JSON array (e. g. {"var": "WIDTH", "attrs": {...}}).

Building

To build, simply run:

ginpar

The building process consists of:

  • Making a public/ directory.
  • Reading the config.json file (this consists of, among other things, the author info, the Ginpar theme, and the website url).
  • Copying the static content of the selected theme into public/
  • Listing the contents of sketches/, and using the ones with .js extension to:
    • Make a directory public/filename/ that contains a generated index.html and sketch.js.
    • Create a public/index.html file that adds a tags for every filename.

If you want to quickstart a project, read initializing.

Deploying

For now, we've only deployed in Netlify. However, using any other server to deliver static content should be easy.

Netlify

How to deploy to Netlify

Built With

  • Jinja2 - Templating language for Python.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Contributors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ginpar-0.2.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distributions

ginpar-0.2.0-py3.7.egg (23.4 kB view details)

Uploaded Egg

ginpar-0.2.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file ginpar-0.2.0.tar.gz.

File metadata

  • Download URL: ginpar-0.2.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for ginpar-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b56dc1e7c43ff95c503b55aa56fd62c565076453125fb7c39853353661cffa87
MD5 331b3006e07ad3183b64d033dd978a15
BLAKE2b-256 7bf8b3346a8db843b62887b1e7bedd89dda577093ae5c8111da53f7e19001e58

See more details on using hashes here.

File details

Details for the file ginpar-0.2.0-py3.7.egg.

File metadata

  • Download URL: ginpar-0.2.0-py3.7.egg
  • Upload date:
  • Size: 23.4 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for ginpar-0.2.0-py3.7.egg
Algorithm Hash digest
SHA256 b0159e7977249e701dc1c114224fefbc1001dadbf188feb5d64fffc84d8b6c60
MD5 9f7af90f446ca2e5ac7753d6a27c67fd
BLAKE2b-256 ca49ac55000007a8086d5cdcfaa918501b5cee72eea7fd597b608a69cb842233

See more details on using hashes here.

File details

Details for the file ginpar-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ginpar-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for ginpar-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e73201d9d846b547fee4377a3f8fde579f576f6101be049a1cc2239333b9bcbb
MD5 16ee7df788e069d50b37e6569abae588
BLAKE2b-256 cfccf512fa05b72cc1aa18e7d3e101ff9ab40d467877d30107f98846fae18b85

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page