0.3.5 • Published 2 years ago

p5-studio v0.3.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

P5 Studio

Screenshot

Table of matters

Getting started

Installation

Before starting make sure you have Python 3 installed on your computer and that the python command is available in the path.

P5 Studio is available as a CLI, it is recommended to install it globally.

npm i -g p5-studio

Creating a new workspace

You can easily create a new workspace using the CLI.

p5 create MyNewWorkspace

Starting the web interface

Once you have successfully created a new project you can now use the serve command to start the development server.

This can be done by running the serve script that has been automatically added to the package.json file.

# with yarn
yarn serve

# with npm
npm run serve

By default the server will start on port 3000 and can be accessed by opening http://localhost:3000 in the browser

CLI

Usage: p5 [options] [command]

Commands

new options \

Creates a new workspace with the provided name

OptionDescriptionDefault
-o, --outPath of the output directory.

generate options \ / g options \

Generate a new sketch with the provided name

OptionDescriptionDefault
-o, --outPath of the output directory.

serve options

OptionDescriptionDefault
-p, --portPort to start the server on3000
-d, --sketchesDirDirectory that contains the sketches.
-o, --outDirDirectory that contains the rendered sketches./renders

Writing sketches

Sketches must be written in Typescript, they are compiled to Javascript automatically using esbuild.

All sketches within the specified sketch directory will be available through the web interface.

In order for a sketch to be recognized, the file name must end by .sketch.ts.

It is recommended to use the generate command to create new sketches in order to avoid mistakes.

The optimization field in the sketch metadata can be used to specify optimizations that will be applied when a render is saved. This uses vpype in the background. Please see this example to learn how to configure the different optimizations.

The gCode metadata field can be used to generate a .gcode file alongside the .svg. This uses vpype-gcode in the background. Please see the gcode example for more informations.

Examples

For more examples please check out the example folder.

You can run the examples locally by cloning this repository and using the following command:

npm run serve:examples

Example sketch

import { SketchFn, SketchMetadata } from "p5-studio";

// This is your sketch metadata, everything is optionnal
// name: The name of your sketch
// resolution: The width and height of your sketch
// fps: The number of time your sketch is rendered every second (rendered only once if not specified)
export const metadata: SketchMetadata = {
  name: "Example sketch",
  resolution: {
    w: 500,
    h: 500,
  },
  optimizations: ['lineSimplify', 'lineMerge', 'reLoop', 'lineSort'],
};

// This function is called once every time the sketch is loaded.
// You can initialize variable and settings here.
// The parameter p is the p5 instance.
export const setup: SketchFn = (p) => {
};

// This function is called once every frame.
// Do your drawing here
// The parameter p is the p5 instance.
export const draw: SketchFn = (p) => {
  p.noFill();
  p.strokeWeight(5);
  p.stroke("red");
  p.circle(250, 250, 300);
};
0.3.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.3.5

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.2.2

2 years ago

0.3.4

2 years ago

0.1.6

2 years ago

0.3.3

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago