goldfire / CanvasInput

HTML5 Canvas Text Input
http://goldfirestudios.com/blog/108/CanvasInput-HTML5-Canvas-Text-Input
514 stars 123 forks source link

CanvasInput

Description

CanvasInput recreates and improves a full DOM element within HTML5 Canvas.

More documentation, examples and demos can be found at CanvasInput.

Features

Browser Compatibility

Tested in the following browsers/versions:

Documentation

Examples

Most basic, default text box:
<canvas id="canvas" width="200" height="50"></canvas>
var input = new CanvasInput({
  canvas: document.getElementById('canvas')
});
More styling options:
<canvas id="canvas" width="350" height="50"></canvas>
var input = new CanvasInput({
  canvas: document.getElementById('canvas'),
  fontSize: 18,
  fontFamily: 'Arial',
  fontColor: '#212121',
  fontWeight: 'bold',
  width: 300,
  padding: 8,
  borderWidth: 1,
  borderColor: '#000',
  borderRadius: 3,
  boxShadow: '1px 1px 0px #fff',
  innerShadow: '0px 0px 5px rgba(0, 0, 0, 0.5)',
  placeHolder: 'Enter message here...'
});

Properties

Methods

In addition to getter/setter methods for each of the above properties, the following methods have also been made available.

License

Copyright (c) 2013-2017 James Simpson and GoldFire Studios, Inc.

Released under the MIT License.