-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4a2ea1b
Showing
17 changed files
with
255 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = [ | ||
'Blank', | ||
'Kurt', | ||
'Prescription01', | ||
'Prescription02', | ||
'Round', | ||
'Sunglasses', | ||
'Wayfarers' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = [ | ||
'BlazerShirt', | ||
'BlazerSweater', | ||
'CollarSweater', | ||
'GraphicShirt', | ||
'Graphics', | ||
'Hoodie', | ||
'Overall', | ||
'ShirtCrewNeck', | ||
'ShirtScoopNeck', | ||
'ShirtVNeck' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module.exports = [ | ||
'Black', | ||
'Blue01', | ||
'Blue02', | ||
'Blue03', | ||
'Gray01', | ||
'Gray02', | ||
'Heather', | ||
'PastelBlue', | ||
'PastelGreen', | ||
'PastelOrange', | ||
'PastelRed', | ||
'PastelYellow', | ||
'Pink', | ||
'Red', | ||
'White' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = [ | ||
'Skull', | ||
'SkullOutline', | ||
'Bat', | ||
'Cumbia', | ||
'Deer', | ||
'Diamond', | ||
'Hola', | ||
'Selena', | ||
'Pizza', | ||
'Resist', | ||
'Bear' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = [ | ||
'Angry', | ||
'AngryNatural', | ||
'Default', | ||
'DefaultNatural', | ||
'FlatNatural', | ||
'RaisedExcited', | ||
'RaisedExcitedNatural', | ||
'SadConcerned', | ||
'SadConcernedNatural', | ||
'UnibrowNatural', | ||
'UpDown', | ||
'UpDownNatural', | ||
'FrownNatural' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = [ | ||
'Close', | ||
'Cry', | ||
'Default', | ||
'Dizzy', | ||
'EyeRoll', | ||
'Happy', | ||
'Hearts', | ||
'Side', | ||
'Squint', | ||
'Surprised', | ||
'Wink', | ||
'WinkWacky' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = [ | ||
'Blank', | ||
'BeardMedium', | ||
'BeardLight', | ||
'BeardMagestic', | ||
'MoustacheFancy', | ||
'MoustacheMagnum' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = [ | ||
'Auburn', | ||
'Black', | ||
'Blonde', | ||
'BlondeGolden', | ||
'Brown', | ||
'BrownDark', | ||
'Platinum', | ||
'Red' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = [ | ||
'Auburn', | ||
'Black', | ||
'Blonde', | ||
'BlondeGolden', | ||
'Brown', | ||
'BrownDark', | ||
'PastelPink', | ||
'Platinum', | ||
'Red', | ||
'SilverGray' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module.exports = [ | ||
'Black', | ||
'Blue01', | ||
'Blue02', | ||
'Blue03', | ||
'Gray01', | ||
'Gray02', | ||
'Heather', | ||
'PastelBlue', | ||
'PastelGreen', | ||
'PastelOrange', | ||
'PastelRed', | ||
'PastelYellow', | ||
'Pink', | ||
'Red', | ||
'White' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = [ | ||
'Concerned', | ||
'Default', | ||
'Disbelief', | ||
'Eating', | ||
'Grimace', | ||
'Sad', | ||
'ScreamOpen', | ||
'Serious', | ||
'Smile', | ||
'Tongue', | ||
'Twinkle', | ||
'Vomit' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = [ | ||
'Tanned', | ||
'Yellow', | ||
'Pale', | ||
'Light', | ||
'Brown', | ||
'DarkBrown', | ||
'Black' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module.exports = [ | ||
'NoHair', | ||
'Eyepatch', | ||
'Hat', | ||
'Hijab', | ||
'Turban', | ||
'WinterHat1', | ||
'WinterHat2', | ||
'WinterHat3', | ||
'WinterHat4', | ||
'LongHairBigHair', | ||
'LongHairBob', | ||
'LongHairBun', | ||
'LongHairCurly', | ||
'LongHairCurvy', | ||
'LongHairDreads', | ||
'LongHairFrida', | ||
'LongHairFro', | ||
'LongHairFroBand', | ||
'LongHairNotTooLong', | ||
'LongHairShavedSides', | ||
'LongHairMiaWallace', | ||
'LongHairStraight', | ||
'LongHairStraight2', | ||
'LongHairStraightStrand', | ||
'ShortHairDreads01', | ||
'ShortHairDreads02', | ||
'ShortHairFrizzle', | ||
'ShortHairShaggy', | ||
'ShortHairShaggyMullet', | ||
'ShortHairShortCurly', | ||
'ShortHairShortFlat', | ||
'ShortHairShortRound', | ||
'ShortHairShortWaved', | ||
'ShortHairSides', | ||
'ShortHairTheCaesar', | ||
'ShortHairTheCaesarSidePart' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const accessories = require('./../data/accessories') | ||
const clothes = require('./../data/clothes') | ||
const clothesColor = require('./../data/clothesColor') | ||
const clothesGraphic = require('./../data/clothesGraphic') | ||
const eyebrows = require('./../data/eyebrow') | ||
const eyes = require('./../data/eyes') | ||
const facialHair = require('./../data/facialHair') | ||
const facialHairColors = require('./../data/facialHairColor') | ||
const hairColors = require('./../data/hairColor') | ||
const hatColors = require('./../data/hatColor') | ||
const mouth = require('./../data/mouth') | ||
const skin = require('./../data/skin') | ||
const top = require('./../data/top') | ||
|
||
const getRandom = (length) => { | ||
return Math.floor(Math.random() * length) | ||
} | ||
|
||
const generateRandomAvatar = (avatarType) => (fileType = '', width = '') => { | ||
const accessory = accessories[getRandom(accessories.length)] | ||
const facialHairStyle = facialHair[getRandom(facialHair.length)] | ||
const facialHairColor = facialHairColors[getRandom(facialHairColors.length)] | ||
const hatColor = hatColors[getRandom(hatColors.length)] | ||
const hairColor = hairColors[getRandom(hairColors.length)] | ||
const clothingColor = clothesColor[getRandom(clothesColor.length)] | ||
const clothingGraphic = clothesGraphic[getRandom(clothesGraphic.length)] | ||
const clothing = clothes[getRandom(clothes.length)] | ||
const eyebrow = eyebrows[getRandom(eyebrows.length)] | ||
const eyesStyle = eyes[getRandom(eyes.length)] | ||
const mouthStyle = mouth[getRandom(mouth.length)] | ||
const skinStyle = skin[getRandom(skin.length)] | ||
const topStyle = top[getRandom(top.length)] | ||
|
||
let avatarStyle = 'Transparent' | ||
if (Math.floor(Math.random() * 2) === 1) { | ||
avatarStyle = 'Circle' | ||
} | ||
|
||
return `https://avataaars.io/${fileType}/${width}?avatarStyle=${avatarType || avatarStyle}&topType=${topStyle}&accessoriesType=${accessory}&hairColor=${hairColor}&hatColor=${hatColor}&facialHairType=${facialHairStyle}&facialHairColor=${facialHairColor}&clotheType=${clothing}&clotheColor=${clothingColor}&graphicType=${clothingGraphic}&eyeType=${eyesStyle}&eyebrowType=${eyebrow}&mouthType=${mouthStyle}&skinColor=${skinStyle}` | ||
} | ||
|
||
module.exports = { generateRandomAvatar } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const { generateRandomAvatar } = require('./generator/generateAvatar') | ||
|
||
module.exports = { | ||
generateRandomAvatar | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "generate-avataaars", | ||
"version": "0.0.1", | ||
"description": "An avataaars generator api base node.", | ||
"main": "index.js", | ||
"author": "Ruby Rose", | ||
"license": "MIT", | ||
"scripts": { | ||
"test": "node test/index.js" | ||
}, | ||
"devDependencies": {}, | ||
"dependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const { generateRandomAvatar } = require('../generator/generateAvatar') | ||
|
||
const avatar = generateRandomAvatar('Circle')('png', 200) | ||
|
||
console.log(avatar) |