Giter Site home page Giter Site logo

img-remarker's Introduction

img-remarker

LICENSE

Remark a img as canvas.

Installation

$ npm install --save img-remarker

Usage

In script way:

<!-- app/src/index.html -->
<body>
    <div id="app"></div>
    <!-- ... -->
    <script src="../node_modules/img-remarker/dist/ImgRemarker.min.js"></script>
    <script>
        const m = new ImgRemarker({
            width: '300px',
            height: '350px',
            text: 'HelloWorld',
            textHeight: '50px',
            textStyle: 'normal',
            textSize: '20px',
            textFamily: '黑体',
            textColor: '#333',
            imgSrc: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR-K60SA0cvvaFJEXlH60k98JjYOvlidFZJSq_aiI5bFGstxp3k4Q'
        });
        m.mount('#app');
    </script>
</body>

In es6 way:

// main.js
import ImgRemarker from 'img-remarker';

const m = new ImgRemarker({
    width: '300px',
    height: '350px',
    text: 'HelloWorld',
    textHeight: '50px',
    textStyle: 'normal',
    textSize: '20px',
    textFamily: '黑体',
    textColor: '#333',
    imgSrc: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR-K60SA0cvvaFJEXlH60k98JjYOvlidFZJSq_aiI5bFGstxp3k4Q'
});
m.mount('#app');

And yes, the npm package supports the UMD format.

Options

You can pass an configuring obejct to ImgRemarker instance.

Name Default Description
width (the width of original img, px) the width of remarked img which generated
height (the height of original img, px) the height of remarked img which generated
text '' string that you wanna remark on the original img, and the character '\n' will indicate that text should wrap
textHeight '30px' the height of rigion where you wanna put the text
textStyle 'normal' the style of text
textSize '14px' the size of text
textLineHeight '14px' the line height of text, if not defined, it will equal textSize
textFamily 'SimHei' the font-family of text
textColor '#000000' the color of text
imgSrc '' the src of original img, could be normal or baseurl

License

MIT © Hades He

img-remarker's People

Contributors

ironmaxtory avatar hadeshe93 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.