Remove incorrect offsets in polygon rendering and fix <rect> position when part of a group. Closes #113. Closes #229.

This commit is contained in:
kangax 2012-08-14 14:03:20 +02:00
parent 99458c3f43
commit a0d05624ed
7 changed files with 23 additions and 27 deletions

View file

@ -1,6 +1,6 @@
/*! Fabric.js Copyright 2008-2012, Printio (Juriy Zaytsev, Maxim Chernyak) */
var fabric = fabric || { version: "0.8.47" };
var fabric = fabric || { version: "0.8.48" };
if (typeof exports != 'undefined') {
exports.fabric = fabric;

22
dist/all.js vendored
View file

@ -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.47" };
var fabric = fabric || { version: "0.8.48" };
if (typeof exports != 'undefined') {
exports.fabric = fabric;
@ -7829,13 +7829,13 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
ctx.fillStyle = this.fill;
}
// TODO: this breaks some shapes, need to look into it
// if (this.group) {
// ctx.translate(
// -this.group.width / 2 + this.width / 2,
// -this.group.height / 2 + this.height / 2
// );
// }
if (this.group && this.type === 'rect') {
ctx.translate(
-this.group.width / 2 + this.width / 2,
-this.group.height / 2 + this.height / 2
);
}
this._render(ctx, noTransform);
if (this.active && !noTransform) {
@ -9936,13 +9936,11 @@ 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 - offsetX, this.points[0].y - offsetY);
ctx.moveTo(this.points[0].x, this.points[0].y);
for (var i = 0, len = this.points.length; i < len; i++) {
point = this.points[i];
ctx.lineTo(point.x - offsetX, point.y - offsetY);
ctx.lineTo(point.x, point.y);
}
if (this.fill) {
ctx.fill();

4
dist/all.min.js vendored

File diff suppressed because one or more lines are too long

BIN
dist/all.min.js.gz vendored

Binary file not shown.

View file

@ -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.47",
"version": "0.8.48",
"author": "Juriy Zaytsev <kangax@gmail.com>",
"keywords": ["canvas", "graphic", "graphics", "SVG", "node-canvas", "parser", "HTML5", "object model"],
"repository": "git://github.com/kangax/fabric.js",

View file

@ -396,13 +396,13 @@
ctx.fillStyle = this.fill;
}
// TODO: this breaks some shapes, need to look into it
// if (this.group) {
// ctx.translate(
// -this.group.width / 2 + this.width / 2,
// -this.group.height / 2 + this.height / 2
// );
// }
if (this.group && this.type === 'rect') {
ctx.translate(
-this.group.width / 2 + this.width / 2,
-this.group.height / 2 + this.height / 2
);
}
this._render(ctx, noTransform);
if (this.active && !noTransform) {

View file

@ -98,13 +98,11 @@
*/
_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 - offsetX, this.points[0].y - offsetY);
ctx.moveTo(this.points[0].x, this.points[0].y);
for (var i = 0, len = this.points.length; i < len; i++) {
point = this.points[i];
ctx.lineTo(point.x - offsetX, point.y - offsetY);
ctx.lineTo(point.x, point.y);
}
if (this.fill) {
ctx.fill();