mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-21 14:34:43 +00:00
Fix rendering of lines where x1,y1 are less than x2,y2.
This commit is contained in:
parent
feaddda1c0
commit
c7006df133
7 changed files with 22 additions and 14 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*! Fabric.js Copyright 2008-2012, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
|
||||
|
||||
var fabric = fabric || { version: "0.7.24" };
|
||||
var fabric = fabric || { version: "0.7.25" };
|
||||
|
||||
if (typeof exports != 'undefined') {
|
||||
exports.fabric = fabric;
|
||||
|
|
|
|||
14
dist/all.js
vendored
14
dist/all.js
vendored
|
|
@ -1,6 +1,6 @@
|
|||
/*! Fabric.js Copyright 2008-2012, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
|
||||
|
||||
var fabric = fabric || { version: "0.7.24" };
|
||||
var fabric = fabric || { version: "0.7.25" };
|
||||
|
||||
if (typeof exports != 'undefined') {
|
||||
exports.fabric = fabric;
|
||||
|
|
@ -8326,8 +8326,8 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
|
|||
},
|
||||
|
||||
_setWidthHeight: function() {
|
||||
this.set('width', (this.x2 - this.x1) || 1);
|
||||
this.set('height', (this.y2 - this.y1) || 1);
|
||||
this.set('width', Math.abs(this.x2 - this.x1) || 1 /* prevent 0 width */);
|
||||
this.set('height', Math.abs(this.y2 - this.y1) || 1 /* prevent 0 height */);
|
||||
this.set('left', this.x1 + this.width / 2);
|
||||
this.set('top', this.y1 + this.height / 2);
|
||||
},
|
||||
|
|
@ -8348,9 +8348,13 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
|
|||
_render: function(ctx) {
|
||||
ctx.beginPath();
|
||||
|
||||
var xMultiplier = this.x1 > this.x2 ? -1 : 1,
|
||||
yMultiplier = this.y1 > this.y2 ? -1 : 1;
|
||||
|
||||
|
||||
// move from center (of virtual box) to its left/top corner
|
||||
ctx.moveTo(this.width === 1 ? 0 : (-this.width / 2), this.height === 1 ? 0 : (-this.height / 2));
|
||||
ctx.lineTo(this.width === 1 ? 0 : (this.width / 2), this.height === 1 ? 0 : (this.height / 2));
|
||||
ctx.moveTo(this.width === 1 ? 0 : (this.width / 2) * xMultiplier, this.height === 1 ? 0 : (this.height / 2) * yMultiplier);
|
||||
ctx.lineTo(this.width === 1 ? 0 : (this.width / 2) * -xMultiplier, this.height === 1 ? 0 : (this.height / 2) * -yMultiplier);
|
||||
|
||||
ctx.lineWidth = this.strokeWidth;
|
||||
|
||||
|
|
|
|||
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.7.24",
|
||||
"version": "0.7.25",
|
||||
"author": "Juriy Zaytsev <kangax@gmail.com>",
|
||||
"keywords": ["canvas", "graphic", "graphics", "SVG", "node-canvas", "parser", "HTML5", "object model"],
|
||||
"repository": "git://github.com/kangax/fabric.js",
|
||||
|
|
|
|||
2
site
2
site
|
|
@ -1 +1 @@
|
|||
Subproject commit bc5475bf1c3c0e08e34a574701d593c8ceb318ba
|
||||
Subproject commit 28171dba210627ff20cd4a1c9447a2c74c6f8e3b
|
||||
|
|
@ -49,8 +49,8 @@
|
|||
},
|
||||
|
||||
_setWidthHeight: function() {
|
||||
this.set('width', (this.x2 - this.x1) || 1);
|
||||
this.set('height', (this.y2 - this.y1) || 1);
|
||||
this.set('width', Math.abs(this.x2 - this.x1) || 1 /* prevent 0 width */);
|
||||
this.set('height', Math.abs(this.y2 - this.y1) || 1 /* prevent 0 height */);
|
||||
this.set('left', this.x1 + this.width / 2);
|
||||
this.set('top', this.y1 + this.height / 2);
|
||||
},
|
||||
|
|
@ -71,9 +71,13 @@
|
|||
_render: function(ctx) {
|
||||
ctx.beginPath();
|
||||
|
||||
var xMultiplier = this.x1 > this.x2 ? -1 : 1,
|
||||
yMultiplier = this.y1 > this.y2 ? -1 : 1;
|
||||
|
||||
|
||||
// move from center (of virtual box) to its left/top corner
|
||||
ctx.moveTo(this.width === 1 ? 0 : (-this.width / 2), this.height === 1 ? 0 : (-this.height / 2));
|
||||
ctx.lineTo(this.width === 1 ? 0 : (this.width / 2), this.height === 1 ? 0 : (this.height / 2));
|
||||
ctx.moveTo(this.width === 1 ? 0 : (this.width / 2) * xMultiplier, this.height === 1 ? 0 : (this.height / 2) * yMultiplier);
|
||||
ctx.lineTo(this.width === 1 ? 0 : (this.width / 2) * -xMultiplier, this.height === 1 ? 0 : (this.height / 2) * -yMultiplier);
|
||||
|
||||
ctx.lineWidth = this.strokeWidth;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue