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

writing-pad

v1.6.1

Published

The writing-pad support some basic features.

Downloads

112

Readme

writing-pad

Dependencies

Usage

var container = document.querySelector("#container");
var board = writingPad.build(container);
board.show()
board.resize()

API

writingPad.build(element, opts)

Create an instance of writingPad class.

element

Append to element container.

opts

This is some optional settings.

  • opts.canvasWidth: Set canvas width. The canvas is able to view width as wide as container when canvas width is wider than container.
  • opts.controlsLayout: Set control panel's layout.(left 、 center 、 right or left-right)
  • opts.useMovingGesture: Set true if you want to use scale gesture.
  • opts.isDrawingOnEvent: Use event to draw canvas, if value is true.
  • opts.gridTipText: Set the tip text of grid's background.
  • opts.hintAreaText: Set hint that is able to write area.
  • opts.controls: The control panel's setup support DrawingEraserGridExtendVerticalCloseResetUndoRedoColor and so on.

Set color or lineWidth if you use Drawing. (ie {Drawing:{color:'rgba(0, 0, 255, 1)', lineWidth:'5'}}). The Reset feature is able to set disabledConfirmation and confirmationText. (ie {Reset:{confirmationText:'Do you want to clear board?'}})

See this if you want to use drawingboard.js controls.

WritingPad

resize()

Resize canvas width.

show()

Show a container.

hide()

Hide a container.

isHidden()

Return true if current container's display is none.

toImage()

Get a image of base64.

toBlob(type, quality):Promise

Get a blob.

board.toBlob().then(function(blob){
  //do something
});
load(resource)

Load a image to draw canvas, the resource can be url or img.

You must set img.crossOrigin and cross domain headers If your canvas need be exported what to use toBlob or toImage.

saveByKey(key)

Save current canvas to history by key.

restoreByKey(key, opts)

Draw a canvas from history's key.

  • opts.useHistoryHeight: Reset canvas height from history's canvas height, if useHistoryHeight is true.
deleteKey(key)

Delete history by key.

containKey(key)

Return true if this key exist history.

clearStorage()

Remove images from storage

openGridBg()

Show the grid background.

closeGridBg()

Hide the grid background.

toggleGridBg()

Show or hide the grid background.

getHeight()

Get the container's height.

extendHeight(height)

Increase container's height.

  • height: Input increasing values.
  • opts.slide: The slide height/200px if value is true.
  • opts.slideDuration: Durations are given in milliseconds. The default duration is 450.
  • opts.slideEl: The slideEl is element or css selector string which slides scroll top.
resetHeight(height)

Reset canvas height.

  • height: canvas height.
autosize(auto:boolean)

Resize canvas width when resize event is triggered by browser.

openHintWritingArea()

Open hint that is able to write area.

closeHintWritingArea()

Close hint that is able to write area.

getControl(id:string)

Get a control object by id. Be able to set id in opts.controls like this:

writingPad.build(container, {
  controls:[
    {
      Drawing: {
        id:'1'
      }
    }
  ]
})

Events

  • hide
  • startDrawing
  • stopDrawing
  • drawing
  • openColorPicker
  • closeColorPicker
  • clear
  • changeDrawingColor
  • changeDrawingSize