Code Monkey home page Code Monkey logo

jquery-canvas-overlay's Introduction

jQuery Canvas Overlay

jQuery plugin to allow canvas overlays with cutout at the current cursor position. Actions of elements behind the overlay, are still working.

GitHub Logo

See live Demo

Getting Started

Download the production version or the development version.

In your web page:

<canvas id="overlay-canvas"></div>
<script src="jquery.js"></script>
<script src="dist/canvasoverlay.min.js"></script>
<script>
jQuery(function($) {
  $('#overlay-canvas').CanvasOverlay();
});
</script>

Documentation

The Plugin has 4 configuration parameters:

Argument: shadow
Default: 10
Data-Attribute: -
Description: This defines the size of the shadow around the cutout.

Argument: radius
Default: 150
Data-Attribute: -
Description: This defines the size / radius of the cutout itself.

Argument: ready
Default: null
Data-Attribute: -
Description: This is the callback for the onready event of the object. The callback has 1 callback variable function(element). Element is a jquery object of the parsed html element.

Argument: background
Default: 'rgba(0,0,0,1)'
Data-Attribute: -
Description: This allows to change the rendering color / pattern / gradient of the overlapping background.

Argument: figure
Default: null
Data-Attribute: -
Description: This allows to add image as cutout. Example added.

Examples

Background pattern instead of solid color

var ca = document.createElement('canvas');
  var cx	=	ca.getContext('2d');
	
	var img = new Image();
	img.src	=	'http://www.cw-internetdienste.de/overlay/assets/img/escheresque_ste.png';
	img.onload	=	function() {
		var pattern = cx.createPattern(img,'repeat')
		var overlayCanvas	=	$('#overlay').CanvasOverlay({shadow:50,radius:500,background:pattern});
	}

Individual image added as cutout

var ca = document.createElement('canvas');
  var cx	=	ca.getContext('2d');
	
	var img = new Image();
	img.src	=	'http://www.cw-internetdienste.de/overlay/assets/img/cursor.png';
	img.onload	=	function() {
		var overlayCanvas	=	$('#overlay').CanvasOverlay({shadow:50,radius:500,figure:img});
	}

Release History

  • 2013-07-08   v0.2.0   Second release. Enhanced blending mode and ability to add images as background and cutout.
  • 2013-06-25   v0.1.0   First initial release. Still experimental.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.