npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

just-sketch

v1.0.1

Published

just npm start kit.

Downloads

4

Readme

sketch

travis dependencies devDependencies

convert image to base64. Of course, you can also join images before convert.

Installation

$ yarn add just-sketch

Using Scenes

  • add watermark or frame.

result

sketch()
.import(imageURL) // import picture
.join(qrCodeURL, { // join qr code watermark
    width: 100,
    right: 40,
    bottom: 20,
}).rect({ // draw frame
    top: 280,
    left: 310,
    width: 120,
    height: 120,
    borderWidth: 1,
    borderColor: `red`,
}).export(base64 => {
    document.querySelector('.js-image').src = base64;
});

Usage

  • convert image to base64:

    import sketch from 'just-sketch';
    
    sketch()
    .import(imageURL)
    .export(base64 => {
        // get base64 here...
    }).catch(error => console.log(error));
  • picture synthesis:

    // Specifies the type of the exported picture
    sketch.imageType = 'png';
    sketch()
    .import(imageURL)
    .join(anotherURL)
    .export(base64 => {
        // get png base64 here...
    });
    
    // call `.join()` by chaining to join multi images
    sketch()
    .import(imageURL)
    .join(anotherURL, {
        top: 0,
        left: 0,
    }).join(anotherURL, {
        right: 0,
        bottom: 0,
    }).export(base64 => {
        // get base64 here...
    });

APIs

  • sketch([width: Number, height: Number]): width and height is optional, if they are passed in, then the size of exported base64 picture will depend on them. Otherwise, it will depend on the natural size of the imported picture in .import()

  • sketch.imageType: The type(png, jpeg) of exported base64 picture.(jpeg by default)

  • .import(imageURL: String): The size of the imported picture will determine the size of the final exported base64 picture.

  • .join(imageURL[, options: Object]): Join another picture to the imported picture.

    • size:
      • options.width: as you known.
      • options.height: as you known.
    • position:
      • options.top: as you known.
      • options.right: as you known.
      • options.bottom: as you known.
      • options.left: as you known.
  • .rect(options: Object): Join rectangle frame.

    • based on .join() options, the following options are added:
      • options.borderWidth:: as you known.
      • options.borderColor:: as you known.
      • options.backgroundColor:: as you known.

NOTE: Only adjacent sides position are accepted.

  • .export((base64, context, canvas) => {}): Export base64 picture, or use context and canvas to do whatever you can.

  • .catch(error => {}): try catch export.

License

Licensed under the MIT License