{"id":26880006,"url":"https://github.com/mobilpadde/my-avatars","last_synced_at":"2025-06-20T09:04:50.947Z","repository":{"id":57306016,"uuid":"418266343","full_name":"Mobilpadde/my-avatars","owner":"Mobilpadde","description":null,"archived":false,"fork":false,"pushed_at":"2021-10-18T05:03:52.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-03T14:26:48.513Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mobilpadde.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-17T22:02:50.000Z","updated_at":"2021-10-18T05:03:54.000Z","dependencies_parsed_at":"2022-09-06T19:40:23.976Z","dependency_job_id":null,"html_url":"https://github.com/Mobilpadde/my-avatars","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Mobilpadde/my-avatars","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mobilpadde%2Fmy-avatars","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mobilpadde%2Fmy-avatars/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mobilpadde%2Fmy-avatars/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mobilpadde%2Fmy-avatars/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mobilpadde","download_url":"https://codeload.github.com/Mobilpadde/my-avatars/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mobilpadde%2Fmy-avatars/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260915853,"owners_count":23082036,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-31T13:34:32.077Z","updated_at":"2025-06-20T09:04:45.937Z","avatar_url":"https://github.com/Mobilpadde.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [my-avatars](https://www.npmjs.com/package/my-avatars)\n\nGenerate unique avatars of off your own image files!\n\n## Docs\n\n- `Item`\n  - `new Item(path, opts)`\n    - `path` is the path to the image\n    - `opts`\n      - `x`: `Number` - x-coord to place the image\n      - `y`: `Number` - y-coord to place the image\n      - `check`: `Boolean` - check if the image can be found - required to `replace`-colors\n      - `replace`: `Array` of `Object`'s - filled with colors to replace from and to\n        - `from`: `String` - color to replace from, in the format of `r,g,b` - e.g. `128,128,128`\n        - `to`: `String` - color to replace to, in the format of `r,g,b` - e.g. `128,128,128`\n- `Layer`\n  - `new Layer(name, idx)`\n    - `name`: `String` - a friendly name to recognise\n    - `idx`: `Number` - the z-index of the layer\n- `Generator`\n  - `new Generator(width, height, parentElm)`\n    - `width`: `Number` - width of the avatar\n    - `height`: `Number` - height of the avatar\n    - `parentElm`: `Element` - element to place avatar within\n\n## Usage\n\n### Installing\n\nFirst install `my-avatars` by running `npm i my-avatars`\n\n### Import\n\nNow you'll need to import `{ Generator, Layer, Item }` from `my-avatars` in your `js`-file.\n\n### Building\n\nTo build the generator, you'll have to have some images at hand. These should be made into `Item`'s, by `new Item('./images/face.png')`.\n\nNext, we'll need a `Layer`: `new Layer('faces', 0)`, this layer should have a name - for your own convenience - and an id, which can correspond to the z-index in css.\n\n\u003e NB: No two layers can't have the same index.\n\nNext-up, we'll need to pass in all of the `Item`'s, like so: `faceLayer.addItem(item)`.\n\n### Generator\n\nNow for the magical part, the `Generator`. Start by creating a new `Generator`, by `new Generator(400, 400, app)`. Whereas the first `400` is the width of the avatar, next is the height and last argument is the parent element of, to which the avatar-canvas should be injected.\n\nIf all of this doesn't make sense. Check out the [example](#example)\n\n## Example\n\nCheck [main.js](./main.js), to run the example use `npm run dev`. Or read this [article](https://madco.me/generate-16-unique-avatar-faces-from-40-lines-of-easy-code)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmobilpadde%2Fmy-avatars","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmobilpadde%2Fmy-avatars","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmobilpadde%2Fmy-avatars/lists"}