Skip to content

Commit

Permalink
Updates to fill function + new scale() + bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
acamposuribe committed Nov 24, 2023
1 parent a39be6b commit bb50e71
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 92 deletions.
79 changes: 49 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ p5.brush.js provides a comprehensive API for creating complex drawings and effec
| [Utility](#utility-functions) | brush.push() | | [Hatch Operations](#hatch-operations) | brush.hatch() |
| | brush.pop() | | | brush.noHatch() |
| | brush.rotate() | | | brush.setHatch() |
| | brush.reDraw() | | [Geometry](#geometry) | brush.point() |
| | brush.reBlend() | | | brush.line() |
| [Vector-Fields](#vector-fields) | brush.field() | | | brush.flowLine() |
| | brush.noField() | | | brush.beginStroke() |
| | brush.refreshField()| | | brush.segment() |
| | brush.listFields() | | | brush.endStroke() |
| | brush.addField() | | | brush.spline() |
| [Brush Management](#brush-management) | brush.scale() | | | brush.plot() |
| | brush.box() | | | brush.rect() |
| | brush.scale() | | [Geometry](#geometry) | brush.point() |
| | brush.reDraw() | | | brush.line() |
| | brush.reBlend() | | | brush.flowLine() |
| [Vector-Fields](#vector-fields) | brush.field() | | | brush.beginStroke() |
| | brush.noField() | | | brush.segment() |
| | brush.refreshField()| | | brush.endStroke() |
| | brush.listFields() | | | brush.spline() |
| | brush.addField() | | | brush.plot() |
| [Brush Management](#brush-management) | brush.box() | | | brush.rect() |
| | brush.add() | | | brush.circle() |
| | brush.clip() | | | brush.beginShape() |
| | brush.noClip() | | | brush.vertex() |
Expand All @@ -95,8 +95,9 @@ p5.brush.js provides a comprehensive API for creating complex drawings and effec
| | brush.noStroke() | | | brush.load() |
| | brush.strokeWeight()| | | brush.preload() |
| [Fill Operations](#fill-operations) | brush.fill() | | | brush.colorCache() |
| | brush.noFill() | | [Classes](#exposed-classes) | brush.Polygon() |
| | brush.bleed() | | | brush.Plot() |
| | brush.noFill() | | | brush.scaleBrushes()|
| | brush.bleed() | | [Classes](#exposed-classes) | brush.Polygon() |
| | brush.fillTexture() | | | brush.Plot() |
| | | | | brush.Position() |

---
Expand All @@ -119,6 +120,11 @@ p5.brush.js provides a comprehensive API for creating complex drawings and effec

---

- `brush.scale(scale)`
- **Description**: Increases or decreases the size of shapes and strokes by expanding or contracting vertices. Objects always scale from their relative origin to the coordinate system. Scale values are specified as decimal percentages. For example, the function call scale(2.0) increases the dimension of a shape by 200%. Transformations apply to everything that happens after and subsequent calls to the function multiply the effect. For example, calling scale(2.0) and then scale(1.5) is the same as scale(3.0).

---

- `brush.reDraw()`
- **Description**: p5.brush uses several buffers and caches to make the drawing operations more performant. Use the reDraw() function if you want to force noBlend brushes to be drawn into the canvas. This function is designed to help maintain the correct draw order for the different strokes and shapes.

Expand Down Expand Up @@ -248,20 +254,6 @@ Functions for managing brush behaviors and properties.

---

- `brush.scale(scale)`
- **Description**: Adjusts the global scale of all standard brush parameters, including weight, vibration, and spacing, based on the given scaling factor. This function is specifically designed to affect dafault brushes, allowing for uniform scaling across various brush types.
- **Parameters**:
- `scale` (Number): The scaling factor to be applied to the brush parameters.
- **Note**: This function only impacts the default brushes. Custom brushes may not be affected by this scaling, since they are defined per case basis.
- **Usage**:
```javascript
// Scale all standard brushes by a factor of 1.5
brush.scale(1.5);
```
Using `brush.scale()`, you can easily adjust the size and spacing characteristics of standard brushes in your project, providing a convenient way to adapt to different canvas sizes or artistic styles.

---

- `brush.box()`
- **Description**: Retrieves an array containing the unique names of all available brushes. This function is useful for accessing the variety of brushes included in the library, which range from different pencil types to markers and specialized brushes like the hatch brush. Of course, the function will also return the custom brushes you've created.
- **Returns**: `Array<string>` - An array listing the names of all brushes.
Expand Down Expand Up @@ -490,16 +482,29 @@ The Fill Management section focuses on managing fill properties for shapes, enab

---

- `brush.bleed(_i, _texture, _borderIntensity)`
- `brush.bleed(strength, direction)`
- **Description**: Adjusts the bleed and texture levels for the fill operation, mimicking the behavior of watercolor paints. This function adds a natural and organic feel to digital artwork.
- **Parameters**:
- `_i` (Number): The intensity of the bleed effect, capped at 0.5.
- `_texture` (Number): The texture level of the watercolor effect, ranging from 0 to 1.
- `strength` (Number): The intensity of the bleed effect, capped at 0.5.
- `direction` (String): Optional. "out" or "in". Defines the direction of the bleed effect
- `_borderIntensity` (Number): The intensity of the border watercolor effect, ranging from 0 to 1.
- **Usage**:
```javascript
// Set the bleed intensity and texture for a watercolor effect
brush.bleed(0.3, 0.7, 0.5);
// Set the bleed intensity and direction for a watercolor effect
brush.bleed(0.3, "out");
```

---

- `brush.fillTexture(textureStrength, borderIntensity)`
- **Description**: Adjusts the texture levels for the fill operation, mimicking the behavior of watercolor paints. This function adds a natural and organic feel to digital artwork.
- **Parameters**:
- `textureStrength` (Number): The texture of the fill effect, ranging from 0 to 1.
- `borderIntensity` (Number): The intensity of the border watercolor effect, ranging from 0 to 1.
- **Usage**:
```javascript
// Set the fill texture and border intensity
brush.fillTexture(0.6, 0.4);
```

---
Expand Down Expand Up @@ -864,6 +869,20 @@ This section covers functions for initializing the drawing system, preloading re

---

- `brush.scale(scale)`
- **Description**: Adjusts the global scale of all standard brush parameters, including weight, vibration, and spacing, based on the given scaling factor. This function is specifically designed to affect default brushes only, allowing for uniform scaling across various brush types.
- **Parameters**:
- `scale` (Number): The scaling factor to be applied to the brush parameters.
- **Note**: This function only impacts the default brushes. Custom brushes may not be affected by this scaling, since they are defined per case basis.
- **Usage**:
```javascript
// Scale all standard brushes by a factor of 1.5
brush.scale(1.5);
```
Using `brush.scale()`, you can easily adjust the size and spacing characteristics of standard brushes in your project, providing a convenient way to adapt to different canvas sizes or artistic styles.

---

<sub>[back to table](#table-of-functions)</sub>
### Exposed Classes

Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>p5.brush.js Example</title>
<script src="./dependencies/p5.min.js"></script>
<script src="./dependencies/spectral.min.js"></script>
<script src="./p5.brush.js"></script>
<script src="./p5.brush.min.js"></script>
<link rel="stylesheet" href="./style.css">
</head>
<body>
Expand Down
Loading

0 comments on commit bb50e71

Please sign in to comment.