Skip to content

Commit 197ff5f

Browse files
committed
add ability to mix shapes/images
- refactor a bunch of functions - fix some performance/loop errors
1 parent 44e42d5 commit 197ff5f

File tree

11 files changed

+671
-621
lines changed

11 files changed

+671
-621
lines changed

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Change log
2+
## 1.1.0
3+
4+
- shapes and images can now be used together in an array to mix basic shapes and custom images;
5+
```js
6+
let mySparticles = new Sparticles( el, {
7+
8+
shape: ["circle", "image"],
9+
imageUrl: "./snowflake.png"
10+
11+
})
12+
```
13+
14+
- fixed some performance / looping errors
15+
- refactored/renamed a lot of prototype methods
16+
17+
- added the ability to write custom shapes in the off-chance that's
18+
better/easier than using a custom svg-image
19+
```js
20+
// first make sure the Sparticles is ready in page.
21+
// then you can add a custom offScreenCanvas before initialising.
22+
Sparticles.prototype.offScreenCanvas.doge = function(style, color, canvas) {
23+
// code for custom shape here, access to "this" object
24+
// which is the Sparticles prototype.
25+
};
26+
// then initialise your sparticles instance with the custom shape
27+
let mySparticles = new Sparticles( el, { shape: "doge" });
28+
29+
30+
```

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,16 @@ option | type | default
178178
**[maxAlpha](#maxAlpha)** | `Number` | `1` | maximum alpha value of every particle
179179
**[minSize](#minSize)** | `Number` | `1` | minimum size of every particle
180180
**[maxSize](#maxSize)** | `Number` | `10` | maximum size of every particle
181-
**[style](#style)** | `String` | `fill` | fill style of particles (one of; "fill", "stroke" or "both")
182181
**[bounce](#bounce)** | `Boolean` | `false` | should the particles bounce off edge of canvas
183182
**[drift](#drift)** | `Number` | `1` | the "driftiness" of particles which have a horizontal/vertical direction
184183
**[glow](#glow)** | `Number` | `0` | the glow effect size of each particle
185184
**[twinkle](#twinkle)** | `Boolean` | `false` | particles to exhibit an alternative alpha transition as "twinkling"
185+
**[style](#style)** | `String` | `fill` | fill style of particles (one of; "fill", "stroke" or "both")
186+
**[shape](#shape)** | `String`/`Array` | `circle` | shape of particles (any of; circle, square, triangle, diamond, line, image) or "random"
186187
**[color](#color)** | `String`/`Array` | `random` | css color as string, or array of color strings (can also be "random")
187188
**[randomColor](#randomColor)** | `Function` | `randomHsl()` | function for returning a random color when the color is set as "random"
188189
**[randomColorCount](#randomColorCount)** | `Function` | `randomHsl()` | function for returning a random color when the color is set as "random"
189-
**[shape](#shape)** | `String`/`Array` | `circle` | shape of particles (any of; circle, square, triangle, diamond, line, image) or "random"
190-
**[imageUrl](#imageUrl)** | `String`/`Array` | | if shape is "image", define an image url (can be data-uri, should be square (1:1 ratio))
190+
**[imageUrl](#imageUrl)** | `String`/`Array` | | if shape is "image", define an image url (can be data-uri, **should be square (1:1 ratio)**)
191191

192192
---
193193

@@ -411,8 +411,9 @@ particle shape from an image when combined with `imageUrl`](#imageUrl).
411411
Determine the custom image to be used for all the particles.
412412
If an array of urls (`[ "http://my.image/shape.png", "http://my.svg/shape.svg" ]`) is given, then each particle
413413
will be assigned a random image as it's shape from the array.
414+
<sup>**This image should be a square (1:1)**</sup>
414415

415-
This only applies [if the `shape` is set to `"image"`](#shape).
416+
`imageUrl` only has an effect [if a `shape` in the array is; `"image"`](#shape).
416417

417418
# methods
418419

0 commit comments

Comments
 (0)