{"id":18924133,"url":"https://github.com/hellsan631/material-avatar","last_synced_at":"2025-04-15T12:32:23.940Z","repository":{"id":57742069,"uuid":"41827970","full_name":"hellsan631/material-avatar","owner":"hellsan631","description":"Simple material design avatars using canvas","archived":false,"fork":false,"pushed_at":"2022-10-10T22:45:54.000Z","size":65,"stargazers_count":39,"open_issues_count":4,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T21:12:36.503Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://hellsan631.github.io/material-avatar/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hellsan631.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-02T21:10:29.000Z","updated_at":"2022-07-25T12:02:21.000Z","dependencies_parsed_at":"2022-08-31T04:21:56.939Z","dependency_job_id":null,"html_url":"https://github.com/hellsan631/material-avatar","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellsan631%2Fmaterial-avatar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellsan631%2Fmaterial-avatar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellsan631%2Fmaterial-avatar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellsan631%2Fmaterial-avatar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hellsan631","download_url":"https://codeload.github.com/hellsan631/material-avatar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249071456,"owners_count":21207992,"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":"2024-11-08T11:05:55.701Z","updated_at":"2025-04-15T12:32:23.698Z","avatar_url":"https://github.com/hellsan631.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"sample.png\" align=\"center\" alt=\"Material Avatar\" /\u003e\n\nSimple material design avatars using canvas\n\n### Enhanced by [BrowserStack](http://browserstack.com/)\n\n[![Code Climate](https://codeclimate.com/github/hellsan631/material-avatar/badges/gpa.svg)](https://codeclimate.com/github/hellsan631/material-avatar)\n[![License](http://img.shields.io/badge/License-MIT-blue.svg)](http://opensource.org/licenses/MIT) \n1.33kb gziped!\n\n====\n\nMaterial-Avatar is non-opinionated and only has a few small features. It was built to solve a larger problem. _How can I generate a good looking default avatar for a user?_.\n\nI got asked this question once, and there are a lot of other more complex implimentations out there, using bits and bobs to calculate a pixelated image, or grab sets of images from places, or use other web services. I like the way google approached the problem, creating a simple image with initials text.\n\nMaterial-Avatar uses HTML5 Canvas to fill an element with a random(ized) background color, [which uses this great module to find nice random colors](https://github.com/davidmerfield/randomColor), but has a fall-back just incase you don't include it.\n\n\u003e __Now Supports jQuery!__\n\n### Useage\n\n1. Install using __npm__, __bower__, or __download__.\n    ```bash\n    npm install --save material-avatar\n    bower install --save material-avatar\n    ```\n\n    And include your scripts,\n\n    ```html\n    \u003cscript src=\"vendor/material-avatar/material-avatar.min.js\"\u003e\u003c/script\u003e\n    ```\n\n2. Create a nice div and fill it with a name, or use the attribute __data-name__. _Note, material-avatar defaults to using the size provided by the style of the element on the page_\n    ```html\n    \u003cdiv class=\"default-profile-photo\" style=\"height:200px; width:200px;\"\u003e\n      Paul Gilbert\n    \u003c/div\u003e\n    ```\n\n3. Call __MaterialAvatar__ in somewhere on your page.\n    ```html\n    \u003cscript\u003e\n      MaterialAvatar(document.getElementsByClass('default-profile-photo'), options);\n\n      //or use jQuery\n\n      $('.default-profile-photo').materialAvatar(options);\n    \u003c/script\u003e\n    ```\n\n4. Profit.\n\n### Options\n\n\u003e __EffectName:__ \"default\" _(type)_\u003cbr/\u003e\n\u003e\tDescription\n\n1. __shape__ \"square\" _(string)_ \u003cbr/\u003e\nCan either be \"circle\" or \"square\", and will take that shape (more shapes in future updates!)\n\n2. __randomColor__ _(object)_ \u003cbr/\u003e\nSettings for using the [randomColor library](https://github.com/davidmerfield/randomColor)\n\n3. __backgroundColor__ _(string)_ \u003cbr/\u003e\nA hex string for a background color (i.e. '#f12a27'). If not set, one will be chosen at random, or from\na default colorPalette (which can be overridden)\n\n4. __textColor__ _(string)_ \u003cbr/\u003e\nA hex string for the text color (i.e. '#fff'). If not set, an accessable friendly color will be chosen\nbased on the background color (either '#222' or '#fff')\n\n5. __colorPalette__ _(array)_ \u003cbr/\u003e\nAn array of color hexes that can will be chosen from randomly as a fallback. Defaults can be found in\nthe material-avatar.js file.\n\n6. __fontSize__ _(number or function)_ \u003cbr/\u003e\nAn overriding size for font. This can either be a number, measured in px, or a function. If its a function,\nit will be sent two arguments, the height of the canvas, and the initials length, which can be used to\nreturn a calculated font size.\n\n7. __fontFamily__ \"Arial\" _(string)_ \u003cbr/\u003e\nThe chosen font family for generating the canvas initials font.\n\n8. __initials__ _(string)_ \u003cbr/\u003e\nA string of characters used as the initials for the avatar.\n\n9. __name__ _(string)_ \u003cbr/\u003e\nIn addition to being able to use the data-name attribute, or the innerHtml of an element, you can also pass\na name in the options, which will be broken down into the initial.\n\n[see sample](https://github.com/hellsan631/material-avatar/tree/master/sample) or [the live website](http://hellsan631.github.io/material-avatar/) for some examples.\n\n### Development\n\nIf you'd like to develop this little module a bit further, I use a nice gulp build process.\n\n__Get a localhost live-reload web-server running to develop the module__\n```\nnpm install\ngulp serve\n```\n\n__Before you push your changes, make sure to run the gulp build script__\n```\ngulp build\n```\n\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellsan631%2Fmaterial-avatar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhellsan631%2Fmaterial-avatar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellsan631%2Fmaterial-avatar/lists"}