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

@britannica/pablito

v0.9.2

Published

<div align="center"> <h1>Pablito</h1> <blockquote>An HTML 5 drawing library that leverages <a href="http://fabricjs.com" target="_blank">FabricJS</a> for the majority of the features.</blockquote>

Downloads

17

Readme

📖 Original Source Information

This library is based largely off of the PBS Canvas-Drawing-Tool and the PBS fuzz-select depedency. You can learn more about PBS efforts on their Open PBS Blog. The PBS tool and most of it's features are derived from FabricJS the HTML5 canvas library.

It also uses the JS Library Boilerplate which makes it super easy to create a library using the latest tooling including Webpack 4 and Babel 7.

💻 Changes

This is more or less a straight port of the original library, but updated to use modern tooling in order for more rapid development. We have also added bug-fixes and custom code that makes our own drawing app perform more to our liking. The fuzzy-select package has been removed as a depency and instead moved into the project which while might not be the best practice speeds up our developent process signifigantly. The package is now on NPMJS and can be brought into your project via a simple import statement.

We have also removed the bundling of FabricJS from the library. FabricJS is almost impossible to build on our development machines and would have been a nightmare for our CI servers. We now instead include whatever version of FabricJS we desire in a script tag so that fabric is part of window.

🙋 The Big Question

Why didn't you fork the original project and make pull requests? This is an excellent question. We had first planned on doing that as we believe in contributing to other open source projects. Some of the things we really wanted, like the package to be imported frorm NPM would have been difficult to coordinate with the original developers. We also felt that we were making so many breaking changes that a pull-request into the original project would have been disastrous. Also time, we were on a very tight deadline for the project that makes use of this library.

⭐ Features

  • Importable from NPM
  • ES5 Module
  • Multiple brushes
  • Ability to control colors
  • Ability to add stickers and backgrounds
  • Erase tool
  • Fill tool
  • Undo and Redo
  • ...and more

📦 Getting Started

Pablito can be installed via NPM or Yarn:

npm i --save @britannica/pablito

yarn add @britannica/pablito

You must import the library into your code:

import Pablito from '@britannica/pablito

Do not forget to import FabricJs using a script tag somewhere in your application we have used CDNJS and it has worked well for us:

<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/2.4.2/fabric.min.js" integrity="sha256-em+qzEOePf0K/yI0PjRJnAEpxnDvBKEtvbSmDdK1hZM=" crossorigin="anonymous"></script>

Fabric is a huge library, so we recomend you use the minified build for production.

Initializing a Pablito instance requires that you pass in a config similar to this one taken from the PBS Canvas-Drawing-Tool documentation.

var stickerBook = new Pablito({
  // The containing element for the stickerbook
  container : container,

  // sticker configuration
  stickers: {
    // the available stickers that can be used
    enabled: [
      'path/to/first/image.png',
      'path/to/other/image.png'
    ],

    // styling options for sticker sizing controls (optional)
    controls: {
      cornerColor: 'rgba(0,0,0,0.5)',
      cornerSize: 20,
      hasBorders: true
    },

    // default positioning for stickers (provide whatever you need, the rest defaults to reasonable values)
    defaults: {
      x: 0, // if x and y defaults are not provided, you *must* provide them when calling placeSticker()
      y: 0,
      xScale: 1,
      yScale: 1,
      rotation: 0 // degrees
    }
  },


  background: {
    // the backgrounds that can be set
    enabled: [
        'first/bg.png',
        'other/bg.png'
    ],
    
    // the default background to use (can be null for empty background)
    default: 'first/bg.png'
  },

  brush: {
    // The available brushes. The list below has the all the currently available ones (at the time of writing)
    enabled: [
      'eraser',
      'bitmap',
      'bitmap-eraser',
      'fill',
      'marker',
      'pattern',
      'pencil',
      'spray',

      // a custom brush configured below
      'mycustombrush'
    ], 
    
    // The available brush widths (in pixels)
    widths: [1, 10],

    // The available colors to use, can be any valid CSS color
    colors: [
      '#0000FF',
      '#FF0000'
    ],

    // any custom brushes, the key of this object are the id to be used in the enabled list above, and the value must
    // be a subclass of fabric.BaseBrush (via fabric.util.createClass(fabric.BaseBrush, { }) )
    custom: {
      mycustombrush: MyCustomBrush
    }
  },

  // Whether or not to enable touch events
  mobileEnabled: true,

  // Whether or not to use default event handlers (see "Events" below)
  useDefaultEventHandlers: true
});

The rest of the documentation can be found in the Read Me file on the PBS Canvas-Drawing-Tool page.

Any additional functionality above and beyond what is listed there we will add here in the future.

✅ TODO

  • We broke all of the unit tests porting this over, at some point we would like to bring those over as well as time permits.
  • Improve performance of the Fill algorithm.
  • Remove a bunch of unecessary files that JS Library Boilerplate helpfully provides, but we don't need.
  • If FabricJS ever comes into a state where it can be built by mere mortals we would like to add that as a dependency.

👩🏼‍⚖️ Legal Stuff

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.