A new PHP framework for 5.4+
joaner / namedavatar Goto Github PK
View Code? Open in Web Editor NEWSVG Avatar generated by name text
Home Page: https://joaner.github.io/namedavatar/
SVG Avatar generated by name text
Home Page: https://joaner.github.io/namedavatar/
好似最新版本不能使用 data:image/svg+xml,<svg>......</svg>
可能需要使用base64编码后呈现
data:image/svg+xml;base64, ${Base64.encode('<svg>......</svg>')}
/namedavatar/src/vue/image.js
AvatarImage.prototype.getFontSize = function() {
var textWidth = this.name.length * (this.name.charCodeAt(0) < 256 ? 0.75 : 1.5)
var availableWidth = this.options.width || 32
var fontSize = Math.round(availableWidth / textWidth)
if (fontSize < this.options.minFontSize) {
this.name = this.name[0].toUpperCase()
fontSize = this.options.maxFontSize
} else if (fontSize > this.options.maxFontSize) {
fontSize = this.options.maxFontSize
}
return fontSize
}
其中,
if (fontSize < this.options.minFontSize) {
this.name = this.name[0].toUpperCase()
fontSize = this.options.maxFontSize
}
this.options.maxFontSize
是否应该为 this.options.minFontSize
?
你好,请问下vue2模式下怎么传options呢?
您好,我在页面中可以使用。请教,如何在小程序里使用您这个方法呢?非常棒。谢谢。
<!DOCTYPE html>
<html>
<head>
<!-- <script type="text/javascript" src="./dist/jquery-3.3.1.min.js"></script> -->
<script src="./dist/namedavatar.js"></script>
</head>
<body>
<!-- <img id="avatar1" alt="供" width="100" > -->
<img id="avatar1" src="./invalid.jpg" alt="Tom Hanks" width="100" style="border-radius: 100%">
<script>
namedavatar.config({
nameType: 'initials',
minFontSize:'20'
});
// fill single <img>
(function(img) {
namedavatar.setImg(img, img.alt)
})(document.getElementById('avatar1'))
</script>
</body>
</html>
```
`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.