Comments (4)
@BaileyMillerSSI you are correct that if the hashing function changes the outcomes will change.
I encourage you to look at the SlotMachine
class and its tests, but in essence our hashing works like this: given a collection of outcomes (e.g. avatar images) and a hashing function that returns an integer (e.g. "sum all the character codes in the string"), we get an instance that will return one of the outcomes when passed a string.
I hope that sets you on the right path. If so, please do close this issue.
The code is all right here, so I will again encourage you to browse the codebase if you have more questions. Thanks for your interest!
from avatars-api-middleware.
My friend is looking to do something similar for a school project so I am trying to help with the code. Your @slots
variable is an array of images, or in the test case file1, file2, file3, file4, file5
. Then you call the pull method with your input string, in the case of the demo website this can the username, or anything really.
Pull returns a variable out of the @slots
array of images, in the test case again file1, file2, file3, file4, file5
, and what you do is you go var eyes= SlotMachine.pull('inputString'); var nose = SlotMachine.pull('inputString');
where SlotMachine will be a different machine for each category, eyes, face, etc. Then at the end you have some code that creates an image by combining all these variables.
@rylnd Aside from the literal hashing function and the image creation code, did I get that correct?
from avatars-api-middleware.
@BaileyMillerSSI yes, I think you've got it.
The eyes/nose stuff is for the more complicated v2 endpoint with several slotMachine
instances for each part of the image, and would be closer to
var eyes = (new SlotMachine(eyesCollection)).pull('inputString');
var nose = (new SlotMachine(noseCollection)).pull('inputString');
The v1 endpoint is the simpler one that I'd suggest you start with; it does the "hash the string and pick an image file" logic, as opposed to building up the image programmatically. The general concept is the same in both cases, though.
Also, @itsthatguy just rewrote the code for es6, so I would suggest looking at the develop branch as opposed to master.
from avatars-api-middleware.
Closing this due to inactivity.
from avatars-api-middleware.
Related Issues (20)
- Identifier can result in a 404 HOT 2
- Library can't be installed HOT 5
- Difference between generated and result of link on the website HOT 1
- API Site is gone? HOT 17
- NestJS: requires a middleware function but got a undefined HOT 4
- I got an error when visiting adorable.io/.
- Make the repository name more descriptive. HOT 3
- Let's work together HOT 8
- Discussion: a better routing schema HOT 8
- Size parameter in URL does not work HOT 3
- CORS from github? HOT 3
- URL's not working all of a sudden, service seems to be down. HOT 3
- Discussion : Laravel Installation or Use HOT 1
- Empty response from server HOT 8
- module.exports missing HOT 5
- Can I use in mobile application? HOT 2
- Remove outdated/confusing server code
- Replace babel-watch due to slow security fixes HOT 1
- Replace imagemagick HOT 1
- extensions affect the returned avatar HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from avatars-api-middleware.