Giter Site home page Giter Site logo

avatargif's Introduction

自定义头像

项目前期准备

  • 使用到得库
    • BootStrap
    • jQuery
    • fabric.js
    • download.js
    • keypress.js
    • 打包工具: Parcel

尝试使用fabric.js

  var canvas = new fabric.Canvas('iAvatar');

    // create a rectangle object
    var rect = new fabric.Rect({
      left: 100,
      top: 100,
      fill: 'red',
      width: 20,
      height: 20
    });

    // "add" rectangle onto canvas
    canvas.add(rect);

使用CRM模式把代码先跑起来,实现canvas得任意拖拽。
将头像的图片信息以base64位输出

function downloadPic(){
  console.log( iAvatar )
}
// DataURL: Base64: balabala

好的是在farbic.js中可以将图片信息输出为base64

尝试使用download.js

在download.js中说明很多种给图片信息编译成图片的方式,包含有:

  • text string
  • text dataURL
  • text blob
  • text url
  • text UInt8 Array
    ...等等
download(document.documentElement.outerHTML, "dlHTML.html", "text/html");

以上述方法为例: 第一个参数为你要编译得信息,第二个参数为你保存图片的名称,第三个信息为保存成什么类型得文件,所以fabric.js给我们提供了dataURL,所以使用起来很方便

keypress.js 负责监听用户键盘事件

avatargif's People

Contributors

jackwong992 avatar

Watchers

James Cloos avatar

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.