@kinetographdev/p5-brush 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,67 @@
1
+ Required Notice: Copyright 2026 Sanat Gupta (https://github.com/0xS4N4TG)
2
+
3
+ # PolyForm Small Business License 1.0.0
4
+
5
+ <https://polyformproject.org/licenses/small-business/1.0.0>
6
+
7
+ ## Acceptance
8
+
9
+ In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
10
+
11
+ ## Copyright License
12
+
13
+ The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
14
+
15
+ ## Distribution License
16
+
17
+ The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
18
+
19
+ ## Notices
20
+
21
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
22
+
23
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
24
+
25
+ ## Changes and New Works License
26
+
27
+ The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
28
+
29
+ ## Patent License
30
+
31
+ The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
32
+
33
+ ## Fair Use
34
+
35
+ You may have "fair use" rights for the software under the law. These terms do not limit them.
36
+
37
+ ## Small Business
38
+
39
+ Use of the software for the benefit of your company is use for a permitted purpose if your company has fewer than 100 total individuals working as employees and independent contractors, and less than 1,000,000 USD (2019) total revenue in the prior tax year. Adjust this revenue threshold for inflation according to the United States Bureau of Labor Statistics' consumer price index for all urban consumers, U.S. city average, for all items, not seasonally adjusted, with 1982–1984=100 reference base.
40
+
41
+ ## No Other Rights
42
+
43
+ These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
44
+
45
+ ## Patent Defense
46
+
47
+ If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
48
+
49
+ ## Violations
50
+
51
+ The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
52
+
53
+ ## No Liability
54
+
55
+ ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
56
+
57
+ ## Definitions
58
+
59
+ The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
60
+
61
+ **You** refers to the individual or entity agreeing to these terms.
62
+
63
+ **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
64
+
65
+ **Your licenses** are all the licenses granted to you for the software under these terms.
66
+
67
+ **Use** means anything you do with the software requiring one of your licenses.
package/README.md CHANGED
@@ -1,3 +1,26 @@
1
- # Temporary Holding Version
1
+ # @kinetographdev/p5-brush
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A canvas that [p5.brush](https://github.com/acamposuribe/p5.brush) draws into, reseeded and redrawn from the frame number, so a frame is the same alone and in sequence.
4
+
5
+ Part of [Kinetograph](https://github.com/0xS4N4TG/kinetograph), a programmatic video engine. `p5.brush` is a peer dependency, used through `p5.brush/standalone`, and is used as it is.
6
+
7
+ ```sh
8
+ npm install @kinetographdev/p5-brush p5.brush
9
+ ```
10
+
11
+ ```tsx
12
+ import { BrushCanvas } from '@kinetographdev/p5-brush';
13
+
14
+ <BrushCanvas seed={7} background="#f4efe6" origin="top-left" draw={(brush, frame, { width }) => {
15
+ brush.set('HB', '#2f2a26', 1.4);
16
+ brush.line(120, 140, 120 + frame * 10, 260);
17
+ }} />
18
+ ```
19
+
20
+ - Each frame: `brush.load(canvas)`, `clear`, `seed(seed)`, `noiseSeed(seed)`, `draw`, `render`, inside `push`/`pop` so fill, hatch and brush settings do not carry to the next frame.
21
+ - The canvas is the composition's size unless `width` and `height` are given.
22
+ - p5.brush's origin is the centre of the canvas, y down. `origin="top-left"` translates so that (0, 0) is the top left corner.
23
+ - A render waits (`delayRender`) until the first frame is drawn.
24
+ - Needs the WebGL support of Kinetograph (a `webgl2` canvas context that the engine draws).
25
+
26
+ Licensed under the PolyForm Small Business License 1.0.0, see `LICENSE.md`.
@@ -0,0 +1,37 @@
1
+ import { type CSSProperties } from 'react';
2
+ /** The p5.brush standalone API (`brush.set`, `brush.line`, `brush.fill`, ...). p5.brush ships no types. */
3
+ export type Brush = Record<string, any>;
4
+ export interface BrushCanvasProps {
5
+ /** Seeds p5.brush's random and noise generators at the start of every frame. */
6
+ seed: number | string;
7
+ /**
8
+ * Draws the frame. `size` is the canvas size in pixels. Coordinates are p5.brush's own: the origin is the centre
9
+ * of the canvas, y points down (as in p5's WEBGL mode), unless `origin="top-left"`.
10
+ */
11
+ draw: (brush: Brush, frame: number, size: {
12
+ width: number;
13
+ height: number;
14
+ }) => void;
15
+ /** Canvas width in pixels. Default: the composition's width. */
16
+ width?: number;
17
+ /** Canvas height in pixels. Default: the composition's height. */
18
+ height?: number;
19
+ /** Where (0, 0) is. `'center'` is p5.brush's own; `'top-left'` translates so that (0, 0) is the top left corner. */
20
+ origin?: 'center' | 'top-left';
21
+ /** Paper colour for `brush.clear()`. Default: transparent. */
22
+ background?: string;
23
+ style?: CSSProperties;
24
+ }
25
+ /**
26
+ * A canvas that p5.brush draws into: `brush.load(canvas)` (never `createCanvas`), then each frame `clear`, `seed`,
27
+ * `noiseSeed`, `draw`, `render`.
28
+ *
29
+ * ```tsx
30
+ * <BrushCanvas seed={7} background="#f4efe6" origin="top-left" draw={(b, frame) => {
31
+ * b.set('HB', '#2f2a26', 1.4);
32
+ * b.line(120, 140, 120 + frame * 10, 260);
33
+ * }} />
34
+ * ```
35
+ */
36
+ export declare function BrushCanvas({ seed, draw, width, height, origin, background, style }: BrushCanvasProps): import("react").JSX.Element;
37
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,56 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // p5.brush for a frame-driven render. p5.brush draws on a canvas with its own WebGL, and keeps state between calls
3
+ // (the seed, the active brush, fill and hatch settings, the transform). A frame that draws from that state is not a
4
+ // function of the frame number. So each frame this component reseeds, clears, draws inside push/pop (the state a
5
+ // frame sets is dropped when it ends) and flushes, which makes a frame the same alone and in sequence.
6
+ //
7
+ // `p5.brush` is a peer dependency, used through its standalone build, and is never patched.
8
+ import { useLayoutEffect, useRef, useState } from 'react';
9
+ import { continueRender, delayRender, useCurrentFrame, useVideoConfig } from 'remotion';
10
+ import * as brushModule from 'p5.brush/standalone';
11
+ const brush = brushModule;
12
+ /**
13
+ * A canvas that p5.brush draws into: `brush.load(canvas)` (never `createCanvas`), then each frame `clear`, `seed`,
14
+ * `noiseSeed`, `draw`, `render`.
15
+ *
16
+ * ```tsx
17
+ * <BrushCanvas seed={7} background="#f4efe6" origin="top-left" draw={(b, frame) => {
18
+ * b.set('HB', '#2f2a26', 1.4);
19
+ * b.line(120, 140, 120 + frame * 10, 260);
20
+ * }} />
21
+ * ```
22
+ */
23
+ export function BrushCanvas({ seed, draw, width, height, origin = 'center', background, style }) {
24
+ const frame = useCurrentFrame();
25
+ const config = useVideoConfig();
26
+ const w = width ?? config.width;
27
+ const h = height ?? config.height;
28
+ const ref = useRef(null);
29
+ // Held until the first frame is drawn, so a render never reads the canvas before p5.brush has put anything on it.
30
+ const [handle] = useState(() => delayRender('p5.brush: loading'));
31
+ useLayoutEffect(() => {
32
+ const canvas = ref.current;
33
+ if (!canvas)
34
+ return;
35
+ brush.load(canvas);
36
+ if (background === undefined)
37
+ brush.clear();
38
+ else
39
+ brush.clear(background);
40
+ brush.seed(seed);
41
+ brush.noiseSeed(seed);
42
+ brush.push();
43
+ try {
44
+ if (origin === 'top-left')
45
+ brush.translate(-w / 2, -h / 2);
46
+ draw(brush, frame, { width: w, height: h });
47
+ brush.render();
48
+ }
49
+ finally {
50
+ brush.pop();
51
+ }
52
+ continueRender(handle);
53
+ });
54
+ return _jsx("canvas", { ref: ref, width: w, height: h, style: { width: w, height: h, display: 'block', ...style } });
55
+ }
56
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@kinetographdev/p5-brush",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "p5.brush for Kinetograph: a canvas that reseeds the brush and redraws from the frame number",
5
+ "license": "PolyForm-Small-Business-1.0.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/0xS4N4TG/kinetograph.git",
9
+ "directory": "packages/plugins/p5-brush"
10
+ },
11
+ "homepage": "https://github.com/0xS4N4TG/kinetograph#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/0xS4N4TG/kinetograph/issues"
14
+ },
15
+ "keywords": [
16
+ "video",
17
+ "remotion",
18
+ "motion-graphics",
19
+ "p5.brush",
20
+ "generative-art"
21
+ ],
22
+ "type": "module",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "default": "./dist/index.js"
27
+ }
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "!dist/**/*.map"
32
+ ],
33
+ "scripts": {
34
+ "build": "tsc -p tsconfig.json",
35
+ "test": "tsc -p tsconfig.test.json && vitest run --passWithNoTests"
36
+ },
37
+ "peerDependencies": {
38
+ "@kinetographdev/core": "^0.2.0",
39
+ "p5.brush": "^2.2.0",
40
+ "react": "^19.3.0"
41
+ },
42
+ "devDependencies": {
43
+ "p5.brush": "2.2.3",
44
+ "react": "19.3.1"
45
+ },
46
+ "engines": {
47
+ "node": ">=22"
48
+ },
49
+ "publishConfig": {
50
+ "access": "public"
51
+ }
52
+ }