I have a requirement that by passing a name it should return an avatar icon contains the first letters of the words contained in that name.For instance, if I pass John Abraham it should return an icon 'JA'.I need to use that icon in an sapui5 control.I do not have any idea on this.How to implement this?Any help is appreciated.
I need avatar icon like this.You can see the icon with letter V in this.avatar icon
Thank You,
Forked @Sathvik Cheela code to meet your requirements:
You could create a custom UI5-control for that. It supports databinding too :)
Example on JSBin:
Check the demo here.
JS BIN
You can read more about canvas here
The canvas answeres are on the right track, but in your case you need a data url that you can assign to your controls
src
oricon
property.The
generateAvatar
function in the following example converts a name (string) to a image data url (contains the image as base64 gif in the url). The data url can be assigned to the Buttons icon property or any other image url property on a UI5 control. And you can even use it as a formatter function with databinding as in the following example.Example on JSBin