From 70d0dd9c0c714f190eec75a0e4966970c8985997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sat, 7 May 2011 17:11:06 +0100 Subject: [PATCH] Move #moveTo() to the same scope as the other drawing commands, and add explaining comments. --- src/path/CompoundPath.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/path/CompoundPath.js b/src/path/CompoundPath.js index 2d87ed58..4924812c 100644 --- a/src/path/CompoundPath.js +++ b/src/path/CompoundPath.js @@ -46,12 +46,6 @@ var CompoundPath = this.CompoundPath = PathItem.extend({ this.children[i].smooth(); }, - moveTo: function() { - var path = new Path(); - this.appendTop(path); - path.moveTo.apply(path, arguments); - }, - draw: function(ctx, param) { var firstChild = this.children[0]; ctx.beginPath(); @@ -70,8 +64,7 @@ var CompoundPath = this.CompoundPath = PathItem.extend({ ctx.stroke(); } } -}, new function() { - +}, new function() { // Injection scope for PostScript-like drawing functions function getCurrentPath(that) { if (that.children.length) { return that.children[that.children.length - 1]; @@ -81,6 +74,12 @@ var CompoundPath = this.CompoundPath = PathItem.extend({ } var fields = { + moveTo: function() { + var path = new Path(); + this.appendTop(path); + path.moveTo.apply(path, arguments); + }, + moveBy: function() { var point = arguments.length ? Point.read(arguments) : new Point(), path = getCurrentPath(this), @@ -93,6 +92,7 @@ var CompoundPath = this.CompoundPath = PathItem.extend({ } }; + // Redirect all other drawing commands to the current path Base.each(['lineTo', 'cubicCurveTo', 'quadraticCurveTo', 'curveTo', 'arcTo', 'lineBy', 'curveBy', 'arcBy'], function(key) { fields[key] = function() {