mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-19 13:40:58 +00:00
Build distribution, bump version.
This commit is contained in:
parent
0fcd356bf6
commit
f99ee7e2e7
5 changed files with 185 additions and 51 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*! Fabric.js Copyright 2008-2012, Printio (Juriy Zaytsev, Maxim Chernyak) */
|
||||
|
||||
var fabric = fabric || { version: "0.8.43" };
|
||||
var fabric = fabric || { version: "0.8.44" };
|
||||
|
||||
if (typeof exports != 'undefined') {
|
||||
exports.fabric = fabric;
|
||||
|
|
|
|||
228
dist/all.js
vendored
228
dist/all.js
vendored
|
|
@ -1,7 +1,7 @@
|
|||
/* build: `node build.js modules=ALL` */
|
||||
/*! Fabric.js Copyright 2008-2012, Printio (Juriy Zaytsev, Maxim Chernyak) */
|
||||
|
||||
var fabric = fabric || { version: "0.8.43" };
|
||||
var fabric = fabric || { version: "0.8.44" };
|
||||
|
||||
if (typeof exports != 'undefined') {
|
||||
exports.fabric = fabric;
|
||||
|
|
@ -7480,10 +7480,12 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
|
|||
* @property
|
||||
* @type Array
|
||||
*/
|
||||
stateProperties: ('top left width height scaleX scaleY flipX flipY ' +
|
||||
'theta angle opacity cornersize fill overlayFill stroke ' +
|
||||
'strokeWidth fillRule borderScaleFactor transformMatrix ' +
|
||||
'selectable').split(' '),
|
||||
stateProperties: (
|
||||
'top left width height scaleX scaleY flipX flipY ' +
|
||||
'theta angle opacity cornersize fill overlayFill ' +
|
||||
'stroke strokeWidth strokeDashArray fillRule ' +
|
||||
'borderScaleFactor transformMatrix selectable'
|
||||
).split(' '),
|
||||
|
||||
top: 0,
|
||||
left: 0,
|
||||
|
|
@ -7505,6 +7507,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
|
|||
overlayFill: null,
|
||||
stroke: null,
|
||||
strokeWidth: 1,
|
||||
strokeDashArray: null,
|
||||
borderOpacityWhenMoving: 0.4,
|
||||
borderScaleFactor: 1,
|
||||
transformMatrix: null,
|
||||
|
|
@ -7609,6 +7612,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
|
|||
overlayFill: this.overlayFill,
|
||||
stroke: this.stroke,
|
||||
strokeWidth: this.strokeWidth,
|
||||
strokeDashArray: this.strokeDashArray,
|
||||
scaleX: toFixed(this.scaleX, this.NUM_FRACTION_DIGITS),
|
||||
scaleY: toFixed(this.scaleY, this.NUM_FRACTION_DIGITS),
|
||||
angle: toFixed(this.getAngle(), this.NUM_FRACTION_DIGITS),
|
||||
|
|
@ -7646,6 +7650,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
|
|||
return [
|
||||
"stroke: ", (this.stroke ? this.stroke : 'none'), "; ",
|
||||
"stroke-width: ", (this.strokeWidth ? this.strokeWidth : '0'), "; ",
|
||||
"stroke-dasharray: ", (this.strokeDashArray ? this.strokeDashArray.join(' ') : "; "),
|
||||
"fill: ", (this.fill ? this.fill : 'none'), "; ",
|
||||
"opacity: ", (this.opacity ? this.opacity : '1'), ";"
|
||||
].join("");
|
||||
|
|
@ -7709,34 +7714,45 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
|
|||
},
|
||||
|
||||
/**
|
||||
* Basic setter
|
||||
* @param {Any} property
|
||||
* @param {Any} value
|
||||
* @return {fabric.Object} thisArg
|
||||
* Sets property to a given value
|
||||
* @method set
|
||||
* @param {String} name
|
||||
* @param {Object|Function} value
|
||||
* @return {fabric.Group} thisArg
|
||||
* @chainable
|
||||
*/
|
||||
set: function(property, value) {
|
||||
var shouldConstrainValue = (property === 'scaleX' || property === 'scaleY') && value < this.MIN_SCALE_LIMIT;
|
||||
if (shouldConstrainValue) {
|
||||
value = this.MIN_SCALE_LIMIT;
|
||||
}
|
||||
if (typeof property == 'object') {
|
||||
for (var prop in property) {
|
||||
this.set(prop, property[prop]);
|
||||
set: function(key, value) {
|
||||
if (typeof key === 'object') {
|
||||
for (var prop in key) {
|
||||
this._set(prop, key[prop]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (property === 'angle') {
|
||||
this.setAngle(value);
|
||||
if (typeof value === 'function') {
|
||||
this._set(key, value(this.get(key)));
|
||||
}
|
||||
else {
|
||||
this[property] = value;
|
||||
this._set(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
_set: function(key, value) {
|
||||
var shouldConstrainValue = (key === 'scaleX' || key === 'scaleY') &&
|
||||
value < this.MIN_SCALE_LIMIT;
|
||||
|
||||
if (shouldConstrainValue) {
|
||||
value = this.MIN_SCALE_LIMIT;
|
||||
}
|
||||
if (key === 'angle') {
|
||||
this.setAngle(value);
|
||||
}
|
||||
else {
|
||||
this[key] = value;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggles specified property from `true` to `false` or from `false` to `true`
|
||||
* @method toggle
|
||||
|
|
@ -7796,7 +7812,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
|
|||
this.transform(ctx);
|
||||
}
|
||||
|
||||
if (this.stroke) {
|
||||
if (this.stroke || this.strokeDashArray) {
|
||||
ctx.lineWidth = this.strokeWidth;
|
||||
ctx.strokeStyle = this.stroke;
|
||||
}
|
||||
|
|
@ -8070,6 +8086,63 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
|
|||
return this;
|
||||
},
|
||||
|
||||
_renderDashedStroke: function(ctx) {
|
||||
|
||||
if (1 & this.strokeDashArray.length /* if odd number of items */) {
|
||||
/* duplicate items */
|
||||
this.strokeDashArray.push.apply(this.strokeDashArray, this.strokeDashArray);
|
||||
}
|
||||
|
||||
var i = 0,
|
||||
x = -this.width/2, y = -this.height/2,
|
||||
_this = this,
|
||||
padding = this.padding,
|
||||
width = this.getWidth(),
|
||||
height = this.getHeight(),
|
||||
dashedArrayLength = this.strokeDashArray.length;
|
||||
|
||||
ctx.save();
|
||||
ctx.beginPath();
|
||||
|
||||
function renderSide(xMultiplier, yMultiplier) {
|
||||
|
||||
var lineLength = 0,
|
||||
sideLength = (yMultiplier ? _this.height : _this.width) + padding * 2;
|
||||
|
||||
while (lineLength < sideLength) {
|
||||
|
||||
var lengthOfSubPath = _this.strokeDashArray[i++];
|
||||
lineLength += lengthOfSubPath;
|
||||
|
||||
if (lineLength > sideLength) {
|
||||
var lengthDiff = lineLength - sideLength;
|
||||
}
|
||||
|
||||
// track coords
|
||||
if (xMultiplier) {
|
||||
x += (lengthOfSubPath * xMultiplier) - (lengthDiff * xMultiplier || 0);
|
||||
}
|
||||
else {
|
||||
y += (lengthOfSubPath * yMultiplier) - (lengthDiff * yMultiplier || 0);
|
||||
}
|
||||
|
||||
ctx[1 & i /* odd */ ? 'moveTo' : 'lineTo'](x, y);
|
||||
if (i >= dashedArrayLength) {
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
renderSide(1, 0);
|
||||
renderSide(0, 1);
|
||||
renderSide(-1, 0);
|
||||
renderSide(0, -1);
|
||||
|
||||
ctx.stroke();
|
||||
ctx.closePath();
|
||||
ctx.restore();
|
||||
},
|
||||
|
||||
/**
|
||||
* Draws corners of an object's bounding box.
|
||||
* Requires public properties: width, height, scaleX, scaleY
|
||||
|
|
@ -9483,7 +9556,11 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
|
|||
if (this.fill) {
|
||||
ctx.fill();
|
||||
}
|
||||
if (this.stroke) {
|
||||
|
||||
if (this.strokeDashArray) {
|
||||
this._renderDashedStroke(ctx);
|
||||
}
|
||||
else if (this.stroke) {
|
||||
ctx.stroke();
|
||||
}
|
||||
},
|
||||
|
|
@ -9840,11 +9917,13 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
|
|||
*/
|
||||
_render: function(ctx) {
|
||||
var point;
|
||||
var offsetX = this.minX + this.width / 2,
|
||||
offsetY = this.minY + this.height / 2;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(this.points[0].x, this.points[0].y);
|
||||
ctx.moveTo(this.points[0].x - offsetX, this.points[0].y - offsetY);
|
||||
for (var i = 0, len = this.points.length; i < len; i++) {
|
||||
point = this.points[i];
|
||||
ctx.lineTo(point.x, point.y);
|
||||
ctx.lineTo(point.x - offsetX, point.y - offsetY);
|
||||
}
|
||||
if (this.fill) {
|
||||
ctx.fill();
|
||||
|
|
@ -11048,31 +11127,19 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
|
|||
},
|
||||
|
||||
/**
|
||||
* Sets property to a given value
|
||||
* @method set
|
||||
* @param {String} name
|
||||
* @param {Object|Function} value
|
||||
* @return {fabric.Group} thisArg
|
||||
* @chainable
|
||||
* @private
|
||||
*/
|
||||
set: function(name, value) {
|
||||
if (typeof value == 'function') {
|
||||
// recurse
|
||||
this.set(name, value(this[name]));
|
||||
_set: function(key, value) {
|
||||
if (key === 'fill' || key === 'opacity') {
|
||||
var i = this.objects.length;
|
||||
this[key] = value;
|
||||
while (i--) {
|
||||
this.objects[i].set(key, value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (name === 'fill' || name === 'opacity') {
|
||||
var i = this.objects.length;
|
||||
this[name] = value;
|
||||
while (i--) {
|
||||
this.objects[i].set(name, value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this[name] = value;
|
||||
}
|
||||
this[key] = value;
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -11591,7 +11658,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
|
|||
canvasEl.width = imgEl.width;
|
||||
canvasEl.height = imgEl.height;
|
||||
|
||||
canvasEl.getContext('2d').drawImage(imgEl, 0, 0);
|
||||
canvasEl.getContext('2d').drawImage(imgEl, 0, 0, imgEl.width, imgEl.height);
|
||||
|
||||
this.filters.forEach(function(filter) {
|
||||
filter && filter.applyTo(canvasEl);
|
||||
|
|
@ -12350,6 +12417,73 @@ fabric.Image.filters.GradientTransparency = fabric.util.createClass( /** @scope
|
|||
fabric.Image.filters.GradientTransparency.fromObject = function(object) {
|
||||
return new fabric.Image.filters.GradientTransparency(object);
|
||||
};
|
||||
|
||||
/**
|
||||
* @class fabric.Image.filters.Tint
|
||||
* @memberOf fabric.Image.filters
|
||||
*/
|
||||
fabric.Image.filters.Tint = fabric.util.createClass( /** @scope fabric.Image.filters.Tint.prototype */ {
|
||||
|
||||
/**
|
||||
* @param {String} type
|
||||
*/
|
||||
type: "Tint",
|
||||
|
||||
/**
|
||||
* @memberOf fabric.Image.filters.RemoveWhite.prototype
|
||||
* @param {Object} [options] Options object
|
||||
*/
|
||||
initialize: function(options) {
|
||||
options || (options = { });
|
||||
this.color = options.color || 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method applyTo
|
||||
* @param {Object} canvasEl Canvas element to apply filter to
|
||||
*/
|
||||
applyTo: function(canvasEl) {
|
||||
|
||||
var context = canvasEl.getContext('2d'),
|
||||
imageData = context.getImageData(0, 0, canvasEl.width, canvasEl.height),
|
||||
data = imageData.data,
|
||||
iLen = data.length, i,
|
||||
r, g, b, a;
|
||||
|
||||
var rgb = parseInt(this.color).toString(16);
|
||||
var cr = parseInt('0x'+rgb.substr(0, 2));
|
||||
var cg = parseInt('0x'+rgb.substr(2, 2));
|
||||
var cb = parseInt('0x'+rgb.substr(4, 2));
|
||||
|
||||
for (i = 0; i < iLen; i+=4) {
|
||||
|
||||
a = data[i+3];
|
||||
|
||||
if (a > 0){
|
||||
data[i] = cr;
|
||||
data[i+1] = cg;
|
||||
data[i+2] = cb;
|
||||
}
|
||||
}
|
||||
|
||||
context.putImageData(imageData, 0, 0);
|
||||
},
|
||||
|
||||
/**
|
||||
* @method toJSON
|
||||
* @return {String} json representation of filter
|
||||
*/
|
||||
toJSON: function() {
|
||||
return {
|
||||
type: this.type,
|
||||
color: this.color
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
fabric.Image.filters.Tint.fromObject = function(object) {
|
||||
return new fabric.Image.filters.Tint(object);
|
||||
};
|
||||
(function(global) {
|
||||
|
||||
"use strict";
|
||||
|
|
|
|||
4
dist/all.min.js
vendored
4
dist/all.min.js
vendored
File diff suppressed because one or more lines are too long
BIN
dist/all.min.js.gz
vendored
BIN
dist/all.min.js.gz
vendored
Binary file not shown.
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "fabric",
|
||||
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
|
||||
"version": "0.8.43",
|
||||
"version": "0.8.44",
|
||||
"author": "Juriy Zaytsev <kangax@gmail.com>",
|
||||
"keywords": ["canvas", "graphic", "graphics", "SVG", "node-canvas", "parser", "HTML5", "object model"],
|
||||
"repository": "git://github.com/kangax/fabric.js",
|
||||
|
|
|
|||
Loading…
Reference in a new issue