jrainlau

lowpoly.js——能够生成 Low Poly 风格图片的 js 库

  •  2
     
  •   jrainlau · Oct 25, 2016 · 3739 views
    This topic created in 3496 days ago, the information mentioned may be changed or developed.

    https://github.com/jrainlau/LowPolifier

    What's it?

    lowpoly.js is a JS liberary which can style an image with Low Poly.

    Img

    Img

    Install

    npm install lowpoly
    

    Usage

    Note that lowpoly.js was written in ES6, it would work fine in the lastest version of morden browsers, or use it with Babel.

    import LowPoly from 'lowpoly'
    
    new LowPoly(src, config) .init() .then((data) => { ... })
    

    After the init() function, it will returns a promise, which includes a base64 source of the low-poly style image.

    Params

    | Param | Type | Description | | --- | --- | --- | | src | {String} | Address of an original image | | config | {Object} | The configuration object |

    The configuration object might take 6 properties:

    EDGE_DETECT_VALUE: Lower this to increase edge contrast sensitivity.

    POINT_RATE: Number of points distribution ratio of points (number) on the edge, detail, generated higher see console.

    POINT_MAX_NUM: Maximum points sampled. Higher = more detail.

    BLUR_SIZE: Smaller is more detailed.

    EDGE_SIZE: Larger is more detailed.

    PIXEL_LIMIT: Images may have this many pixels at most (width x height) or will be resampled. Have had no trouble setting this to ~10,000,000 or more.

    License

    MIT

    9 replies    2016-10-25 15:57:12 +08:00
    lxrmido
        1
    lxrmido  
       Oct 25, 2016
    不错
    Shared
        2
    Shared  
       Oct 25, 2016
    看楼主的代码学到了新知识。不过 blog 没 RSS 好可惜
    vimutt
        3
    vimutt  
       Oct 25, 2016
    感觉很不错啊 不熟悉 nodejs 能不能给个简单的可运行的实例啊
    Phariel
        4
    Phariel  
       Oct 25, 2016 via Android
    为什么代码注释是日文。
    hronro
        5
    hronro  
       Oct 25, 2016
    日本人?还是说这个不是楼主自己写的?
    jrainlau
        6
    jrainlau  
    OP
       Oct 25, 2016
    @Phariel 日文的那一段是 fork 的,仔细看注释有 fork 的地址哦
    jrainlau
        7
    jrainlau  
    OP
       Oct 25, 2016
    @hronro 日文的那一段是 fork 的,仔细看注释有 fork 的地址哦
    jrainlau
        8
    jrainlau  
    OP
       Oct 25, 2016
    @vimutt 这不是 node 呀,就一个普通的 js 库,不过是用了 es6 的特性而已,用法很简单的,看文档就可以啦
    ClassicOldSong
        9
    ClassicOldSong  
       Oct 25, 2016 via Android
    有意思,先 star
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2788 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 12:59 · PVG 20:59 · LAX 05:59 · JFK 08:59
    ♥ Do have faith in what you're doing.