🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@blinkmobile/canvas-manipulation

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blinkmobile/canvas-manipulation

Helper functions for manipulating a HTMLCanvasElement

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

blinkmobile / canvas-manipulation npm AppVeyor Status Travis CI Status

Helper functions for manipulating a HTMLCanvasElement

Installation

  • Install module via npm

    npm install @blinkmobile/canvas-manipulation --save
    
  • Load this library and use a build step e.g. webpack or browserify

    const canvasManipulation = require('@blinkmobile/canvas-manipulation')
    // OR
    import canvasManipulation from '@blinkmobile/canvas-manipulation'
    
  • Or alternatively, load the script straight into a browser and access canvasManipulation globally

    <!DOCTYPE html>
    <html>
    <head>
      <script src="node_modules/@blinkmobile/canvas-manipulation/dist/canvas-manipulation.js"></script>
    </head>
    <body>
      ...
      <script>
        // available via window.canvasManipulation
      </script>
    </body>
    </html>
    

Usage

drawImageCentered(canvas: HTMLCanvasElement, image: CanvasImageSource)
  • Draw a CanvasImageSource onto a HTMLCanvasElement

  • Will center the image onto the canvas if the image is smaller than the canvas

  • Will scale the image down to fit if the image is bigger than the canvas

resize(canvas: HTMLCanvasElement, width: number, height: number, scaleDown: boolean) : boolean
  • Change the width and/or height of a CanvasImageSource while preserving the current content

  • Returns true if the canvas content has been preserved

  • If scaleDown is false and the content is larger than the newly sized canvas, the content will not be preserved

toDataURLCropped(canvas: HTMLCanvasElement, type: string, encoderOptions: number) : string

Example

Check the example directory for a working example or run it yourself:

  • Install Node 6.x or higher

  • Clone this repository

    Note: The master branch can contain undocumented or backward compatibility breaking changes. You should checkout the latest release before running the demo.

  • Install dependencies

    npm install
    
  • Start demo

    npm start
    

Keywords

HTML5

FAQs

Package last updated on 10 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts