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

object_painter

v1.0.0

Published

A javascript library to paint objects with canvas

Downloads

1

Readme

object_painter

object_painter is an open source project made with javascript that allows an application to paint an object image in different layers with canvas.

Designed for

Websites and applications who wants to deliver better experiences for your customers and any project that wants to implement an environment painter with a simple way to integrate using an easy api for that.

Features

  • Loads a environment image
  • Add Layer mask to proccess object colors
  • Set fit mode to adapt the image on canvas
  • Set layer color to paint object
  • Get layer colors data
  • Get a specific layer color
  • Reset colors and fit

Installation

This is a pure javascript library available through the npm registry and no dependency is required.

$ npm install object_painter

To test the lib you must to have a local server like http://localhost because canvas check the CORS from image file data, so you can try:

$ npx http-server -c-1 -a localhost -p 8000 

Usage

<canvas width="400" height="300" id="room"></canvas>
<script src="node_modules/object_painter/src/object_painter.js"></script>
<script>
    const objectPainter = new ObjectPainter({
        canvasId: "room",
        fit: "stretch"
    });
    objectPainter.loadBackground('path/to/yours/image.jpg')
    objectPainter.addLayer('layer_name', 'path/to/yours/mask.png')
</script>

To have a great experience, your masks must have the same size of your original loaded image as background.

API

  • Before call any function, be sure to create an instance of library:
    const objectPainter = new ObjectPainter({
        //The canvas identifier
        canvasId: "room",        
        //The image size adapter
        fit: "stretch",
    });
  • Loading a environment image as background:
    objectPainter.loadBackground('path/to/yours/environment.png')
  • Loading a mask image to proccess colors:
    objectPainter.addLayer('layer_name','path/to/yours/mask.png')
  • Setting the paint color to a specific layer:
    objectPainter.setLayerColor('layer_name', "red")
  • Setting the fit image adaptation to deliver a good experience:
    objectPainter.setFit("stretch") //stretch, contain, cover
  • Get a specific layer painted color:
    objectPainter.getLayerColor("layer_name")
  • Get all layer painted colors:
    objectPainter.getColors()
  • Remove all painted colors:
    objectPainter.reset()

License

MIT