diff --git a/examples/cli.js b/examples/cli.js
index 9928d93a..48356ae7 100644
--- a/examples/cli.js
+++ b/examples/cli.js
@@ -1,9 +1,7 @@
-const QRCode = require('../lib')
-
+import * as QRCode from '../lib/index.js'
QRCode.toString('yo yo yo', function (error, data) {
if (error) {
throw new Error(error)
}
-
console.log(data)
})
diff --git a/examples/clientsideserver.js b/examples/clientsideserver.js
index 612a4643..facbfeca 100644
--- a/examples/clientsideserver.js
+++ b/examples/clientsideserver.js
@@ -1,44 +1,36 @@
-const express = require('express')
-const app = express()// .createServer()
-const http = require('http')
-const fs = require('fs')
-const QRCode = require('../lib')
-const canvasutil = require('canvasutil')
-const { createCanvas, loadImage } = require('canvas')
-
-const path = require('path')
-
+import express from 'express'
+import http from 'http'
+import fs from 'fs'
+import * as QRCode from '../lib/index.js'
+import canvasutil from 'canvasutil'
+import canvas from 'canvas'
+import path from 'path'
+const app = express() // .createServer()
+const { createCanvas, loadImage } = canvas
// app.use(express.methodOverride())
// app.use(express.bodyParser())
// app.use(app.router)
// app.use(express.static(path.resolve(__dirname, '..')))
-
app.get('/qrcode.js', (req, res) => {
res.set('content-type', 'text/javascript')
fs.createReadStream(path.join(__dirname, '..', 'build', 'qrcode.js')).pipe(res)
})
-
app.get('/qrcode.tosjis.js', (req, res) => {
res.set('content-type', 'text/javascript')
fs.createReadStream(path.join(__dirname, '..', 'build', 'qrcode.tosjis.js')).pipe(res)
})
-
app.get('/', function (req, res) {
fs.readFile(path.join(__dirname, 'clientside.html'), function (err, data) {
res.send(data ? data.toString() : err)
})
})
-
const effectHandlers = {}
-
app.get('/generate', function (req, res) {
const q = req.query || {}
-
let effect = q.effect || 'plain'
if (!effectHandlers[effect]) {
effect = 'plain'
}
-
effectHandlers[effect](q, function (error, canvas) {
if (!error) {
canvas.toBuffer(function (err, buf) {
@@ -55,22 +47,18 @@ app.get('/generate', function (req, res) {
}
})
})
-
effectHandlers.node = function (args, cb) {
args.src = path.join(__dirname, 'images', 'node_logo.png')
this.image(path.join(args, cb))
}
-
effectHandlers.npm = function (args, cb) {
args.src = path.join(__dirname, 'images', 'npm_logo.png')
this.image(args, cb)
}
-
effectHandlers.bacon = function (args, cb) {
args.src = path.join(__dirname, 'images', 'bacon-love.png')
this.image(args, cb)
}
-
effectHandlers.rounded = function (args, cb) {
const canvas = createCanvas(200, 200)
QRCode.toCanvas(canvas, args.text || '', function (err) {
@@ -78,7 +66,6 @@ effectHandlers.rounded = function (args, cb) {
cb(err, canvas)
return
}
-
const tpx = new canvasutil.PixelCore()
const luma709Only = canvasutil.conversionLib.luma709Only
const up = []
@@ -94,12 +81,9 @@ effectHandlers.rounded = function (args, cb) {
let l
let d
let corner = 0
-
tpx.threshold = 100
-
tpx.iterate(canvas, function (px, i, len, pixels, w, h, pixelCore) {
corner = 0
-
// is dark
if (luma709Only(px.r, px.g, px.b) < pixelCore.threshold) {
if (i - w > 0) {
@@ -109,7 +93,6 @@ effectHandlers.rounded = function (args, cb) {
up[2] = pixels[upPx + 2]
// console.log('up',up);
}
-
if (i + w <= len) {
downPx = (i + w) * 4
down[0] = pixels[downPx + 0]
@@ -117,7 +100,6 @@ effectHandlers.rounded = function (args, cb) {
down[2] = pixels[downPx + 2]
// console.log('down',down);
}
-
// have left pixel but no wrapping
if (i % w !== 0) {
leftPx = (i - 1) * 4
@@ -126,7 +108,6 @@ effectHandlers.rounded = function (args, cb) {
left[2] = pixels[leftPx + 2]
// console.log('left',left);
}
-
if (i % w !== w - 1) {
rightPx = (i + 1) * 4
right[0] = pixels[rightPx + 0]
@@ -134,12 +115,10 @@ effectHandlers.rounded = function (args, cb) {
right[2] = pixels[rightPx + 2]
// console.log('right',right);
}
-
r = rightPx ? luma709Only(right[0], right[1], right[2]) : 0
t = upPx ? luma709Only(up[0], up[1], up[2]) : 0
l = leftPx ? luma709Only(left[0], left[1], left[2]) : 0
d = downPx ? luma709Only(down[0], down[1], down[2]) : 0
-
if (l > pixelCore.threshold) { // if left is light and i am dark
if (t > pixelCore.threshold) { // if top is light and i am dark
corner = 1
@@ -155,7 +134,6 @@ effectHandlers.rounded = function (args, cb) {
corner = 1
}
}
-
if (corner) {
px.a = 50
}
@@ -164,63 +142,51 @@ effectHandlers.rounded = function (args, cb) {
cb(null, canvas)
})
}
-
effectHandlers.remoteImage = function (args, cb) {
let src = args.src
let domain
let uri
-
if (!src) {
cb(new Error('src required'), null)
} else {
if (src.indexof('://') !== -1) {
src = src.split('://').unshift()
const parts = src.split('/')
-
domain = parts.shift()
uri = parts.join('/')
}
}
-
if (!domain || !uri) {
cb(new Error('missing domain or uri ' + args.src))
return
}
-
const options = {
host: domain,
port: 80,
path: uri,
method: 'GET'
}
-
const req = http.request(options, function (res) {
if (res.statusCode < 200 || res.statusCode > 299) {
cb(new Error('http ' + res.statusCode + ' response code'), null)
return
}
-
res.setEncoding('utf8')
-
let data = ''
res.on('data', function (chunk) {
data += chunk
console.log('BODY: ' + chunk)
})
-
res.on('complete', function () {
cb(null, data)
})
-
res.on('error', function (error) {
cb(error, null)
- cb = function () {}
+ cb = function () { }
})
})
-
req.end()
}
-
effectHandlers.image = function (args, cb) {
loadImage(args.src || '').then((img) => {
const convert = canvasutil.conversionLib
@@ -230,7 +196,6 @@ effectHandlers.image = function (args, cb) {
cb(err, false)
return
}
-
const codeCtx = canvas.getContext('2d')
const frame = codeCtx.getImageData(0, 0, canvas.width, canvas.width)
const tpx = new canvasutil.PixelCore()
@@ -238,13 +203,10 @@ effectHandlers.image = function (args, cb) {
const ctx = baconCanvas.getContext('2d')
const topThreshold = args.darkThreshold || 25
const bottomThreshold = args.lightThreshold || 75
-
tpx.threshold = 50
-
// scale image
let w = canvas.width
let h = canvas.height
-
if (img.width > img.height) {
w = w * (canvas.height / h)
h = canvas.height
@@ -253,20 +215,16 @@ effectHandlers.image = function (args, cb) {
w = canvas.width
}
ctx.drawImage(img, 0, 0, w, h)
-
try {
tpx.iterate(baconCanvas, function (px, i, l, pixels, w, h, pixelCore) {
const luma = (0.2125 * px.r + 0.7154 * px.g + 0.0721 * px.b)
const codeLuma = convert.luma709Only(frame.data[i * 4], frame.data[i * 4 + 1], frame.data[i * 4 + 2])
let yuv
let rgb
-
if (codeLuma > pixelCore.threshold) {
if (luma < bottomThreshold) {
yuv = convert.rgbToYuv(px.r, px.g, px.b)
-
rgb = convert.yuvToRgb(bottomThreshold, yuv[1], yuv[2])
-
px.r = rgb[0]
px.g = rgb[1]
px.b = rgb[2]
@@ -275,9 +233,7 @@ effectHandlers.image = function (args, cb) {
} else {
if (luma > topThreshold) {
yuv = convert.rgbToYuv(px.r, px.g, px.b)
-
rgb = convert.yuvToRgb(topThreshold, yuv[1], yuv[2])
-
px.r = rgb[0]
px.g = rgb[1]
px.b = rgb[2]
@@ -287,14 +243,12 @@ effectHandlers.image = function (args, cb) {
} catch (e) {
cb(err, false)
}
-
cb(null, baconCanvas)
})
}, (error) => {
cb(error, null)
})
}
-
effectHandlers.plain = function (args, cb) {
const canvas = createCanvas(200, 200)
const text = args.text || ''
@@ -302,6 +256,5 @@ effectHandlers.plain = function (args, cb) {
cb(err, canvas)
})
}
-
app.listen(3031)
console.log('listening on 3031')
diff --git a/examples/save.js b/examples/save.js
index fa334e55..7c58fba0 100644
--- a/examples/save.js
+++ b/examples/save.js
@@ -1,5 +1,4 @@
-const QRCode = require('../lib')
-
+import * as QRCode from '../lib/index.js'
const path = './tmp.png'
QRCode.toFile(path, 'life of the party bros', {
color: {
@@ -7,6 +6,6 @@ QRCode.toFile(path, 'life of the party bros', {
light: '#0000' // Transparent background
}
}, function (err) {
- if (err) throw err
+ if (err) { throw err }
console.log('saved.')
})
diff --git a/examples/server.js b/examples/server.js
index 6007dba0..9549d7fa 100644
--- a/examples/server.js
+++ b/examples/server.js
@@ -1,35 +1,31 @@
-const QRCode = require('../lib')
-const http = require('http')
-
+import * as QRCode from '../lib/index.js'
+import http from 'http'
function testQRCode (req, res) {
res.writeHead(200, { 'Content-Type': 'text/html' })
-
const jungleBook = "The moonlight was blocked out of the mouth of the cave, for Shere Khan's\n" +
- 'great square head and shoulders were thrust into the entrance. Tabaqui,\n' +
- 'behind him, was squeaking: "My lord, my lord, it went in here!"\n' +
- '\n' +
- '"Shere Khan does us great honor," said Father Wolf, but his eyes were\n' +
- 'very angry. "What does Shere Khan need?"\n' +
- '\n' +
- "\"My quarry. A man's cub went this way,\" said Shere Khan. \"Its parents\n" +
- 'have run off. Give it to me."\n' +
- '\n' +
- "Shere Khan had jumped at a woodcutter's campfire, as Father Wolf had\n" +
- 'said, and was furious from the pain of his burned feet. But Father Wolf\n' +
- 'knew that the mouth of the cave was too narrow for a tiger to come in\n' +
- "by. Even where he was, Shere Khan's shoulders and forepaws were cramped\n" +
- "for want of room, as a man's would be if he tried to fight in a barrel.\n" +
- '\n' +
- '"The Wolves are a free people," said Father Wolf. "They take orders from\n' +
- "the Head of the Pack, and not from any striped cattle-killer. The man's\n" +
- 'cub is ours--to kill if we choose."'
-
+ 'great square head and shoulders were thrust into the entrance. Tabaqui,\n' +
+ 'behind him, was squeaking: "My lord, my lord, it went in here!"\n' +
+ '\n' +
+ '"Shere Khan does us great honor," said Father Wolf, but his eyes were\n' +
+ 'very angry. "What does Shere Khan need?"\n' +
+ '\n' +
+ "\"My quarry. A man's cub went this way,\" said Shere Khan. \"Its parents\n" +
+ 'have run off. Give it to me."\n' +
+ '\n' +
+ "Shere Khan had jumped at a woodcutter's campfire, as Father Wolf had\n" +
+ 'said, and was furious from the pain of his burned feet. But Father Wolf\n' +
+ 'knew that the mouth of the cave was too narrow for a tiger to come in\n' +
+ "by. Even where he was, Shere Khan's shoulders and forepaws were cramped\n" +
+ "for want of room, as a man's would be if he tried to fight in a barrel.\n" +
+ '\n' +
+ '"The Wolves are a free people," said Father Wolf. "They take orders from\n' +
+ "the Head of the Pack, and not from any striped cattle-killer. The man's\n" +
+ 'cub is ours--to kill if we choose."'
// QRCode.QRCodeDraw.color.dark = '#d4d4d4';
QRCode.toDataURL(jungleBook, function (err, url) {
- if (err) console.log('error: ' + err)
+ if (err) { console.log('error: ' + err) }
res.end("
node-qrcode
")
})
}
-
http.createServer(testQRCode).listen(3030)
console.log('test server started on port 3030')
diff --git a/examples/vendors/excanvas/excanvas.compiled.js b/examples/vendors/excanvas/excanvas.compiled.js
index a34ca1da..788c2d79 100644
--- a/examples/vendors/excanvas/excanvas.compiled.js
+++ b/examples/vendors/excanvas/excanvas.compiled.js
@@ -11,25 +11,319 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
-document.createElement("canvas").getContext||(function(){var s=Math,j=s.round,F=s.sin,G=s.cos,V=s.abs,W=s.sqrt,k=10,v=k/2;function X(){return this.context_||(this.context_=new H(this))}var L=Array.prototype.slice;function Y(b,a){var c=L.call(arguments,2);return function(){return b.apply(a,c.concat(L.call(arguments)))}}var M={init:function(b){if(/MSIE/.test(navigator.userAgent)&&!window.opera){var a=b||document;a.createElement("canvas");a.attachEvent("onreadystatechange",Y(this.init_,this,a))}},init_:function(b){b.namespaces.g_vml_||
-b.namespaces.add("g_vml_","urn:schemas-microsoft-com:vml","#default#VML");b.namespaces.g_o_||b.namespaces.add("g_o_","urn:schemas-microsoft-com:office:office","#default#VML");if(!b.styleSheets.ex_canvas_){var a=b.createStyleSheet();a.owningElement.id="ex_canvas_";a.cssText="canvas{display:inline-block;overflow:hidden;text-align:left;width:300px;height:150px}g_vml_\\:*{behavior:url(#default#VML)}g_o_\\:*{behavior:url(#default#VML)}"}var c=b.getElementsByTagName("canvas"),d=0;for(;d','","");this.element_.insertAdjacentHTML("BeforeEnd",t.join(""))};i.stroke=function(b){var a=[],c=P(b?this.fillStyle:this.strokeStyle),d=c.color,f=c.alpha*this.globalAlpha;a.push("g.x)g.x=e.x;if(h.y==null||e.yg.y)g.y=e.y}}a.push(' ">');if(b)if(typeof this.fillStyle=="object"){var m=this.fillStyle,r=0,n={x:0,y:0},o=0,q=1;if(m.type_=="gradient"){var t=m.x1_/this.arcScaleX_,E=m.y1_/this.arcScaleY_,p=this.getCoords_(m.x0_/this.arcScaleX_,m.y0_/this.arcScaleY_),
-z=this.getCoords_(t,E);r=Math.atan2(z.x-p.x,z.y-p.y)*180/Math.PI;if(r<0)r+=360;if(r<1.0E-6)r=0}else{var p=this.getCoords_(m.x0_,m.y0_),w=g.x-h.x,x=g.y-h.y;n={x:(p.x-h.x)/w,y:(p.y-h.y)/x};w/=this.arcScaleX_*k;x/=this.arcScaleY_*k;var R=s.max(w,x);o=2*m.r0_/R;q=2*m.r1_/R-o}var u=m.colors_;u.sort(function(ba,ca){return ba.offset-ca.offset});var J=u.length,da=u[0].color,ea=u[J-1].color,fa=u[0].alpha*this.globalAlpha,ga=u[J-1].alpha*this.globalAlpha,S=[],l=0;for(;l')}else a.push('');else{var K=this.lineScale_*this.lineWidth;if(K<1)f*=K;a.push("')}a.push("");this.element_.insertAdjacentHTML("beforeEnd",a.join(""))};i.fill=function(){this.stroke(true)};i.closePath=function(){this.currentPath_.push({type:"close"})};i.getCoords_=function(b,a){var c=this.m_;return{x:k*(b*c[0][0]+a*c[1][0]+c[2][0])-v,y:k*(b*c[0][1]+a*c[1][1]+c[2][1])-v}};i.save=function(){var b={};O(this,b);this.aStack_.push(b);this.mStack_.push(this.m_);this.m_=y(I(),this.m_)};i.restore=function(){O(this.aStack_.pop(),
-this);this.m_=this.mStack_.pop()};function ha(b){var a=0;for(;a<3;a++){var c=0;for(;c<2;c++)if(!isFinite(b[a][c])||isNaN(b[a][c]))return false}return true}function A(b,a,c){if(!!ha(a)){b.m_=a;if(c)b.lineScale_=W(V(a[0][0]*a[1][1]-a[0][1]*a[1][0]))}}i.translate=function(b,a){A(this,y([[1,0,0],[0,1,0],[b,a,1]],this.m_),false)};i.rotate=function(b){var a=G(b),c=F(b);A(this,y([[a,c,0],[-c,a,0],[0,0,1]],this.m_),false)};i.scale=function(b,a){this.arcScaleX_*=b;this.arcScaleY_*=a;A(this,y([[b,0,0],[0,a,
-0],[0,0,1]],this.m_),true)};i.transform=function(b,a,c,d,f,h){A(this,y([[b,a,0],[c,d,0],[f,h,1]],this.m_),true)};i.setTransform=function(b,a,c,d,f,h){A(this,[[b,a,0],[c,d,0],[f,h,1]],true)};i.clip=function(){};i.arcTo=function(){};i.createPattern=function(){return new U};function D(b){this.type_=b;this.r1_=this.y1_=this.x1_=this.r0_=this.y0_=this.x0_=0;this.colors_=[]}D.prototype.addColorStop=function(b,a){a=P(a);this.colors_.push({offset:b,color:a.color,alpha:a.alpha})};function U(){}G_vmlCanvasManager=
-M;CanvasRenderingContext2D=H;CanvasGradient=D;CanvasPattern=U})();
+document.createElement("canvas").getContext || (function () {
+ var s = Math, j = s.round, F = s.sin, G = s.cos, V = s.abs, W = s.sqrt, k = 10, v = k / 2;
+ function X() { return this.context_ || (this.context_ = new H(this)); }
+ var L = Array.prototype.slice;
+ function Y(b, a) { var c = L.call(arguments, 2); return function () { return b.apply(a, c.concat(L.call(arguments))); }; }
+ var M = { init: function (b) { if (/MSIE/.test(navigator.userAgent) && !window.opera) {
+ var a = b || document;
+ a.createElement("canvas");
+ a.attachEvent("onreadystatechange", Y(this.init_, this, a));
+ } }, init_: function (b) {
+ b.namespaces.g_vml_ ||
+ b.namespaces.add("g_vml_", "urn:schemas-microsoft-com:vml", "#default#VML");
+ b.namespaces.g_o_ || b.namespaces.add("g_o_", "urn:schemas-microsoft-com:office:office", "#default#VML");
+ if (!b.styleSheets.ex_canvas_) {
+ var a = b.createStyleSheet();
+ a.owningElement.id = "ex_canvas_";
+ a.cssText = "canvas{display:inline-block;overflow:hidden;text-align:left;width:300px;height:150px}g_vml_\\:*{behavior:url(#default#VML)}g_o_\\:*{behavior:url(#default#VML)}";
+ }
+ var c = b.getElementsByTagName("canvas"), d = 0;
+ for (; d < c.length; d++)
+ this.initElement(c[d]);
+ },
+ initElement: function (b) { if (!b.getContext) {
+ b.getContext = X;
+ b.innerHTML = "";
+ b.attachEvent("onpropertychange", Z);
+ b.attachEvent("onresize", $);
+ var a = b.attributes;
+ if (a.width && a.width.specified)
+ b.style.width = a.width.nodeValue + "px";
+ else
+ b.width = b.clientWidth;
+ if (a.height && a.height.specified)
+ b.style.height = a.height.nodeValue + "px";
+ else
+ b.height = b.clientHeight;
+ } return b; } };
+ function Z(b) {
+ var a = b.srcElement;
+ switch (b.propertyName) {
+ case "width":
+ a.style.width = a.attributes.width.nodeValue + "px";
+ a.getContext().clearRect();
+ break;
+ case "height":
+ a.style.height = a.attributes.height.nodeValue + "px";
+ a.getContext().clearRect();
+ break;
+ }
+ }
+ function $(b) { var a = b.srcElement; if (a.firstChild) {
+ a.firstChild.style.width = a.clientWidth + "px";
+ a.firstChild.style.height = a.clientHeight + "px";
+ } }
+ M.init();
+ var N = [], B = 0;
+ for (; B < 16; B++) {
+ var C = 0;
+ for (; C < 16; C++)
+ N[B * 16 + C] = B.toString(16) + C.toString(16);
+ }
+ function I() { return [[1, 0, 0], [0, 1, 0], [0, 0, 1]]; }
+ function y(b, a) {
+ var c = I(), d = 0;
+ for (; d < 3; d++) {
+ var f = 0;
+ for (; f < 3; f++) {
+ var h = 0, g = 0;
+ for (; g < 3; g++)
+ h += b[d][g] * a[g][f];
+ c[d][f] =
+ h;
+ }
+ }
+ return c;
+ }
+ function O(b, a) { a.fillStyle = b.fillStyle; a.lineCap = b.lineCap; a.lineJoin = b.lineJoin; a.lineWidth = b.lineWidth; a.miterLimit = b.miterLimit; a.shadowBlur = b.shadowBlur; a.shadowColor = b.shadowColor; a.shadowOffsetX = b.shadowOffsetX; a.shadowOffsetY = b.shadowOffsetY; a.strokeStyle = b.strokeStyle; a.globalAlpha = b.globalAlpha; a.arcScaleX_ = b.arcScaleX_; a.arcScaleY_ = b.arcScaleY_; a.lineScale_ = b.lineScale_; }
+ function P(b) {
+ var a, c = 1;
+ b = String(b);
+ if (b.substring(0, 3) == "rgb") {
+ var d = b.indexOf("(", 3), f = b.indexOf(")", d +
+ 1), h = b.substring(d + 1, f).split(",");
+ a = "#";
+ var g = 0;
+ for (; g < 3; g++)
+ a += N[Number(h[g])];
+ if (h.length == 4 && b.substr(3, 1) == "a")
+ c = h[3];
+ }
+ else
+ a = b;
+ return { color: a, alpha: c };
+ }
+ function aa(b) { switch (b) {
+ case "butt": return "flat";
+ case "round": return "round";
+ case "square":
+ default: return "square";
+ } }
+ function H(b) {
+ this.m_ = I();
+ this.mStack_ = [];
+ this.aStack_ = [];
+ this.currentPath_ = [];
+ this.fillStyle = this.strokeStyle = "#000";
+ this.lineWidth = 1;
+ this.lineJoin = "miter";
+ this.lineCap = "butt";
+ this.miterLimit = k * 1;
+ this.globalAlpha = 1;
+ this.canvas = b;
+ var a = b.ownerDocument.createElement("div");
+ a.style.width = b.clientWidth + "px";
+ a.style.height = b.clientHeight + "px";
+ a.style.overflow = "hidden";
+ a.style.position = "absolute";
+ b.appendChild(a);
+ this.element_ = a;
+ this.lineScale_ = this.arcScaleY_ = this.arcScaleX_ = 1;
+ }
+ var i = H.prototype;
+ i.clearRect = function () { this.element_.innerHTML = ""; };
+ i.beginPath = function () { this.currentPath_ = []; };
+ i.moveTo = function (b, a) { var c = this.getCoords_(b, a); this.currentPath_.push({ type: "moveTo", x: c.x, y: c.y }); this.currentX_ = c.x; this.currentY_ = c.y; };
+ i.lineTo = function (b, a) { var c = this.getCoords_(b, a); this.currentPath_.push({ type: "lineTo", x: c.x, y: c.y }); this.currentX_ = c.x; this.currentY_ = c.y; };
+ i.bezierCurveTo = function (b, a, c, d, f, h) { var g = this.getCoords_(f, h), l = this.getCoords_(b, a), e = this.getCoords_(c, d); Q(this, l, e, g); };
+ function Q(b, a, c, d) { b.currentPath_.push({ type: "bezierCurveTo", cp1x: a.x, cp1y: a.y, cp2x: c.x, cp2y: c.y, x: d.x, y: d.y }); b.currentX_ = d.x; b.currentY_ = d.y; }
+ i.quadraticCurveTo = function (b, a, c, d) {
+ var f = this.getCoords_(b, a), h = this.getCoords_(c, d), g = { x: this.currentX_ +
+ 0.6666666666666666 * (f.x - this.currentX_), y: this.currentY_ + 0.6666666666666666 * (f.y - this.currentY_) };
+ Q(this, g, { x: g.x + (h.x - this.currentX_) / 3, y: g.y + (h.y - this.currentY_) / 3 }, h);
+ };
+ i.arc = function (b, a, c, d, f, h) { c *= k; var g = h ? "at" : "wa", l = b + G(d) * c - v, e = a + F(d) * c - v, m = b + G(f) * c - v, r = a + F(f) * c - v; if (l == m && !h)
+ l += 0.125; var n = this.getCoords_(b, a), o = this.getCoords_(l, e), q = this.getCoords_(m, r); this.currentPath_.push({ type: g, x: n.x, y: n.y, radius: c, xStart: o.x, yStart: o.y, xEnd: q.x, yEnd: q.y }); };
+ i.rect = function (b, a, c, d) {
+ this.moveTo(b, a);
+ this.lineTo(b + c, a);
+ this.lineTo(b + c, a + d);
+ this.lineTo(b, a + d);
+ this.closePath();
+ };
+ i.strokeRect = function (b, a, c, d) { var f = this.currentPath_; this.beginPath(); this.moveTo(b, a); this.lineTo(b + c, a); this.lineTo(b + c, a + d); this.lineTo(b, a + d); this.closePath(); this.stroke(); this.currentPath_ = f; };
+ i.fillRect = function (b, a, c, d) { var f = this.currentPath_; this.beginPath(); this.moveTo(b, a); this.lineTo(b + c, a); this.lineTo(b + c, a + d); this.lineTo(b, a + d); this.closePath(); this.fill(); this.currentPath_ = f; };
+ i.createLinearGradient = function (b, a, c, d) { var f = new D("gradient"); f.x0_ = b; f.y0_ = a; f.x1_ = c; f.y1_ = d; return f; };
+ i.createRadialGradient = function (b, a, c, d, f, h) { var g = new D("gradientradial"); g.x0_ = b; g.y0_ = a; g.r0_ = c; g.x1_ = d; g.y1_ = f; g.r1_ = h; return g; };
+ i.drawImage = function (b) {
+ var a, c, d, f, h, g, l, e, m = b.runtimeStyle.width, r = b.runtimeStyle.height;
+ b.runtimeStyle.width = "auto";
+ b.runtimeStyle.height = "auto";
+ var n = b.width, o = b.height;
+ b.runtimeStyle.width = m;
+ b.runtimeStyle.height = r;
+ if (arguments.length == 3) {
+ a = arguments[1];
+ c = arguments[2];
+ h = g = 0;
+ l = d = n;
+ e = f = o;
+ }
+ else if (arguments.length ==
+ 5) {
+ a = arguments[1];
+ c = arguments[2];
+ d = arguments[3];
+ f = arguments[4];
+ h = g = 0;
+ l = n;
+ e = o;
+ }
+ else if (arguments.length == 9) {
+ h = arguments[1];
+ g = arguments[2];
+ l = arguments[3];
+ e = arguments[4];
+ a = arguments[5];
+ c = arguments[6];
+ d = arguments[7];
+ f = arguments[8];
+ }
+ else
+ throw Error("Invalid number of arguments");
+ var q = this.getCoords_(a, c), t = [];
+ t.push(" ', '", "");
+ this.element_.insertAdjacentHTML("BeforeEnd", t.join(""));
+ };
+ i.stroke = function (b) {
+ var a = [], c = P(b ? this.fillStyle : this.strokeStyle), d = c.color, f = c.alpha * this.globalAlpha;
+ a.push(" g.x)
+ g.x = e.x;
+ if (h.y == null || e.y < h.y)
+ h.y = e.y;
+ if (g.y == null || e.y > g.y)
+ g.y = e.y;
+ }
+ }
+ a.push(' ">');
+ if (b)
+ if (typeof this.fillStyle == "object") {
+ var m = this.fillStyle, r = 0, n = { x: 0, y: 0 }, o = 0, q = 1;
+ if (m.type_ == "gradient") {
+ var t = m.x1_ / this.arcScaleX_, E = m.y1_ / this.arcScaleY_, p = this.getCoords_(m.x0_ / this.arcScaleX_, m.y0_ / this.arcScaleY_), z = this.getCoords_(t, E);
+ r = Math.atan2(z.x - p.x, z.y - p.y) * 180 / Math.PI;
+ if (r < 0)
+ r += 360;
+ if (r < 1.0E-6)
+ r = 0;
+ }
+ else {
+ var p = this.getCoords_(m.x0_, m.y0_), w = g.x - h.x, x = g.y - h.y;
+ n = { x: (p.x - h.x) / w, y: (p.y - h.y) / x };
+ w /= this.arcScaleX_ * k;
+ x /= this.arcScaleY_ * k;
+ var R = s.max(w, x);
+ o = 2 * m.r0_ / R;
+ q = 2 * m.r1_ / R - o;
+ }
+ var u = m.colors_;
+ u.sort(function (ba, ca) { return ba.offset - ca.offset; });
+ var J = u.length, da = u[0].color, ea = u[J - 1].color, fa = u[0].alpha * this.globalAlpha, ga = u[J - 1].alpha * this.globalAlpha, S = [], l = 0;
+ for (; l < J; l++) {
+ var T = u[l];
+ S.push(T.offset * q +
+ o + " " + T.color);
+ }
+ a.push('');
+ }
+ else
+ a.push('');
+ else {
+ var K = this.lineScale_ * this.lineWidth;
+ if (K < 1)
+ f *= K;
+ a.push("');
+ }
+ a.push("");
+ this.element_.insertAdjacentHTML("beforeEnd", a.join(""));
+ };
+ i.fill = function () { this.stroke(true); };
+ i.closePath = function () { this.currentPath_.push({ type: "close" }); };
+ i.getCoords_ = function (b, a) { var c = this.m_; return { x: k * (b * c[0][0] + a * c[1][0] + c[2][0]) - v, y: k * (b * c[0][1] + a * c[1][1] + c[2][1]) - v }; };
+ i.save = function () { var b = {}; O(this, b); this.aStack_.push(b); this.mStack_.push(this.m_); this.m_ = y(I(), this.m_); };
+ i.restore = function () {
+ O(this.aStack_.pop(), this);
+ this.m_ = this.mStack_.pop();
+ };
+ function ha(b) { var a = 0; for (; a < 3; a++) {
+ var c = 0;
+ for (; c < 2; c++)
+ if (!isFinite(b[a][c]) || isNaN(b[a][c]))
+ return false;
+ } return true; }
+ function A(b, a, c) { if (!!ha(a)) {
+ b.m_ = a;
+ if (c)
+ b.lineScale_ = W(V(a[0][0] * a[1][1] - a[0][1] * a[1][0]));
+ } }
+ i.translate = function (b, a) { A(this, y([[1, 0, 0], [0, 1, 0], [b, a, 1]], this.m_), false); };
+ i.rotate = function (b) { var a = G(b), c = F(b); A(this, y([[a, c, 0], [-c, a, 0], [0, 0, 1]], this.m_), false); };
+ i.scale = function (b, a) {
+ this.arcScaleX_ *= b;
+ this.arcScaleY_ *= a;
+ A(this, y([[b, 0, 0], [0, a,
+ 0], [0, 0, 1]], this.m_), true);
+ };
+ i.transform = function (b, a, c, d, f, h) { A(this, y([[b, a, 0], [c, d, 0], [f, h, 1]], this.m_), true); };
+ i.setTransform = function (b, a, c, d, f, h) { A(this, [[b, a, 0], [c, d, 0], [f, h, 1]], true); };
+ i.clip = function () { };
+ i.arcTo = function () { };
+ i.createPattern = function () { return new U; };
+ function D(b) { this.type_ = b; this.r1_ = this.y1_ = this.x1_ = this.r0_ = this.y0_ = this.x0_ = 0; this.colors_ = []; }
+ D.prototype.addColorStop = function (b, a) { a = P(a); this.colors_.push({ offset: b, color: a.color, alpha: a.alpha }); };
+ function U() { }
+ G_vmlCanvasManager =
+ M;
+ CanvasRenderingContext2D = H;
+ CanvasGradient = D;
+ CanvasPattern = U;
+})();
diff --git a/examples/vendors/excanvas/excanvas.js b/examples/vendors/excanvas/excanvas.js
index 367764b4..9df49d2f 100644
--- a/examples/vendors/excanvas/excanvas.js
+++ b/examples/vendors/excanvas/excanvas.js
@@ -11,8 +11,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
-
-
// Known Issues:
//
// * Patterns are not implemented.
@@ -30,895 +28,711 @@
// (http://webfx.eae.net/dhtml/boxsizing/boxsizing.html)
// * Non uniform scaling does not correctly scale strokes.
// * Optimize. There is always room for speed improvements.
-
// Only add this code if we do not already have a canvas implementation
if (!document.createElement('canvas').getContext) {
-
-(function() {
-
- // alias some functions to make (compiled) code shorter
- var m = Math;
- var mr = m.round;
- var ms = m.sin;
- var mc = m.cos;
- var abs = m.abs;
- var sqrt = m.sqrt;
-
- // this is used for sub pixel precision
- var Z = 10;
- var Z2 = Z / 2;
-
- /**
- * This funtion is assigned to the