update docs

This commit is contained in:
Nolan Lawson 2016-01-16 14:50:40 -05:00
parent 519d5cc700
commit 43e8d08f02
23 changed files with 11654 additions and 533 deletions

View File

@ -120,9 +120,9 @@ Warning: this API uses [Promises](https://promisesaplus.com/), because it's not
* [binaryStringToBlob(binary, type)](#binaryStringToBlob)
* [blobToBase64String(blob)](#blobToBase64String)
* [dataURLToBlob(dataURL)](#dataURLToBlob)
* [imgSrcToDataURL(src, type, crossOrigin)](#imgSrcToDataURL)
* [canvasToBlob(canvas, type)](#canvasToBlob)
* [imgSrcToBlob(src, type, crossOrigin)](#imgSrcToBlob)
* [imgSrcToDataURL(src, type, crossOrigin, quality)](#imgSrcToDataURL)
* [canvasToBlob(canvas, type, quality)](#canvasToBlob)
* [imgSrcToBlob(src, type, crossOrigin, quality)](#imgSrcToBlob)
* [arrayBufferToBlob(buffer, type)](#arrayBufferToBlob)
* [blobToArrayBuffer(blob)](#blobToArrayBuffer)
@ -288,7 +288,7 @@ blobUtil.dataURLToBlob(dataURL).then(function (blob) {
```
<a name="imgSrcToDataURL"></a>
###imgSrcToDataURL(src, type, crossOrigin)
###imgSrcToDataURL(src, type, crossOrigin, quality)
Convert an image's <code>src</code> URL to a data URL by loading the image and painting
it to a <code>canvas</code>. Returns a Promise.
@ -301,6 +301,8 @@ will only paint the first frame of an animated GIF.
- type `string` | `undefined` - the content type (optional, defaults to 'image/png')
- crossOrigin `string` | `undefined` - for CORS-enabled images, set this to
'Anonymous' to avoid "tainted canvas" errors
- quality `number` | `undefined` - a number between 0 and 1 indicating image quality
if the requested type is 'image/jpeg' or 'image/webp'
**Returns**: `Promise` - Promise that resolves with the data URL string
@ -324,13 +326,15 @@ blobUtil.imgSrcToDataURL('http://some-other-site.com/img.jpg', 'image/jpeg',
```
<a name="canvasToBlob"></a>
###canvasToBlob(canvas, type)
###canvasToBlob(canvas, type, quality)
Convert a <code>canvas</code> to a <code>Blob</code>. Returns a Promise.
**Params**
- canvas `string`
- type `string` | `undefined` - the content type (optional, defaults to 'image/png')
- quality `number` | `undefined` - a number between 0 and 1 indicating image quality
if the requested type is 'image/jpeg' or 'image/webp'
**Returns**: `Promise` - Promise that resolves with the <code>Blob</code>
@ -357,7 +361,7 @@ blobUtil.canvasToBlob(canvas, 'image/webp').then(function (blob) {
```
<a name="imgSrcToBlob"></a>
###imgSrcToBlob(src, type, crossOrigin)
###imgSrcToBlob(src, type, crossOrigin, quality)
Convert an image's <code>src</code> URL to a <code>Blob</code> by loading the image and painting
it to a <code>canvas</code>. Returns a Promise.
@ -370,6 +374,8 @@ will only paint the first frame of an animated GIF.
- type `string` | `undefined` - the content type (optional, defaults to 'image/png')
- crossOrigin `string` | `undefined` - for CORS-enabled images, set this to
'Anonymous' to avoid "tainted canvas" errors
- quality `number` | `undefined` - a number between 0 and 1 indicating image quality
if the requested type is 'image/jpeg' or 'image/webp'
**Returns**: `Promise` - Promise that resolves with the <code>Blob</code>

Binary file not shown.

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

View File

@ -28,10 +28,9 @@
<article>
<pre class="prettyprint source linenums"><code>'use strict';
var utils = require('./utils');
/* jshint -W079 */
var Blob = require('blob');
var Promise = utils.Promise;
var Promise = require('pouchdb-promise');
//
// PRIVATE
@ -233,15 +232,17 @@ function dataURLToBlob(dataURL) {
* @param {string|undefined} type - the content type (optional, defaults to 'image/png')
* @param {string|undefined} crossOrigin - for CORS-enabled images, set this to
* 'Anonymous' to avoid "tainted canvas" errors
* @param {number|undefined} quality - a number between 0 and 1 indicating image quality
* if the requested type is 'image/jpeg' or 'image/webp'
* @returns {Promise} Promise that resolves with the data URL string
*/
function imgSrcToDataURL(src, type, crossOrigin) {
function imgSrcToDataURL(src, type, crossOrigin, quality) {
type = type || 'image/png';
return loadImage(src, crossOrigin).then(function (img) {
return imgToCanvas(img);
}).then(function (canvas) {
return canvas.toDataURL(type);
return canvas.toDataURL(type, quality);
});
}
@ -249,16 +250,18 @@ function imgSrcToDataURL(src, type, crossOrigin) {
* Convert a &lt;code>canvas&lt;/code> to a &lt;code>Blob&lt;/code>. Returns a Promise.
* @param {string} canvas
* @param {string|undefined} type - the content type (optional, defaults to 'image/png')
* @param {number|undefined} quality - a number between 0 and 1 indicating image quality
* if the requested type is 'image/jpeg' or 'image/webp'
* @returns {Promise} Promise that resolves with the &lt;code>Blob&lt;/code>
*/
function canvasToBlob(canvas, type) {
function canvasToBlob(canvas, type, quality) {
return Promise.resolve().then(function () {
if (typeof canvas.toBlob === 'function') {
return new Promise(function (resolve) {
canvas.toBlob(resolve, type);
canvas.toBlob(resolve, type, quality);
});
}
return dataURLToBlob(canvas.toDataURL(type));
return dataURLToBlob(canvas.toDataURL(type, quality));
});
}
@ -273,15 +276,17 @@ function canvasToBlob(canvas, type) {
* @param {string|undefined} type - the content type (optional, defaults to 'image/png')
* @param {string|undefined} crossOrigin - for CORS-enabled images, set this to
* 'Anonymous' to avoid "tainted canvas" errors
* @param {number|undefined} quality - a number between 0 and 1 indicating image quality
* if the requested type is 'image/jpeg' or 'image/webp'
* @returns {Promise} Promise that resolves with the &lt;code>Blob&lt;/code>
*/
function imgSrcToBlob(src, type, crossOrigin) {
function imgSrcToBlob(src, type, crossOrigin, quality) {
type = type || 'image/png';
return loadImage(src, crossOrigin).then(function (img) {
return imgToCanvas(img);
}).then(function (canvas) {
return canvasToBlob(canvas, type);
return canvasToBlob(canvas, type, quality);
});
}
@ -304,8 +309,14 @@ function arrayBufferToBlob(buffer, type) {
* @returns {Promise} Promise that resolves with the &lt;code>ArrayBuffer&lt;/code>
*/
function blobToArrayBuffer(blob) {
return blobToBinaryString(blob).then(function (binary) {
return binaryStringToArrayBuffer(binary);
return new Promise(function (resolve, reject) {
var reader = new FileReader();
reader.onloadend = function (e) {
var result = e.target.result || new ArrayBuffer(0);
resolve(result);
};
reader.onerror = reject;
reader.readAsArrayBuffer(blob);
});
}
@ -334,13 +345,13 @@ module.exports = {
</div>
<nav>
<h2><a href="index.html">Index</a></h2><h3>Global</h3><ul><li><a href="global.html#arrayBufferToBlob">arrayBufferToBlob</a></li><li><a href="global.html#base64StringToBlob">base64StringToBlob</a></li><li><a href="global.html#binaryStringToBlob">binaryStringToBlob</a></li><li><a href="global.html#blobToArrayBuffer">blobToArrayBuffer</a></li><li><a href="global.html#blobToBase64String">blobToBase64String</a></li><li><a href="global.html#blobToBinaryString">blobToBinaryString</a></li><li><a href="global.html#canvasToBlob">canvasToBlob</a></li><li><a href="global.html#createBlob">createBlob</a></li><li><a href="global.html#createObjectURL">createObjectURL</a></li><li><a href="global.html#dataURLToBlob">dataURLToBlob</a></li><li><a href="global.html#imgSrcToBlob">imgSrcToBlob</a></li><li><a href="global.html#imgSrcToDataURL">imgSrcToDataURL</a></li><li><a href="global.html#revokeObjectURL">revokeObjectURL</a></li></ul>
<h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#arrayBufferToBlob">arrayBufferToBlob</a></li><li><a href="global.html#base64StringToBlob">base64StringToBlob</a></li><li><a href="global.html#binaryStringToBlob">binaryStringToBlob</a></li><li><a href="global.html#blobToArrayBuffer">blobToArrayBuffer</a></li><li><a href="global.html#blobToBase64String">blobToBase64String</a></li><li><a href="global.html#blobToBinaryString">blobToBinaryString</a></li><li><a href="global.html#canvasToBlob">canvasToBlob</a></li><li><a href="global.html#createBlob">createBlob</a></li><li><a href="global.html#createObjectURL">createObjectURL</a></li><li><a href="global.html#dataURLToBlob">dataURLToBlob</a></li><li><a href="global.html#imgSrcToBlob">imgSrcToBlob</a></li><li><a href="global.html#imgSrcToDataURL">imgSrcToDataURL</a></li><li><a href="global.html#revokeObjectURL">revokeObjectURL</a></li></ul>
</nav>
<br clear="both">
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha10</a> on Tue Nov 04 2014 15:42:40 GMT-0500 (EST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-beta3</a> on Sat Jan 16 2016 14:43:19 GMT-0500 (EST)
</footer>
<script> prettyPrint(); </script>

View File

@ -1,57 +1,90 @@
@font-face {
font-family: 'Open Sans';
font-weight: normal;
font-style: normal;
src: url('../fonts/OpenSans-Regular-webfont.eot');
src:
local('Open Sans'),
local('OpenSans'),
url('../fonts/OpenSans-Regular-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/OpenSans-Regular-webfont.woff') format('woff'),
url('../fonts/OpenSans-Regular-webfont.svg#open_sansregular') format('svg');
}
@font-face {
font-family: 'Open Sans Light';
font-weight: normal;
font-style: normal;
src: url('../fonts/OpenSans-Light-webfont.eot');
src:
local('Open Sans Light'),
local('OpenSans Light'),
url('../fonts/OpenSans-Light-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/OpenSans-Light-webfont.woff') format('woff'),
url('../fonts/OpenSans-Light-webfont.svg#open_sanslight') format('svg');
}
html
{
overflow: auto;
background-color: #fff;
font-size: 14px;
}
body
{
font: 14px "DejaVu Sans Condensed", "Liberation Sans", "Nimbus Sans L", Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif;
line-height: 130%;
color: #000;
background-color: #fff;
font-family: 'Open Sans', sans-serif;
line-height: 1.5;
color: #4d4e53;
background-color: white;
}
a {
color: #444;
a, a:visited, a:active {
color: #0095dd;
text-decoration: none;
}
a:visited {
color: #444;
}
a:active {
color: #444;
a:hover {
text-decoration: underline;
}
header
{
display: block;
padding: 6px 4px;
padding: 0px 4px;
}
tt, code, kbd, samp {
font-family: Consolas, Monaco, 'Andale Mono', monospace;
}
.class-description {
font-style: italic;
font-family: Palatino, 'Palatino Linotype', serif;
font-size: 130%;
line-height: 140%;
margin-bottom: 1em;
margin-top: 1em;
}
.class-description:empty {
margin: 0;
}
#main {
float: left;
width: 100%;
width: 70%;
}
article dl {
margin-bottom: 40px;
}
section
{
display: block;
background-color: #fff;
padding: 12px 24px;
border-bottom: 1px solid #ccc;
margin-right: 240px;
margin-right: 30px;
}
.variation {
@ -68,26 +101,27 @@ section
nav
{
display: block;
float: left;
margin-left: -230px;
float: right;
margin-top: 28px;
width: 220px;
width: 30%;
box-sizing: border-box;
border-left: 1px solid #ccc;
padding-left: 9px;
padding-left: 16px;
}
nav ul {
font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif;
font-size: 100%;
line-height: 17px;
padding:0;
margin:0;
list-style-type:none;
padding: 0;
margin: 0;
list-style-type: none;
}
nav h2 a, nav h2 a:visited {
color: #A35A00;
text-decoration: none;
nav ul a, nav ul a:visited, nav ul a:active {
font-family: Consolas, Monaco, 'Andale Mono', monospace;
line-height: 18px;
color: #4D4E53;
}
nav h3 {
@ -98,18 +132,6 @@ nav li {
margin-top: 6px;
}
nav a {
color: #5C5954;
}
nav a:visited {
color: #5C5954;
}
nav a:active {
color: #5C5954;
}
footer {
display: block;
padding: 6px;
@ -118,39 +140,33 @@ footer {
font-size: 90%;
}
h1, h2, h3, h4 {
font-weight: 200;
margin: 0;
}
h1
{
font-size: 200%;
font-weight: bold;
letter-spacing: -0.01em;
margin: 6px 0 9px 0;
font-family: 'Open Sans Light', sans-serif;
font-size: 48px;
letter-spacing: -2px;
margin: 12px 24px 20px;
}
h2
h2, h3
{
font-size: 170%;
font-weight: bold;
letter-spacing: -0.01em;
margin: 6px 0 3px 0;
}
h3
{
font-size: 150%;
font-weight: bold;
letter-spacing: -0.01em;
margin-top: 16px;
margin: 6px 0 3px 0;
font-size: 30px;
font-weight: 700;
letter-spacing: -1px;
margin-bottom: 12px;
}
h4
{
font-size: 130%;
font-weight: bold;
letter-spacing: -0.01em;
margin-top: 16px;
margin: 18px 0 3px 0;
color: #A35A00;
font-size: 18px;
letter-spacing: -0.33px;
margin-bottom: 12px;
color: #4d4e53;
}
h5, .container-overview .subsection-title
@ -158,7 +174,7 @@ h5, .container-overview .subsection-title
font-size: 120%;
font-weight: bold;
letter-spacing: -0.01em;
margin: 8px 0 3px -16px;
margin: 8px 0 3px 0;
}
h6
@ -176,6 +192,11 @@ h6
text-decoration: none;
}
.clear
{
clear: both;
}
.important
{
font-weight: bold;
@ -191,11 +212,11 @@ h6
}
.name, .signature {
font-family: Consolas, "Lucida Console", Monaco, monospace;
font-family: Consolas, Monaco, 'Andale Mono', monospace;
}
.details { margin-top: 14px; border-left: 2px solid #DDD; }
.details dt { width:120px; float:left; padding-left: 10px; padding-top: 6px; }
.details dt { width: 120px; float: left; padding-left: 10px; padding-top: 6px; }
.details dd { margin-left: 70px; }
.details ul { margin: 0; }
.details ul { list-style-type: none; }
@ -205,14 +226,12 @@ h6
.description {
margin-bottom: 1em;
margin-left: -16px;
margin-top: 1em;
}
.code-caption
{
font-style: italic;
font-family: Palatino, 'Palatino Linotype', serif;
font-size: 107%;
margin: 0;
}
@ -230,14 +249,13 @@ h6
.prettyprint code
{
font-family: Consolas, 'Lucida Console', Monaco, monospace;
font-size: 100%;
line-height: 18px;
display: block;
padding: 4px 12px;
margin: 0;
background-color: #fff;
color: #000;
color: #4D4E53;
}
.prettyprint code span.line
@ -286,8 +304,8 @@ h6
}
.params .name, .props .name, .name code {
color: #A35A00;
font-family: Consolas, 'Lucida Console', Monaco, monospace;
color: #4D4E53;
font-family: Consolas, Monaco, 'Andale Mono', monospace;
font-size: 100%;
}
@ -316,13 +334,15 @@ h6
.params th, .props th { border-right: 1px solid #aaa; }
.params thead .last, .props thead .last { border-right: 1px solid #ddd; }
.params td.description > p:first-child
.params td.description > p:first-child,
.props td.description > p:first-child
{
margin-top: 0;
padding-top: 0;
}
.params td.description > p:last-child
.params td.description > p:last-child,
.props td.description > p:last-child
{
margin-bottom: 0;
padding-bottom: 0;

View File

@ -98,7 +98,7 @@
/*
pre.prettyprint {
background: white;
font-family: Menlo, Monaco, Consolas, monospace;
font-family: Consolas, Monaco, 'Andale Mono', monospace;
font-size: 12px;
line-height: 1.5;
border: 1px solid #ccc;

File diff suppressed because it is too large Load Diff