Giter VIP home page Giter VIP logo

namedavatar's Issues

请教小程序中如何使用?

您好,我在页面中可以使用。请教,如何在小程序里使用您这个方法呢?非常棒。谢谢。

<!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>
```
`

谷歌72版生成图片显示异常

好似最新版本不能使用 data:image/svg+xml,<svg>......</svg>
可能需要使用base64编码后呈现
data:image/svg+xml;base64, ${Base64.encode('<svg>......</svg>')}

源码image.js中minFontSize的疑问?

/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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.