# template-p5

> ts-p5 为了提供给 p5 提供更好的代码提示，与更符合初学者直觉的书写方式。

Latest version **0.0.2** (published 2020-12-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install template-p5
pnpm add template-p5
yarn add template-p5
bun add template-p5
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2020-12-20 |
| First published | 2020-12-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 16.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | aerospacexu |

## Links

- npm: https://www.npmjs.com/package/template-p5
- npm.io page: https://npm.io/package/template-p5

## Dependencies (3)

- [p5](https://npm.io/package/p5.md) ^0.9.0
- [src](https://npm.io/package/src.md) ^1.1.2
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13

## Recent versions

- 0.0.2 (latest) — 2020-12-20

## README

# ts-p5

ts-p5 为了提供给 p5 提供更好的代码提示，与更符合初学者直觉的书写方式。

## 如何写？

```js
import { sketchCreator } from 'ts-p5';
import { getWindowSize } from 'ts-p5/utils';

sketchCreator(
  {
    preload: function () {},
    setup: function (p) {
      const { width, height } = getWindowSize();
      p.createCanvas(width, height);
      p.background(0);
    },
    draw: function (p) {
      p.background(0);
      p.noStroke();
    },
    mousePressed: function (p) {
      console.log(p.mouseX);
      console.log(p.mouseY);
    },
  },
  document.querySelector('#sketch')
);
```

## utils

`import { map, getWindowSize } from 'ts-p5/utils'`

将常用的函数实现了一遍放在该文件夹下，方便使用。

## Service

将动画效果抽象为一项服务是解耦的重点。

例如下雨动画中，我们将雨滴储存在一个数组中 `raindrops: Raindrop`，通过 `update` 方法更新雨滴的数量。

---
_Source: https://npm.io/package/template-p5 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
