@dicebear/core 5.1.3 → 5.1.5
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/lib/core.js +3 -3
- package/lib/schema.js +3 -4
- package/package.json +3 -3
package/lib/core.js
CHANGED
|
@@ -5,13 +5,13 @@ import * as license from './utils/license.js';
|
|
|
5
5
|
import { toFormat } from '@dicebear/converter';
|
|
6
6
|
import { getBackgroundColors } from './utils/color.js';
|
|
7
7
|
export function createAvatar(style, options = {}) {
|
|
8
|
-
var _a, _b, _c, _d;
|
|
8
|
+
var _a, _b, _c, _d, _e;
|
|
9
9
|
options = mergeOptions(style, options);
|
|
10
10
|
const prng = createPrng(options.seed);
|
|
11
11
|
const result = style.create({ prng: prng, options });
|
|
12
12
|
const { primary: primaryBackgroundColor, secondary: secondaryBackgroundColor, } = getBackgroundColors(prng, (_a = options.backgroundColor) !== null && _a !== void 0 ? _a : []);
|
|
13
13
|
const backgroundType = prng.pick((_b = options.backgroundType) !== null && _b !== void 0 ? _b : [], 'solid');
|
|
14
|
-
const backgroundRotation = prng.
|
|
14
|
+
const backgroundRotation = prng.integer(((_c = options.backgroundRotation) === null || _c === void 0 ? void 0 : _c.length) ? Math.min(...options.backgroundRotation) : 0, ((_d = options.backgroundRotation) === null || _d === void 0 ? void 0 : _d.length) ? Math.max(...options.backgroundRotation) : 0);
|
|
15
15
|
if (options.size) {
|
|
16
16
|
result.attributes.width = options.size.toString();
|
|
17
17
|
result.attributes.height = options.size.toString();
|
|
@@ -33,7 +33,7 @@ export function createAvatar(style, options = {}) {
|
|
|
33
33
|
result.body = svgUtils.addBackground(result, primaryBackgroundColor, secondaryBackgroundColor, backgroundType, backgroundRotation);
|
|
34
34
|
}
|
|
35
35
|
if (options.radius || options.clip) {
|
|
36
|
-
result.body = svgUtils.addViewboxMask(result, (
|
|
36
|
+
result.body = svgUtils.addViewboxMask(result, (_e = options.radius) !== null && _e !== void 0 ? _e : 0);
|
|
37
37
|
}
|
|
38
38
|
// Reduces the occurrence of ID collisions when rendering multiple avatars on one HTML page.
|
|
39
39
|
result.body = svgUtils.randomizeIds(result, prng.seed);
|
package/lib/schema.js
CHANGED
|
@@ -50,13 +50,12 @@ export const schema = {
|
|
|
50
50
|
type: 'array',
|
|
51
51
|
items: {
|
|
52
52
|
type: 'integer',
|
|
53
|
-
minimum:
|
|
53
|
+
minimum: -360,
|
|
54
54
|
maximum: 360,
|
|
55
55
|
},
|
|
56
|
+
maxItems: 2,
|
|
56
57
|
default: [
|
|
57
|
-
0,
|
|
58
|
-
160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290,
|
|
59
|
-
300, 310, 320, 330, 340, 350,
|
|
58
|
+
0, 360,
|
|
60
59
|
],
|
|
61
60
|
},
|
|
62
61
|
translateX: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dicebear/core",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.5",
|
|
4
4
|
"description": "An avatar library for designers and developers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"avatar",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"test": "uvu tests"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@dicebear/converter": "^5.1.
|
|
35
|
+
"@dicebear/converter": "^5.1.5"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@tsconfig/recommended": "^1.0.1",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "cd0ba272057aeb321db66e63a483d55557082344"
|
|
50
50
|
}
|