Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pixer

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pixer

add pixelated canvas gradient between html elements

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Pixer

Automatically generate pixelated gradient between two block elements. Written in Typescript.

Getting started

Download this plugin from the Github repository or install it through this command:

$ npm install pixer --save

This library is also available through Bower package manager:

$ bower install pixer --save

Required assets

Set some CSS rules for the canvas elements we are going to use. These are some suggested classes:

.js-pixer {
	width: 100%;
	height: 80px;
}

.js-pixer--big {
	width: 100%;
	height: 120px;
}

.js-pixer--small {
	width: 100%;
	height: 40px;
}

Import the Pixer library:

<script src="path/to/dist/pixer.js"></script>

Required markup

Just put a canvas element having the data-pixer attribute in between the two block elements you want to apply the pixelated border to. It's mandatory to set a CSS property for the background of the two target elements:


<!-- target 1 -->
<div style="background:<COLOR>"></div>

<!-- the pixelated gradient border will be generated inside this canvas -->
<canvas data-pixer class="js-pixer"></canvas>

<!-- target 2 -->
<div style="background:<ANOTHER COLOR>"></div>

Start it up

This Javascript library is UMD compliant, so you can consume it even like this:

	var pixer = require('pixer');

	// Call the init function which returns the API object handler
	var pixerApi = pixer();

Or just get the global object bound to the window:

	var pixer = window.pixer;

	// Call the init function which returns the API object handler
	var pixerApi = pixer();

Set some options

At the moment the only customizable setting is the number of stripes that the pixelated border will be formed of. The default amount of stripes is 4.

You can set the custom amount of stripes by passing a valid JSON object into the data-pixer attribute:

<div id="target-1" style="background:<COLOR>"></div>
<canvas data-pixer='{"stripes":"4"}' class="js-pixer"></canvas>
<div id="target-2" style="background:<ANOTHER COLOR>"></div>

API

Available methods:

	var pixerApi = pixer();

	// Reflow all the pixelated borders in the page
	pixerApi.reflow();

AUTHORS

Giancarlo Soverini giancarlosoverini@gmail.com

LICENSE

AGPL-3.0

Keywords

FAQs

Package last updated on 08 Dec 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc