Latest Socket ResearchMalicious Chrome Extension Performs Hidden Affiliate Hijacking.Details
Socket
Book a DemoInstallSign in
Socket

get-context

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-context

Chainable canvas.

Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

get-context.js

Chainable canvas context api wrapper.

Build Status NPM version Dependency Status Bitdeli Badge

Install

With Node.js:

$ npm install get-context

With Bower:

$ bower install shannonmoeller/get-context

With Component:

$ component install shannonmoeller/get-context

API

getContext(element, type)

Creates an instance of a chainable canvas 2D-context api wrapper.

var canvas = document.createElement('canvas');
var context = require('get-context')(canvas);

context
    .set({
        strokeStyle: '#0000ff',
        lineCap: 'round'
    })
    .beginPath()
        .arc(75, 75, 50, 0, Math.PI * 2, true) // Outer circle
        .moveTo(110, 75)
        .arc(75, 75, 35, 0, Math.PI, false)    // Mouth (clockwise)
        .moveTo(65,65)
        .arc(60, 65, 5, 0, Math.PI * 2, true)  // Left eye
        .moveTo(95,65)
        .arc(90, 65, 5, 0, Math.PI * 2, true)  // Right eye
    .stroke();

.get(key)

Gets a single context property.

context.get('fillStyle');
// returns #000000

.get(array)

Gets multiple context properties.

context.get(['fillStyle', 'strokeStyle']);
// returns { fillStyle: '#000000', strokeStyle: '#000000' }

.set(key, value)

Sets a single context property.

context.set('fillStyle', '#FF0000');
// returns context

.set(object)

Sets multiple context properties.

context.set({
    fillStyle: '#FF0000',
    strokeStyle: '#00FF00'
});
// returns context

Test

$ npm test

browser support

License

MIT

Keywords

canvas

FAQs

Package last updated on 06 Dec 2013

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