Skip to content

Commit

Permalink
Fixed a few bugs. Reduced p5 dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
acamposuribe committed Jan 12, 2024
1 parent 5b49463 commit 2b7a629
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 106 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
package-lock.json
package-lock.json
src/index_noP5.js
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ p5.brush.js provides a comprehensive API for creating complex drawings and effec
| | brush.clip() | | | brush.vertex() |
| | brush.noClip() | | | brush.endShape() |
| [Stroke Operations](#stroke-operations) | brush.set() | | | brush.polygon() |
| | brush.pick() | | [Configuration](#optional-configuration) | brush.config() |
| | brush.pick() | | [Configuration](#optional-configuration) | brush.seed() |
| | brush.stroke() | | | brush.load() |
| | brush.noStroke() | | | brush.preload() |
| | brush.strokeWeight()| | | brush.colorCache() |
Expand Down Expand Up @@ -866,18 +866,15 @@ These three functions perform similarly to the p5.js beginShape(), vertex(), and

This section covers functions for initializing the drawing system, preloading required assets, and configuring system behavior. By default, the library works without executing these functions, but you might want to configure them to your liking.

- `brush.config(objct = {})`
- **Description**: Sets custom configuration for the drawing system. It allows the overriding of the default randomness source by specifying a custom function.
- `brush.seed(seed)`
- **Description**: Sets a custom seed for deterministic drawing results.
- **Parameters**:
- `objct` (Object): Configuration object with properties. Default is `{}`.
- `objct.R` (Function): Optional custom random number generator function.
- **Example**: To use a deterministic random number generator, such as one from a generative art platform like fx(hash), you might configure your system as follows:
- `seed` (String | Number): A seed.
- **Example**:
```javascript
brush.config({
R: () => $fx.random()
});
brush.seed('hello');
```
Replace `$fx.random()` with the actual function provided by the platform. By default, if `objct.R` is not provided, `p5.brush.js` uses p5's `random()` function, which allows for the use of `randomSeed()` to set the seed for randomness.
Replace `hello` with the actual seed.

---

Expand Down
2 changes: 1 addition & 1 deletion dist/p5.brush.js

Large diffs are not rendered by default.

17 changes: 11 additions & 6 deletions example/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ let y_values = []

function setup () {

randomSeed(12323)
brush.seed(121233)
C.createCanvas()
background("#e2e7dc")
angleMode(RADIANS)
Expand All @@ -83,7 +85,6 @@ function setup () {
y_values[i] = random(width)
}

brush.load()

/*
brush.field("seabed")
Expand All @@ -94,9 +95,12 @@ function setup () {
brush.flowLine(30,60+i*10,195,0)
i++
}
*/

brush.noStroke()

brush.gravity(0,height)

brush.fill("black", 60)
brush.bleed(0.3)
brush.beginShape(0.5)
Expand All @@ -105,6 +109,7 @@ function setup () {
brush.vertex(150,150)
brush.vertex(50,150)
brush.endShape(CLOSE)


brush.fill("blue", 60)
brush.beginShape(0.5)
Expand All @@ -113,17 +118,17 @@ function setup () {
brush.vertex(200,150)
brush.vertex(100,150)
brush.endShape(CLOSE)
*/
brush.noFill()


}

function draw() {

background("#e2e7dc")
//background("#e2e7dc")
translate(-width/2,-height/2)
strokeWeight(2)
//brush.fill("#ff2702",70)
brush.set("HB", "black", 1)
brush.bleed(0.4)
brush.beginShape(1)
for (let i = 0; i < 6; i++) {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "p5.brush",
"version": "1.1",
"version": "1.1.0",
"description": "Unlock custom brushes, natural fill effects and intuitive hatching in p5.js",
"main": "src/index.js",
"module": "src/index.js",
Expand Down Expand Up @@ -30,11 +30,12 @@
},
"homepage": "https://p5-brush.cargo.site/",
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"rollup": "^4.9.4",
"rollup-plugin-cleanup": "^3.2.1"
},
"peerDependencies": {
"p5": "^1.9.0"
}
}
}
13 changes: 10 additions & 3 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import terser from '@rollup/plugin-terser';
import cleanup from 'rollup-plugin-cleanup';
import resolve from '@rollup/plugin-node-resolve';

const config = {
input: 'src/index.js',
Expand All @@ -10,9 +11,15 @@ const config = {
format: 'umd',
name: 'brush',
},
plugins: [terser(), cleanup({
comments: "none",
})],
plugins: [
resolve({
browser: true
}),
terser(),
cleanup({
comments: "none",
})
],
};

export default config;
Loading

0 comments on commit 2b7a629

Please sign in to comment.